def gengo_authentication(self, cr, uid, context=None):
        ''' 
        This method tries to open a connection with Gengo. For that, it uses the Public and Private
        keys that are linked to the company (given by Gengo on subscription). It returns a tuple with
         * as first element: a boolean depicting if the authentication was a success or not
         * as second element: the connection, if it was a success, or the error message returned by 
            Gengo when the connection failed.
            This error message can either be displayed in the server logs (if the authentication was called 
            by the cron) or in a dialog box (if requested by the user), thus it's important to return it 
            translated.
        '''

        user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
        if not user.company_id.gengo_public_key or not user.company_id.gengo_private_key:
            return (False, _("Invalid Gengo configuration. Gengo authentication `Public Key` or `Private Key` is missing. Complete Gengo authentication parameters under `Settings > Companies > Gengo Parameters`."))
        try:
            gengo = MyGengo(
                public_key=user.company_id.gengo_public_key.encode('ascii'),
                private_key=user.company_id.gengo_private_key.encode('ascii'),
                sandbox=True,
            )
            gengo.getAccountStats()

            return (True, gengo)
        except Exception, e:
            return (False, _("Gengo Connection Error\n%s") %e)
 def gengo_authentication(self, cr, uid, context=None):
     ''' 
     This method tries to open a connection with Gengo. For that, it uses the Public and Private
     keys that are linked to the company (given by Gengo on subscription). It returns a tuple with
      * as first element: a boolean depicting if the authentication was a success or not
      * as second element: the connection, if it was a success, or the error message returned by 
         Gengo when the connection failed.
         This error message can either be displayed in the server logs (if the authentication was called 
         by the cron) or in a dialog box (if requested by the user), thus it's important to return it 
         translated.
     '''
     user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
     if not user.company_id.gengo_public_key or not user.company_id.gengo_private_key:
         return (
             False,
             _("Gengo `Public Key` or `Private Key` are missing. Enter your Gengo authentication parameters under `Settings > Companies > Gengo Parameters`."
               ))
     try:
         gengo = MyGengo(
             public_key=user.company_id.gengo_public_key.encode('ascii'),
             private_key=user.company_id.gengo_private_key.encode('ascii'),
             sandbox=user.company_id.gengo_sandbox,
         )
         gengo.getAccountStats()
         return (True, gengo)
     except Exception, e:
         _logger.exception('Gengo connection failed')
         return (False,
                 _("Gengo connection failed with this message:\n``%s``") %
                 e)
Ejemplo n.º 3
0
# -*- coding: utf-8 -*-
#!/usr/bin/python

from mygengo import MyGengo

# Get an instance of MyGengo to work with...
gengo = MyGengo(
    public_key = 'xpU@jqEzqnXCb#OOsAeR4z49IX|j}#dwyliMp2RIq1vM9OIKq-K#{mg~sVBUX^91',
    private_key = '~Q9hI|sV(I^iX7|8WQ=l5=CvUmEWx3[=c5ms09|$JIuT-$aiTIYkS4~1F7^C9dw3',
    sandbox = False, # possibly false, depending on your dev needs
)

# Print the account stats...
print gengo.getAccountStats()
Ejemplo n.º 4
0
	def test_getAccountStats(self):
		myGengo = MyGengo(public_key = public_key, private_key = private_key, sandbox = SANDBOX)
		stats = myGengo.getAccountStats()
		self.assertEqual(stats['opstat'], 'ok')
Ejemplo n.º 5
0
 def test_getAccountStats(self):
     myGengo = MyGengo(public_key=public_key,
                       private_key=private_key,
                       sandbox=SANDBOX)
     stats = myGengo.getAccountStats()
     self.assertEqual(stats['opstat'], 'ok')
Ejemplo n.º 6
0
# -*- coding: utf-8 -*-
#!/usr/bin/python

from mygengo import MyGengo

# Get an instance of MyGengo to work with...
gengo = MyGengo(
    public_key = 'your_public_key',
    private_key = 'your_private_key',
    sandbox = False, # possibly false, depending on your dev needs
)

# Print the account stats...
print gengo.getAccountStats()