Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 02d17ac

Browse files
authored
Merge pull request ej2#84 from nbhambhani/user_agent
Update user-agent
2 parents 44c5ac3 + f6ab7a0 commit 02d17ac

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

quickbooks/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ def make_request(self, request_type, url, request_body=None, content_type='appli
247247
self.create_session()
248248
headers = {
249249
'Content-Type': content_type,
250-
'Accept': 'application/json'
250+
'Accept': 'application/json',
251+
'User-Agent': 'python-quickbooks V3 library'
251252
}
252253

253254
if file_path:
@@ -257,7 +258,7 @@ def make_request(self, request_type, url, request_body=None, content_type='appli
257258
headers.update({
258259
'Content-Type': 'multipart/form-data; boundary=%s' % boundary,
259260
'Accept-Encoding': 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
260-
'User-Agent': 'OAuth gem v0.4.7',
261+
'User-Agent': 'python-quickbooks V3 library',
261262
'Accept': 'application/json',
262263
'Connection': 'close'
263264
})
@@ -378,6 +379,7 @@ def download_pdf(self, qbbo, item_id):
378379
headers = {
379380
'Content-Type': 'application/pdf',
380381
'Accept': 'application/pdf, application/json',
382+
'User-Agent': 'python-quickbooks V3 library'
381383
}
382384

383385
response = self.session.request("GET", url, True, self.company_id, headers=headers)

tests/unit/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def test_make_request(self, qb_session):
253253

254254
qb_session.request.assert_called_with(
255255
"GET", url, True, "1234", data={},
256-
headers={'Content-Type': 'application/json', 'Accept': 'application/json'}, params={})
256+
headers={'Content-Type': 'application/json', 'Accept': 'application/json', 'User-Agent': 'python-quickbooks V3 library'}, params={})
257257

258258
def test_make_request_create_session(self):
259259
receipt = SalesReceipt()
@@ -298,7 +298,7 @@ def test_download_pdf(self, qb_session):
298298
url = "https://sandbox-quickbooks.api.intuit.com/v3/company/1234/salesreceipt/1/pdf"
299299
qb_session.request.assert_called_with(
300300
"GET", url, True, "1234",
301-
headers={'Content-Type': 'application/pdf', 'Accept': 'application/pdf, application/json'})
301+
headers={'Content-Type': 'application/pdf', 'Accept': 'application/pdf, application/json', 'User-Agent': 'python-quickbooks V3 library'})
302302

303303
qb_session.request.return_value = MockPdfResponse()
304304
response = receipt.download_pdf(qb_client)

0 commit comments

Comments
 (0)