Skip to content

Commit

Permalink
Separate out set_up_service from get_authorize_url.
Browse files Browse the repository at this point in the history
Functionality should be separate for the two, but get_authorize_url sets up a service if there isn't one already

Brought up because of issue #8
  • Loading branch information
simonv3 committed Jul 24, 2014
1 parent 151ecc7 commit e6c6405
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions quickbooks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'''Main class'''
import xml.etree.ElementTree as ET

import json
import simplejson

try:
from rauth import OAuth1Session, OAuth1Service
Expand Down Expand Up @@ -99,12 +99,7 @@ def __init__(self, **args):

]


def get_authorize_url(self):
"""Returns the Authorize URL as returned by QB,
and specified by OAuth 1.0a.
:return URI:
"""
def set_up_service(self):
self.qbService = OAuth1Service(
name = None,
consumer_key = self.consumer_key,
Expand All @@ -114,10 +109,22 @@ def get_authorize_url(self):
authorize_url = self.authorize_url,
base_url = None
)
self.request_token, self.request_token_secret = self.qbService.get_request_token(

def get_authorize_url(self):
"""Returns the Authorize URL as returned by QB,
and specified by OAuth 1.0a.
:return URI:
"""
if self.qbService is None:
self.set_up_service()

self.request_token, self.request_token_secret = self.qbService \
.get_request_token(
params={'oauth_callback':self.callback_url}
)

print self.request_token, self.request_token_secret

return self.qbService.get_authorize_url(self.request_token)

def get_access_tokens(self, oauth_verifier):
Expand Down Expand Up @@ -292,9 +299,9 @@ def hammer_it(self, request_type, url, request_body = {},
content_type="text", accept = 'json'):
"""
A slim version of simonv3's excellent keep_trying method. Among other
trimmings, it assumes we can only use v3 of the
QBO API. It also allows for requests and responses
in xml OR json. (No xml parsing added yet but the way is paved...)
trimmings, it assumes we can only use v3 of the
QBO API. It also allows for requests and responses
in xml OR json. (No xml parsing added yet but the way is paved...)
"""

if self.session != None:
Expand Down

0 comments on commit e6c6405

Please sign in to comment.