-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for BillingAccount and Usage (#80)
Adding support for BillingAccount and Usage (#80)
- Loading branch information
1 parent
f7ca0b0
commit 617e411
Showing
4 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from collections import OrderedDict | ||
|
||
from .base import ApiBase | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class BillingAccount(ApiBase): | ||
SIMPLE_FIELDS = [ | ||
'createdBy', | ||
'createdDate', | ||
'customFieldList', | ||
'customerDefault', | ||
'frequency', | ||
'idNumber', | ||
'inactive', | ||
'lastBillCycleDate', | ||
'lastBillDate', | ||
'memo', | ||
'name', | ||
'nextBillCycleDate', | ||
'startDate', | ||
'nullFieldList', | ||
] | ||
|
||
RECORD_REF_FIELDS = [ | ||
'billingSchedule', | ||
'cashSaleForm', | ||
'class', | ||
'currency', | ||
'customForm', | ||
'customer', | ||
'department', | ||
'invoiceForm', | ||
'location', | ||
'subsidiary', | ||
] | ||
|
||
def __init__(self, ns_client): | ||
ApiBase.__init__(self, ns_client=ns_client, type_name='BillingAccount') | ||
|
||
def post(self, data) -> OrderedDict: | ||
assert data['externalId'], 'missing external id' | ||
billing_account = self.ns_client.BillingAccount(**data) | ||
|
||
self.build_simple_fields(self.SIMPLE_FIELDS, data, billing_account) | ||
|
||
self.build_record_ref_fields(self.RECORD_REF_FIELDS, data, billing_account) | ||
|
||
logger.debug('able to create billing account = %s', billing_account) | ||
|
||
res = self.ns_client.upsert(billing_account) | ||
return self._serialize(res) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from collections import OrderedDict | ||
|
||
from .base import ApiBase | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Usage(ApiBase): | ||
SIMPLE_FIELDS = [ | ||
'memo', | ||
'usageDate', | ||
'usageQuantity', | ||
'nullFieldList', | ||
] | ||
|
||
RECORD_REF_FIELDS = [ | ||
'customForm', | ||
'customer', | ||
'item', | ||
'subscriptionPlan', | ||
'usageSubscription', | ||
'usageSubscriptionLine', | ||
] | ||
|
||
def __init__(self, ns_client): | ||
ApiBase.__init__(self, ns_client=ns_client, type_name='Usage') | ||
|
||
def post(self, data) -> OrderedDict: | ||
assert data['externalId'], 'missing external id' | ||
usage = self.ns_client.Usage(**data) | ||
|
||
self.build_simple_fields(self.SIMPLE_FIELDS, data, usage) | ||
|
||
self.build_record_ref_fields(self.RECORD_REF_FIELDS, data, usage) | ||
|
||
logger.debug('able to create usage = %s', usage) | ||
|
||
res = self.ns_client.upsert(usage) | ||
return self._serialize(res) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters