Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Setra Client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
it-bott-integrasjoner
Setra Client
Commits
6e1a87d1
Commit
6e1a87d1
authored
3 years ago
by
rha104
Browse files
Options
Downloads
Patches
Plain Diff
FSHO-19: Added update batch method. And fixed format to match the post_new_batch method
parent
4840bd32
No related branches found
No related tags found
1 merge request
!14
FSHO-19: Added update batch method. And fixed format to match the post_new_batch method
Pipeline
#74967
failed
3 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
setra_client/client.py
+24
-0
24 additions, 0 deletions
setra_client/client.py
with
24 additions
and
0 deletions
setra_client/client.py
+
24
−
0
View file @
6e1a87d1
...
...
@@ -41,6 +41,7 @@ class SetraEndpoints:
transaction_url
=
'
api/transaction/
'
,
voucher_url
=
'
api/voucher/
'
,
new_batch_url
=
'
api/addtrans/
'
,
put_batch_url
=
'
api/addtrans/
'
,
batch_complete_url
=
'
api/batch_complete/
'
,
batch_error_url
=
"
api/batch_error/
"
,
parameters_url
=
"
api/parameters/
"
,
...
...
@@ -50,6 +51,7 @@ class SetraEndpoints:
self
.
transaction_url
=
transaction_url
self
.
voucher_url
=
voucher_url
self
.
new_batch_url
=
new_batch_url
self
.
put_batch_url
=
put_batch_url
self
.
batch_complete_url
=
batch_complete_url
self
.
batch_error_url
=
batch_error_url
self
.
parameters_url
=
parameters_url
...
...
@@ -95,6 +97,9 @@ class SetraEndpoints:
def
post_new_batch
(
self
):
return
urllib
.
parse
.
urljoin
(
self
.
baseurl
,
self
.
new_batch_url
)
def
put_update_batch
(
self
):
return
urllib
.
parse
.
urljoin
(
self
.
baseurl
,
self
.
new_batch_url
)
def
batch_complete
(
self
,
batch_id
:
str
):
"""
URL for Batch endpoint
...
...
@@ -269,6 +274,25 @@ class SetraClient(object):
response
.
raise_for_status
()
return
response
def
put_update_batch
(
self
,
batchdata
:
Batch
):
"""
PUT updates an existing batch with vouchers and transactions,
if the batch exists in setra, and has status=created, or validation failed.
Returns 404 if no batch was found, 202 for successful update, or 409 if batch was found, but
did not meet the status criteria mentioned above.
"""
url
=
self
.
urls
.
put_update_batch
()
headers
=
{
'
Content-Type
'
:
'
application/json
'
}
response
=
self
.
put
(
url
,
data
=
batchdata
.
json
(),
headers
=
headers
,
return_response
=
True
)
if
response
.
status_code
in
(
409
,
202
):
return
'
OK
'
else
:
response
.
raise_for_status
()
return
response
def
get_batch_complete
(
self
,
batch_id
:
str
):
"""
GETs complete batch (with vouchers and transactions)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment