UNPKG

@apideck/node

Version:
1,362 lines (1,332 loc) 1.66 MB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } var fetch$1 = _interopDefault(require('node-fetch-commonjs')); var stream = require('stream'); /* tslint:disable */ /* eslint-disable */ /** * Apideck * The Apideck OpenAPI Spec: SDK Optimized * * The version of the OpenAPI document: 10.13.0 * Contact: support@apideck.com * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ const BASE_PATH = /*#__PURE__*/'https://unify.apideck.com'.replace(/\/+$/, ''); const isBlob = value => typeof Blob !== 'undefined' && value instanceof Blob; /** * This is the base class for all generated API classes. */ class BaseAPI { constructor(configuration = new Configuration()) { this.configuration = configuration; this.fetchApi = async (url, init) => { let fetchParams = { url, init }; for (const middleware of this.middleware) { if (middleware.pre) { fetchParams = (await middleware.pre({ fetch: this.fetchApi, ...fetchParams })) || fetchParams; } } let response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init); for (const middleware of this.middleware) { if (middleware.post) { response = (await middleware.post({ fetch: this.fetchApi, url: fetchParams.url, init: fetchParams.init, response: response.clone() })) || response; } } return response; }; this.middleware = configuration.middleware; } withMiddleware(...middlewares) { const next = this.clone(); next.middleware = next.middleware.concat(...middlewares); return next; } withPreMiddleware(...preMiddlewares) { const middlewares = preMiddlewares.map(pre => ({ pre })); return this.withMiddleware(...middlewares); } withPostMiddleware(...postMiddlewares) { const middlewares = postMiddlewares.map(post => ({ post })); return this.withMiddleware(...middlewares); } async request(context, initOverrides) { const { url, init } = this.createFetchParams(context, initOverrides); const response = await this.fetchApi(url, init); if (response.status >= 200 && response.status < 300) { return response; } throw response; } createFetchParams(context, initOverrides) { let url = this.configuration.basePath + context.path; if (context.query !== undefined && Object.keys(context.query).length !== 0) { // only add the querystring to the URL if there are query parameters. // this is done to avoid urls ending with a "?" character which buggy webservers // do not handle correctly sometimes. url += '?' + this.configuration.queryParamsStringify(context.query); } const body = typeof FormData !== 'undefined' && context.body instanceof FormData || context.body instanceof URLSearchParams || isBlob(context.body) ? context.body : JSON.stringify(context.body); const headers = Object.assign({}, this.configuration.headers, context.headers); const init = { method: context.method, headers: headers, body, credentials: this.configuration.credentials, ...initOverrides }; return { url, init }; } /** * Create a shallow clone of `this` by constructing a new instance * and then shallow cloning data members. */ clone() { const constructor = this.constructor; const next = new constructor(this.configuration); next.middleware = this.middleware.slice(); return next; } } class RequiredError extends Error { constructor(field, msg) { super(msg); this.field = field; this.name = 'RequiredError'; } } const COLLECTION_FORMATS = { csv: ',', ssv: ' ', tsv: '\t', pipes: '|' }; class Configuration { constructor(configuration = {}) { this.configuration = configuration; } get basePath() { return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH; } get fetchApi() { return this.configuration.fetchApi; } get middleware() { return this.configuration.middleware || []; } get queryParamsStringify() { return this.configuration.queryParamsStringify || querystring; } get username() { return this.configuration.username; } get password() { return this.configuration.password; } get apiKey() { const apiKey = this.configuration.apiKey; if (apiKey) { return typeof apiKey === 'function' ? apiKey : () => apiKey; } return undefined; } get accessToken() { const accessToken = this.configuration.accessToken; if (accessToken) { return typeof accessToken === 'function' ? accessToken : async () => accessToken; } return undefined; } get headers() { return this.configuration.headers; } get credentials() { return this.configuration.credentials; } } function exists(json, key) { const value = json[key]; return value !== null && value !== undefined; } function querystring(params, prefix = '') { return Object.keys(params).map(key => { const fullKey = prefix + (prefix.length ? `[${key}]` : key); const value = params[key]; if (value instanceof Array) { const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`); return `${encodeURIComponent(fullKey)}=${multiValue}`; } if (value instanceof Date) { return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`; } if (value instanceof Object) { return querystring(value, fullKey); } return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; }).filter(part => part.length > 0).join('&'); } function mapValues(data, fn) { return Object.keys(data).reduce((acc, key) => ({ ...acc, [key]: fn(data[key]) }), {}); } function canConsumeForm(consumes) { for (const consume of consumes) { if ('multipart/form-data' === consume.contentType) { return true; } } return false; } class JSONApiResponse { constructor(raw, transformer = jsonValue => jsonValue) { this.raw = raw; this.transformer = transformer; } async value() { return this.transformer(await this.raw.json()); } } class VoidApiResponse { constructor(raw) { this.raw = raw; } async value() { return undefined; } } class BlobApiResponse { constructor(raw) { this.raw = raw; } async value() { return await this.raw.blob(); } } class TextApiResponse { constructor(raw) { this.raw = raw; } async value() { return await this.raw.text(); } } function PassThroughBodyFromJSON(json) { return PassThroughBodyFromJSONTyped(json); } function PassThroughBodyFromJSONTyped(json, ignoreDiscriminator) { return json; } function PassThroughBodyToJSON(value) { return value; } /* tslint:disable */ function SubsidiaryReferenceFromJSON(json) { return SubsidiaryReferenceFromJSONTyped(json); } function SubsidiaryReferenceFromJSONTyped(json, ignoreDiscriminator) { if (json === undefined || json === null) { return json; } return { id: !exists(json, 'id') ? undefined : json['id'], name: !exists(json, 'name') ? undefined : json['name'] }; } function SubsidiaryReferenceToJSON(value) { if (value === undefined) { return undefined; } if (value === null) { return null; } return { name: value.name }; } /* tslint:disable */ (function (AccountingDepartmentStatus) { AccountingDepartmentStatus["active"] = "active"; AccountingDepartmentStatus["inactive"] = "inactive"; })(exports.AccountingDepartmentStatus || (exports.AccountingDepartmentStatus = {})); function AccountingDepartmentFromJSON(json) { return AccountingDepartmentFromJSONTyped(json); } function AccountingDepartmentFromJSONTyped(json, ignoreDiscriminator) { if (json === undefined || json === null) { return json; } return { id: !exists(json, 'id') ? undefined : json['id'], parent_id: !exists(json, 'parent_id') ? undefined : json['parent_id'], name: !exists(json, 'name') ? undefined : json['name'], status: !exists(json, 'status') ? undefined : json['status'], subsidiaries: !exists(json, 'subsidiaries') ? undefined : json['subsidiaries'].map(SubsidiaryReferenceFromJSON), custom_mappings: !exists(json, 'custom_mappings') ? undefined : json['custom_mappings'], row_version: !exists(json, 'row_version') ? undefined : json['row_version'], updated_by: !exists(json, 'updated_by') ? undefined : json['updated_by'], created_by: !exists(json, 'created_by') ? undefined : json['created_by'], updated_at: !exists(json, 'updated_at') ? undefined : json['updated_at'] === null ? null : new Date(json['updated_at']), created_at: !exists(json, 'created_at') ? undefined : json['created_at'] === null ? null : new Date(json['created_at']), pass_through: !exists(json, 'pass_through') ? undefined : PassThroughBodyFromJSON(json['pass_through']) }; } function AccountingDepartmentToJSON(value) { if (value === undefined) { return undefined; } if (value === null) { return null; } return { parent_id: value.parent_id, name: value.name, status: value.status, subsidiaries: value.subsidiaries === undefined ? undefined : value.subsidiaries.map(SubsidiaryReferenceToJSON), row_version: value.row_version, pass_through: PassThroughBodyToJSON(value.pass_through) }; } /* tslint:disable */ function AccountingDepartmentsFilterFromJSON(json) { return AccountingDepartmentsFilterFromJSONTyped(json); } function AccountingDepartmentsFilterFromJSONTyped(json, ignoreDiscriminator) { if (json === undefined || json === null) { return json; } return { subsidiary: !exists(json, 'subsidiary') ? undefined : json['subsidiary'] }; } function AccountingDepartmentsFilterToJSON(value) { if (value === undefined) { return undefined; } if (value === null) { return null; } return { subsidiary: value.subsidiary }; } /* tslint:disable */ (function (AccountingEventType) { AccountingEventType["Star"] = "*"; AccountingEventType["accounting_customer_created"] = "accounting.customer.created"; AccountingEventType["accounting_customer_updated"] = "accounting.customer.updated"; AccountingEventType["accounting_customer_deleted"] = "accounting.customer.deleted"; AccountingEventType["accounting_invoice_created"] = "accounting.invoice.created"; AccountingEventType["accounting_invoice_updated"] = "accounting.invoice.updated"; AccountingEventType["accounting_invoice_deleted"] = "accounting.invoice.deleted"; AccountingEventType["accounting_invoice_item_created"] = "accounting.invoice_item.created"; AccountingEventType["accounting_invoice_item_updated"] = "accounting.invoice_item.updated"; AccountingEventType["accounting_invoice_item_deleted"] = "accounting.invoice_item.deleted"; AccountingEventType["accounting_ledger_account_created"] = "accounting.ledger_account.created"; AccountingEventType["accounting_ledger_account_updated"] = "accounting.ledger_account.updated"; AccountingEventType["accounting_ledger_account_deleted"] = "accounting.ledger_account.deleted"; AccountingEventType["accounting_tax_rate_created"] = "accounting.tax_rate.created"; AccountingEventType["accounting_tax_rate_updated"] = "accounting.tax_rate.updated"; AccountingEventType["accounting_tax_rate_deleted"] = "accounting.tax_rate.deleted"; AccountingEventType["accounting_bill_created"] = "accounting.bill.created"; AccountingEventType["accounting_bill_updated"] = "accounting.bill.updated"; AccountingEventType["accounting_bill_deleted"] = "accounting.bill.deleted"; AccountingEventType["accounting_payment_created"] = "accounting.payment.created"; AccountingEventType["accounting_payment_updated"] = "accounting.payment.updated"; AccountingEventType["accounting_payment_deleted"] = "accounting.payment.deleted"; AccountingEventType["accounting_supplier_created"] = "accounting.supplier.created"; AccountingEventType["accounting_supplier_updated"] = "accounting.supplier.updated"; AccountingEventType["accounting_supplier_deleted"] = "accounting.supplier.deleted"; AccountingEventType["accounting_purchase_order_created"] = "accounting.purchase_order.created"; AccountingEventType["accounting_purchase_order_updated"] = "accounting.purchase_order.updated"; AccountingEventType["accounting_purchase_order_deleted"] = "accounting.purchase_order.deleted"; AccountingEventType["accounting_expense_created"] = "accounting.expense.created"; AccountingEventType["accounting_expense_updated"] = "accounting.expense.updated"; AccountingEventType["accounting_expense_deleted"] = "accounting.expense.deleted"; AccountingEventType["accounting_credit_note_created"] = "accounting.credit_note.created"; AccountingEventType["accounting_credit_note_updated"] = "accounting.credit_note.updated"; AccountingEventType["accounting_credit_note_deleted"] = "accounting.credit_note.deleted"; })(exports.AccountingEventType || (exports.AccountingEventType = {})); function AccountingEventTypeFromJSON(json) { return AccountingEventTypeFromJSONTyped(json); } function AccountingEventTypeFromJSONTyped(json, ignoreDiscriminator) { return json; } function AccountingEventTypeToJSON(value) { return value; } /* tslint:disable */ (function (AddressType) { AddressType["primary"] = "primary"; AddressType["secondary"] = "secondary"; AddressType["home"] = "home"; AddressType["office"] = "office"; AddressType["shipping"] = "shipping"; AddressType["billing"] = "billing"; AddressType["other"] = "other"; })(exports.AddressType || (exports.AddressType = {})); function AddressFromJSON(json) { return AddressFromJSONTyped(json); } function AddressFromJSONTyped(json, ignoreDiscriminator) { if (json === undefined || json === null) { return json; } return { id: !exists(json, 'id') ? undefined : json['id'], type: !exists(json, 'type') ? undefined : json['type'], string: !exists(json, 'string') ? undefined : json['string'], name: !exists(json, 'name') ? undefined : json['name'], line1: !exists(json, 'line1') ? undefined : json['line1'], line2: !exists(json, 'line2') ? undefined : json['line2'], line3: !exists(json, 'line3') ? undefined : json['line3'], line4: !exists(json, 'line4') ? undefined : json['line4'], street_number: !exists(json, 'street_number') ? undefined : json['street_number'], city: !exists(json, 'city') ? undefined : json['city'], state: !exists(json, 'state') ? undefined : json['state'], postal_code: !exists(json, 'postal_code') ? undefined : json['postal_code'], country: !exists(json, 'country') ? undefined : json['country'], latitude: !exists(json, 'latitude') ? undefined : json['latitude'], longitude: !exists(json, 'longitude') ? undefined : json['longitude'], county: !exists(json, 'county') ? undefined : json['county'], contact_name: !exists(json, 'contact_name') ? undefined : json['contact_name'], salutation: !exists(json, 'salutation') ? undefined : json['salutation'], phone_number: !exists(json, 'phone_number') ? undefined : json['phone_number'], fax: !exists(json, 'fax') ? undefined : json['fax'], email: !exists(json, 'email') ? undefined : json['email'], website: !exists(json, 'website') ? undefined : json['website'], notes: !exists(json, 'notes') ? undefined : json['notes'], row_version: !exists(json, 'row_version') ? undefined : json['row_version'] }; } function AddressToJSON(value) { if (value === undefined) { return undefined; } if (value === null) { return null; } return { id: value.id, type: value.type, string: value.string, name: value.name, line1: value.line1, line2: value.line2, line3: value.line3, line4: value.line4, street_number: value.street_number, city: value.city, state: value.state, postal_code: value.postal_code, country: value.country, latitude: value.latitude, longitude: value.longitude, county: value.county, contact_name: value.contact_name, salutation: value.salutation, phone_number: value.phone_number, fax: value.fax, email: value.email, website: value.website, notes: value.notes, row_version: value.row_version }; } /* tslint:disable */ (function (AccountingLocationStatus) { AccountingLocationStatus["active"] = "active"; AccountingLocationStatus["inactive"] = "inactive"; })(exports.AccountingLocationStatus || (exports.AccountingLocationStatus = {})); function AccountingLocationFromJSON(json) { return AccountingLocationFromJSONTyped(json); } function AccountingLocationFromJSONTyped(json, ignoreDiscriminator) { if (json === undefined || json === null) { return json; } return { id: !exists(json, 'id') ? undefined : json['id'], parent_id: !exists(json, 'parent_id') ? undefined : json['parent_id'], company_name: !exists(json, 'company_name') ? undefined : json['company_name'], display_name: !exists(json, 'display_name') ? undefined : json['display_name'], status: !exists(json, 'status') ? undefined : json['status'], addresses: !exists(json, 'addresses') ? undefined : json['addresses'].map(AddressFromJSON), subsidiaries: !exists(json, 'subsidiaries') ? undefined : json['subsidiaries'].map(SubsidiaryReferenceFromJSON), custom_mappings: !exists(json, 'custom_mappings') ? undefined : json['custom_mappings'], row_version: !exists(json, 'row_version') ? undefined : json['row_version'], updated_by: !exists(json, 'updated_by') ? undefined : json['updated_by'], created_by: !exists(json, 'created_by') ? undefined : json['created_by'], updated_at: !exists(json, 'updated_at') ? undefined : json['updated_at'] === null ? null : new Date(json['updated_at']), created_at: !exists(json, 'created_at') ? undefined : json['created_at'] === null ? null : new Date(json['created_at']), pass_through: !exists(json, 'pass_through') ? undefined : PassThroughBodyFromJSON(json['pass_through']) }; } function AccountingLocationToJSON(value) { if (value === undefined) { return undefined; } if (value === null) { return null; } return { parent_id: value.parent_id, company_name: value.company_name, display_name: value.display_name, status: value.status, addresses: value.addresses === undefined ? undefined : value.addresses.map(AddressToJSON), subsidiaries: value.subsidiaries === undefined ? undefined : value.subsidiaries.map(SubsidiaryReferenceToJSON), row_version: value.row_version, pass_through: PassThroughBodyToJSON(value.pass_through) }; } /* tslint:disable */ function AccountingLocationsFilterFromJSON(json) { return AccountingLocationsFilterFromJSONTyped(json); } function AccountingLocationsFilterFromJSONTyped(json, ignoreDiscriminator) { if (json === undefined || json === null) { return json; } return { subsidiary: !exists(json, 'subsidiary') ? undefined : json['subsidiary'] }; } function AccountingLocationsFilterToJSON(value) { if (value === undefined) { return undefined; } if (value === null) { return null; } return { subsidiary: value.subsidiary }; } /* tslint:disable */ function ActivitiesFilterFromJSON(json) { return ActivitiesFilterFromJSONTyped(json); } function ActivitiesFilterFromJSONTyped(json, ignoreDiscriminator) { if (json === undefined || json === null) { return json; } return { company_id: !exists(json, 'company_id') ? undefined : json['company_id'], owner_id: !exists(json, 'owner_id') ? undefined : json['owner_id'], contact_id: !exists(json, 'contact_id') ? undefined : json['contact_id'], updated_since: !exists(json, 'updated_since') ? undefined : new Date(json['updated_since']), type: !exists(json, 'type') ? undefined : json['type'] }; } function ActivitiesFilterToJSON(value) { if (value === undefined) { return undefined; } if (value === null) { return null; } return { company_id: value.company_id, owner_id: value.owner_id, contact_id: value.contact_id, updated_since: value.updated_since === undefined ? undefined : new Date(value.updated_since).toISOString(), type: value.type }; } /* tslint:disable */ (function (SortDirection) { SortDirection["asc"] = "asc"; SortDirection["desc"] = "desc"; })(exports.SortDirection || (exports.SortDirection = {})); function SortDirectionFromJSON(json) { return SortDirectionFromJSONTyped(json); } function SortDirectionFromJSONTyped(json, ignoreDiscriminator) { return json; } function SortDirectionToJSON(value) { return value; } /* tslint:disable */ (function (ActivitiesSortBy) { ActivitiesSortBy["created_at"] = "created_at"; ActivitiesSortBy["updated_at"] = "updated_at"; })(exports.ActivitiesSortBy || (exports.ActivitiesSortBy = {})); function ActivitiesSortFromJSON(json) { return ActivitiesSortFromJSONTyped(json); } function ActivitiesSortFromJSONTyped(json, ignoreDiscriminator) { if (json === undefined || json === null) { return json; } return { by: !exists(json, 'by') ? undefined : json['by'], direction: !exists(json, 'direction') ? undefined : SortDirectionFromJSON(json['direction']) }; } function ActivitiesSortToJSON(value) { if (value === undefined) { return undefined; } if (value === null) { return null; } return { by: value.by, direction: SortDirectionToJSON(value.direction) }; } /* tslint:disable */ (function (ActivityAttendeeStatus) { ActivityAttendeeStatus["accepted"] = "accepted"; ActivityAttendeeStatus["tentative"] = "tentative"; ActivityAttendeeStatus["declined"] = "declined"; })(exports.ActivityAttendeeStatus || (exports.ActivityAttendeeStatus = {})); function ActivityAttendeeFromJSON(json) { return ActivityAttendeeFromJSONTyped(json); } function ActivityAttendeeFromJSONTyped(json, ignoreDiscriminator) { if (json === undefined || json === null) { return json; } return { id: !exists(json, 'id') ? undefined : json['id'], name: !exists(json, 'name') ? undefined : json['name'], first_name: !exists(json, 'first_name') ? undefined : json['first_name'], middle_name: !exists(json, 'middle_name') ? undefined : json['middle_name'], last_name: !exists(json, 'last_name') ? undefined : json['last_name'], prefix: !exists(json, 'prefix') ? undefined : json['prefix'], suffix: !exists(json, 'suffix') ? undefined : json['suffix'], email_address: !exists(json, 'email_address') ? undefined : json['email_address'], is_organizer: !exists(json, 'is_organizer') ? undefined : json['is_organizer'], status: !exists(json, 'status') ? undefined : json['status'], user_id: !exists(json, 'user_id') ? undefined : json['user_id'], contact_id: !exists(json, 'contact_id') ? undefined : json['contact_id'], updated_at: !exists(json, 'updated_at') ? undefined : json['updated_at'] === null ? null : new Date(json['updated_at']), created_at: !exists(json, 'created_at') ? undefined : json['created_at'] === null ? null : new Date(json['created_at']) }; } function ActivityAttendeeToJSON(value) { if (value === undefined) { return undefined; } if (value === null) { return null; } return { name: value.name, first_name: value.first_name, middle_name: value.middle_name, last_name: value.last_name, prefix: value.prefix, suffix: value.suffix, email_address: value.email_address, is_organizer: value.is_organizer, status: value.status }; } /* tslint:disable */ function CustomFieldFromJSON(json) { return CustomFieldFromJSONTyped(json); } function CustomFieldFromJSONTyped(json, ignoreDiscriminator) { if (json === undefined || json === null) { return json; } return { id: json['id'], name: !exists(json, 'name') ? undefined : json['name'], description: !exists(json, 'description') ? undefined : json['description'], value: !exists(json, 'value') ? undefined : json['value'] }; } function CustomFieldToJSON(value) { if (value === undefined) { return undefined; } if (value === null) { return null; } return { id: value.id, name: value.name, description: value.description, value: value.value }; } /* tslint:disable */ (function (ActivityType) { ActivityType["call"] = "call"; ActivityType["meeting"] = "meeting"; ActivityType["email"] = "email"; ActivityType["note"] = "note"; ActivityType["task"] = "task"; ActivityType["deadline"] = "deadline"; ActivityType["send_letter"] = "send-letter"; ActivityType["send_quote"] = "send-quote"; ActivityType["other"] = "other"; })(exports.ActivityType || (exports.ActivityType = {})); (function (ActivityShowAs) { ActivityShowAs["free"] = "free"; ActivityShowAs["busy"] = "busy"; })(exports.ActivityShowAs || (exports.ActivityShowAs = {})); function ActivityFromJSON(json) { return ActivityFromJSONTyped(json); } function ActivityFromJSONTyped(json, ignoreDiscriminator) { if (json === undefined || json === null) { return json; } return { type: json['type'], id: !exists(json, 'id') ? undefined : json['id'], downstream_id: !exists(json, 'downstream_id') ? undefined : json['downstream_id'], activity_datetime: !exists(json, 'activity_datetime') ? undefined : json['activity_datetime'], duration_seconds: !exists(json, 'duration_seconds') ? undefined : json['duration_seconds'], user_id: !exists(json, 'user_id') ? undefined : json['user_id'], account_id: !exists(json, 'account_id') ? undefined : json['account_id'], contact_id: !exists(json, 'contact_id') ? undefined : json['contact_id'], company_id: !exists(json, 'company_id') ? undefined : json['company_id'], opportunity_id: !exists(json, 'opportunity_id') ? undefined : json['opportunity_id'], lead_id: !exists(json, 'lead_id') ? undefined : json['lead_id'], owner_id: !exists(json, 'owner_id') ? undefined : json['owner_id'], campaign_id: !exists(json, 'campaign_id') ? undefined : json['campaign_id'], case_id: !exists(json, 'case_id') ? undefined : json['case_id'], asset_id: !exists(json, 'asset_id') ? undefined : json['asset_id'], contract_id: !exists(json, 'contract_id') ? undefined : json['contract_id'], product_id: !exists(json, 'product_id') ? undefined : json['product_id'], solution_id: !exists(json, 'solution_id') ? undefined : json['solution_id'], custom_object_id: !exists(json, 'custom_object_id') ? undefined : json['custom_object_id'], title: !exists(json, 'title') ? undefined : json['title'], description: !exists(json, 'description') ? undefined : json['description'], note: !exists(json, 'note') ? undefined : json['note'], location: !exists(json, 'location') ? undefined : json['location'], location_address: !exists(json, 'location_address') ? undefined : AddressFromJSON(json['location_address']), all_day_event: !exists(json, 'all_day_event') ? undefined : json['all_day_event'], _private: !exists(json, 'private') ? undefined : json['private'], group_event: !exists(json, 'group_event') ? undefined : json['group_event'], event_sub_type: !exists(json, 'event_sub_type') ? undefined : json['event_sub_type'], group_event_type: !exists(json, 'group_event_type') ? undefined : json['group_event_type'], child: !exists(json, 'child') ? undefined : json['child'], archived: !exists(json, 'archived') ? undefined : json['archived'], deleted: !exists(json, 'deleted') ? undefined : json['deleted'], show_as: !exists(json, 'show_as') ? undefined : json['show_as'], done: !exists(json, 'done') ? undefined : json['done'], start_datetime: !exists(json, 'start_datetime') ? undefined : json['start_datetime'], end_datetime: !exists(json, 'end_datetime') ? undefined : json['end_datetime'], duration_minutes: !exists(json, 'duration_minutes') ? undefined : json['duration_minutes'], activity_date: !exists(json, 'activity_date') ? undefined : json['activity_date'], end_date: !exists(json, 'end_date') ? undefined : json['end_date'], recurrent: !exists(json, 'recurrent') ? undefined : json['recurrent'], reminder_datetime: !exists(json, 'reminder_datetime') ? undefined : json['reminder_datetime'], reminder_set: !exists(json, 'reminder_set') ? undefined : json['reminder_set'], video_conference_url: !exists(json, 'video_conference_url') ? undefined : json['video_conference_url'], video_conference_id: !exists(json, 'video_conference_id') ? undefined : json['video_conference_id'], custom_fields: !exists(json, 'custom_fields') ? undefined : json['custom_fields'].map(CustomFieldFromJSON), attendees: !exists(json, 'attendees') ? undefined : json['attendees'].map(ActivityAttendeeFromJSON), custom_mappings: !exists(json, 'custom_mappings') ? undefined : json['custom_mappings'], updated_by: !exists(json, 'updated_by') ? undefined : json['updated_by'], created_by: !exists(json, 'created_by') ? undefined : json['created_by'], updated_at: !exists(json, 'updated_at') ? undefined : json['updated_at'], created_at: !exists(json, 'created_at') ? undefined : json['created_at'], pass_through: !exists(json, 'pass_through') ? undefined : PassThroughBodyFromJSON(json['pass_through']) }; } function ActivityToJSON(value) { if (value === undefined) { return undefined; } if (value === null) { return null; } return { type: value.type, activity_datetime: value.activity_datetime, duration_seconds: value.duration_seconds, user_id: value.user_id, account_id: value.account_id, contact_id: value.contact_id, company_id: value.company_id, opportunity_id: value.opportunity_id, lead_id: value.lead_id, owner_id: value.owner_id, campaign_id: value.campaign_id, case_id: value.case_id, asset_id: value.asset_id, contract_id: value.contract_id, product_id: value.product_id, solution_id: value.solution_id, custom_object_id: value.custom_object_id, title: value.title, description: value.description, note: value.note, location: value.location, location_address: AddressToJSON(value.location_address), all_day_event: value.all_day_event, private: value._private, group_event: value.group_event, event_sub_type: value.event_sub_type, group_event_type: value.group_event_type, child: value.child, archived: value.archived, deleted: value.deleted, show_as: value.show_as, done: value.done, start_datetime: value.start_datetime, end_datetime: value.end_datetime, activity_date: value.activity_date, end_date: value.end_date, recurrent: value.recurrent, reminder_datetime: value.reminder_datetime, reminder_set: value.reminder_set, video_conference_url: value.video_conference_url, video_conference_id: value.video_conference_id, custom_fields: value.custom_fields === undefined ? undefined : value.custom_fields.map(CustomFieldToJSON), attendees: value.attendees === undefined ? undefined : value.attendees.map(ActivityAttendeeToJSON), pass_through: PassThroughBodyToJSON(value.pass_through) }; } /* tslint:disable */ (function (BalanceByTransactionTransactionType) { BalanceByTransactionTransactionType["invoice"] = "invoice"; BalanceByTransactionTransactionType["credit_note"] = "credit_note"; BalanceByTransactionTransactionType["bill"] = "bill"; BalanceByTransactionTransactionType["payment"] = "payment"; BalanceByTransactionTransactionType["bill_payment"] = "bill_payment"; })(exports.BalanceByTransactionTransactionType || (exports.BalanceByTransactionTransactionType = {})); function BalanceByTransactionFromJSON(json) { return BalanceByTransactionFromJSONTyped(json); } function BalanceByTransactionFromJSONTyped(json, ignoreDiscriminator) { if (json === undefined || json === null) { return json; } return { transaction_id: !exists(json, 'transaction_id') ? undefined : json['transaction_id'], transaction_date: !exists(json, 'transaction_date') ? undefined : new Date(json['transaction_date']), transaction_type: !exists(json, 'transaction_type') ? undefined : json['transaction_type'], due_date: !exists(json, 'due_date') ? undefined : new Date(json['due_date']), original_amount: !exists(json, 'original_amount') ? undefined : json['original_amount'], outstanding_balance: !exists(json, 'outstanding_balance') ? undefined : json['outstanding_balance'], transaction_number: !exists(json, 'transaction_number') ? undefined : json['transaction_number'] }; } function BalanceByTransactionToJSON(value) { if (value === undefined) { return undefined; } if (value === null) { return null; } return { transaction_id: value.transaction_id, transaction_date: value.transaction_date === undefined ? undefined : new Date(value.transaction_date).toISOString().substr(0, 10), transaction_type: value.transaction_type, due_date: value.due_date === undefined ? undefined : new Date(value.due_date).toISOString().substr(0, 10), original_amount: value.original_amount, outstanding_balance: value.outstanding_balance, transaction_number: value.transaction_number }; } /* tslint:disable */ function BalanceByPeriodFromJSON(json) { return BalanceByPeriodFromJSONTyped(json); } function BalanceByPeriodFromJSONTyped(json, ignoreDiscriminator) { if (json === undefined || json === null) { return json; } return { start_date: !exists(json, 'start_date') ? undefined : json['start_date'] === null ? null : new Date(json['start_date']), end_date: !exists(json, 'end_date') ? undefined : json['end_date'] === null ? null : new Date(json['end_date']), total_amount: !exists(json, 'total_amount') ? undefined : json['total_amount'], balances_by_transaction: !exists(json, 'balances_by_transaction') ? undefined : json['balances_by_transaction'].map(BalanceByTransactionFromJSON) }; } function BalanceByPeriodToJSON(value) { if (value === undefined) { return undefined; } if (value === null) { return null; } return { start_date: value.start_date === undefined ? undefined : value.start_date === null ? null : new Date(value.start_date).toISOString().substr(0, 10), end_date: value.end_date === undefined ? undefined : value.end_date === null ? null : new Date(value.end_date).toISOString().substr(0, 10), total_amount: value.total_amount, balances_by_transaction: value.balances_by_transaction === undefined ? undefined : value.balances_by_transaction.map(BalanceByTransactionToJSON) }; } /* tslint:disable */ (function (Currency) { Currency["UNKNOWN_CURRENCY"] = "UNKNOWN_CURRENCY"; Currency["AED"] = "AED"; Currency["AFN"] = "AFN"; Currency["ALL"] = "ALL"; Currency["AMD"] = "AMD"; Currency["ANG"] = "ANG"; Currency["AOA"] = "AOA"; Currency["ARS"] = "ARS"; Currency["AUD"] = "AUD"; Currency["AWG"] = "AWG"; Currency["AZN"] = "AZN"; Currency["BAM"] = "BAM"; Currency["BBD"] = "BBD"; Currency["BDT"] = "BDT"; Currency["BGN"] = "BGN"; Currency["BHD"] = "BHD"; Currency["BIF"] = "BIF"; Currency["BMD"] = "BMD"; Currency["BND"] = "BND"; Currency["BOB"] = "BOB"; Currency["BOV"] = "BOV"; Currency["BRL"] = "BRL"; Currency["BSD"] = "BSD"; Currency["BTN"] = "BTN"; Currency["BWP"] = "BWP"; Currency["BYR"] = "BYR"; Currency["BZD"] = "BZD"; Currency["CAD"] = "CAD"; Currency["CDF"] = "CDF"; Currency["CHE"] = "CHE"; Currency["CHF"] = "CHF"; Currency["CHW"] = "CHW"; Currency["CLF"] = "CLF"; Currency["CLP"] = "CLP"; Currency["CNY"] = "CNY"; Currency["COP"] = "COP"; Currency["COU"] = "COU"; Currency["CRC"] = "CRC"; Currency["CUC"] = "CUC"; Currency["CUP"] = "CUP"; Currency["CVE"] = "CVE"; Currency["CZK"] = "CZK"; Currency["DJF"] = "DJF"; Currency["DKK"] = "DKK"; Currency["DOP"] = "DOP"; Currency["DZD"] = "DZD"; Currency["EGP"] = "EGP"; Currency["ERN"] = "ERN"; Currency["ETB"] = "ETB"; Currency["EUR"] = "EUR"; Currency["FJD"] = "FJD"; Currency["FKP"] = "FKP"; Currency["GBP"] = "GBP"; Currency["GEL"] = "GEL"; Currency["GHS"] = "GHS"; Currency["GIP"] = "GIP"; Currency["GMD"] = "GMD"; Currency["GNF"] = "GNF"; Currency["GTQ"] = "GTQ"; Currency["GYD"] = "GYD"; Currency["HKD"] = "HKD"; Currency["HNL"] = "HNL"; Currency["HRK"] = "HRK"; Currency["HTG"] = "HTG"; Currency["HUF"] = "HUF"; Currency["IDR"] = "IDR"; Currency["ILS"] = "ILS"; Currency["INR"] = "INR"; Currency["IQD"] = "IQD"; Currency["IRR"] = "IRR"; Currency["ISK"] = "ISK"; Currency["JMD"] = "JMD"; Currency["JOD"] = "JOD"; Currency["JPY"] = "JPY"; Currency["KES"] = "KES"; Currency["KGS"] = "KGS"; Currency["KHR"] = "KHR"; Currency["KMF"] = "KMF"; Currency["KPW"] = "KPW"; Currency["KRW"] = "KRW"; Currency["KWD"] = "KWD"; Currency["KYD"] = "KYD"; Currency["KZT"] = "KZT"; Currency["LAK"] = "LAK"; Currency["LBP"] = "LBP"; Currency["LKR"] = "LKR"; Currency["LRD"] = "LRD"; Currency["LSL"] = "LSL"; Currency["LTL"] = "LTL"; Currency["LVL"] = "LVL"; Currency["LYD"] = "LYD"; Currency["MAD"] = "MAD"; Currency["MDL"] = "MDL"; Currency["MGA"] = "MGA"; Currency["MKD"] = "MKD"; Currency["MMK"] = "MMK"; Currency["MNT"] = "MNT"; Currency["MOP"] = "MOP"; Currency["MRO"] = "MRO"; Currency["MUR"] = "MUR"; Currency["MVR"] = "MVR"; Currency["MWK"] = "MWK"; Currency["MXN"] = "MXN"; Currency["MXV"] = "MXV"; Currency["MYR"] = "MYR"; Currency["MZN"] = "MZN"; Currency["NAD"] = "NAD"; Currency["NGN"] = "NGN"; Currency["NIO"] = "NIO"; Currency["NOK"] = "NOK"; Currency["NPR"] = "NPR"; Currency["NZD"] = "NZD"; Currency["OMR"] = "OMR"; Currency["PAB"] = "PAB"; Currency["PEN"] = "PEN"; Currency["PGK"] = "PGK"; Currency["PHP"] = "PHP"; Currency["PKR"] = "PKR"; Currency["PLN"] = "PLN"; Currency["PYG"] = "PYG"; Currency["QAR"] = "QAR"; Currency["RON"] = "RON"; Currency["RSD"] = "RSD"; Currency["RUB"] = "RUB"; Currency["RWF"] = "RWF"; Currency["SAR"] = "SAR"; Currency["SBD"] = "SBD"; Currency["SCR"] = "SCR"; Currency["SDG"] = "SDG"; Currency["SEK"] = "SEK"; Currency["SGD"] = "SGD"; Currency["SHP"] = "SHP"; Currency["SLL"] = "SLL"; Currency["SOS"] = "SOS"; Currency["SRD"] = "SRD"; Currency["SSP"] = "SSP"; Currency["STD"] = "STD"; Currency["SVC"] = "SVC"; Currency["SYP"] = "SYP"; Currency["SZL"] = "SZL"; Currency["THB"] = "THB"; Currency["TJS"] = "TJS"; Currency["TMT"] = "TMT"; Currency["TND"] = "TND"; Currency["TOP"] = "TOP"; Currency["TRC"] = "TRC"; Currency["TRY"] = "TRY"; Currency["TTD"] = "TTD"; Currency["TWD"] = "TWD"; Currency["TZS"] = "TZS"; Currency["UAH"] = "UAH"; Currency["UGX"] = "UGX"; Currency["USD"] = "USD"; Currency["USN"] = "USN"; Currency["USS"] = "USS"; Currency["UYI"] = "UYI"; Currency["UYU"] = "UYU"; Currency["UZS"] = "UZS"; Currency["VEF"] = "VEF"; Currency["VND"] = "VND"; Currency["VUV"] = "VUV"; Currency["WST"] = "WST"; Currency["XAF"] = "XAF"; Currency["XAG"] = "XAG"; Currency["XAU"] = "XAU"; Currency["XBA"] = "XBA"; Currency["XBB"] = "XBB"; Currency["XBC"] = "XBC"; Currency["XBD"] = "XBD"; Currency["XCD"] = "XCD"; Currency["XDR"] = "XDR"; Currency["XOF"] = "XOF"; Currency["XPD"] = "XPD"; Currency["XPF"] = "XPF"; Currency["XPT"] = "XPT"; Currency["XTS"] = "XTS"; Currency["XXX"] = "XXX"; Currency["YER"] = "YER"; Currency["ZAR"] = "ZAR"; Currency["ZMK"] = "ZMK"; Currency["ZMW"] = "ZMW"; Currency["BTC"] = "BTC"; Currency["ETH"] = "ETH"; })(exports.Currency || (exports.Currency = {})); function CurrencyFromJSON(json) { return CurrencyFromJSONTyped(json); } function CurrencyFromJSONTyped(json, ignoreDiscriminator) { return json; } function CurrencyToJSON(value) { return value; } /* tslint:disable */ function OutstandingBalanceByCurrencyFromJSON(json) { return OutstandingBalanceByCurrencyFromJSONTyped(json); } function OutstandingBalanceByCurrencyFromJSONTyped(json, ignoreDiscriminator) { if (json === undefined || json === null) { return json; } return { currency: !exists(json, 'currency') ? undefined : CurrencyFromJSON(json['currency']), total_amount: !exists(json, 'total_amount') ? undefined : json['total_amount'], balances_by_period: !exists(json, 'balances_by_period') ? undefined : json['balances_by_period'].map(BalanceByPeriodFromJSON) }; } function OutstandingBalanceByCurrencyToJSON(value) { if (value === undefined) { return undefined; } if (value === null) { return null; } return { currency: CurrencyToJSON(value.currency), total_amount: value.total_amount, balances_by_period: value.balances_by_period === undefined ? undefined : value.balances_by_period.map(BalanceByPeriodToJSON) }; } /* tslint:disable */ function OutstandingBalanceBySupplierFromJSON(json) { return OutstandingBalanceBySupplierFromJSONTyped(json); } function OutstandingBalanceBySupplierFromJSONTyped(json, ignoreDiscriminator) { if (json === undefined || json === null) { return json; } return { supplier_id: !exists(json, 'supplier_id') ? undefined : json['supplier_id'], supplier_name: !exists(json, 'supplier_name') ? undefined : json['supplier_name'], outstanding_balances_by_currency: !exists(json, 'outstanding_balances_by_currency') ? undefined : json['outstanding_balances_by_currency'].map(OutstandingBalanceByCurrencyFromJSON) }; } function OutstandingBalanceBySupplierToJSON(value) { if (value === undefined) { return undefined; } if (value === null) { return null; } return { supplier_id: value.supplier_id, supplier_name: value.supplier_name, outstanding_balances_by_currency: value.outstanding_balances_by_currency === undefined ? undefined : value.outstanding_balances_by_currency.map(OutstandingBalanceByCurrencyToJSON) }; } /* tslint:disable */ function AgedCreditorsFromJSON(json) { return AgedCreditorsFromJSONTyped(json); } function AgedCreditorsFromJSONTyped(json, ignoreDiscriminator) { if (json === undefined || json === null) { return json; } return { report_generated_at: !exists(json, 'report_generated_at') ? undefined : new Date(json['report_generated_at']), report_as_of_date: !exists(json, 'report_as_of_date') ? undefined : new Date(json['report_as_of_date']), period_count: !exists(json, 'period_count') ? undefined : json['period_count'], period_length: !exists(json, 'period_length') ? undefined : json['period_length'], outstanding_balances: !exists(json, 'outstanding_balances') ? undefined : json['outstanding_balances'].map(OutstandingBalanceBySupplierFromJSON) }; } function AgedCreditorsToJSON(value) { if (value === undefined) { return undefined; } if (value === null) { return null; } return { report_generated_at: value.report_generated_at === undefined ? undefined : new Date(value.report_generated_at).toISOString(), report_as_of_date: value.report_as_of_date === undefined ? undefined : new Date(value.report_as_of_date).toISOString().substr(0, 10), period_count: value.period_count, period_length: value.period_length, outstanding_balances: value.outstanding_balances === undefined ? undefined : value.outstanding_balances.map(OutstandingBalanceBySupplierToJSON) }; } /* tslint:disable */ function OutstandingBalanceByCustomerFromJSON(json) { return OutstandingBalanceByCustomerFromJSONTyped(json); } function OutstandingBalanceByCustomerFromJSONTyped(json, ignoreDiscriminator) { if (json === undefined || json === null) { return json; } return { customer_id: !exists(json, 'customer_id') ? undefined : json['customer_id'], customer_name: !exists(json, 'customer_name') ? undefined : json['customer_name'], outstanding_balances_by_currency: !exists(json, 'outstanding_balances_by_currency') ? undefined : json['outstanding_balances_by_currency'].map(OutstandingBalanceByCurrencyFromJSON) }; } function OutstandingBalanceByCustomerToJSON(value) { if (value === undefined) { return undefined; } if (value === null) { return null; } return { customer_id: value.customer_id, customer_name: value.customer_name, outstanding_balances_by_currency: value.outstanding_balances_by_currency === undefined ? undefined : value.outstanding_balances_by_currency.map(OutstandingBalanceByCurrencyToJSON) }; } /* tslint:disable */ function AgedDebtorsFromJSON(json) { return AgedDebtorsFromJSONTyped(json); } function AgedDebtorsFromJSONTyped(json, ignoreDiscriminator) { if (json === undefined || json === null) { return json; } return { report_generated_at: !exists(json, 'report_generated_at') ? undefined : new Date(json['report_generated_at']), report_as_of_date: !exists(json, 'report_as_of_date') ? undefined : new Date(json['report_as_of_date']), period_count: !exists(json, 'period_count') ? undefined : json['period_count'], period_length: !exists(json, 'period_length') ? undefined : json['period_length'], outstanding_balances: !exists(json, 'outstanding_balances') ? undefined : json['outstanding_balances'].map(OutstandingBalanceByCustomerFromJSON) }; } function AgedDebtorsToJSON(value) { if (value === undefined) { return undefined; } if (value === null) { return null; } return { report_generated_at: value.report_generated_at === undefined ? undefined : new Date(value.report_generated_at).toISOString(), report_as_of_date: value.report_as_of_date === undefined ? undefined : new Date(value.report_as_of_date).toISOString().substr(0, 10), period_count: value.period_count, period_length: value.period_length, outstanding_balances: value.outstanding_balances === undefined ? undefined : value.outstanding_balances.map(OutstandingBalanceByCustomerToJSON) }; } /* tslint:disable */ function AgedReportFilterFromJSON(json) { return AgedReportFilterFromJSONTyped(json); } function AgedReportFilterFromJSONTyped(json, ignoreDiscriminator) { if (json === undefined || json === null) { return json; } return { customer_id: !exists(json, 'customer_id') ? undefined : json['customer_id'], supplier_id: !exists(json, 'supplier_id') ? undefined : json['supplier_id'], report_as_of_date: !exists(json, 'report_as_of_date') ? undefined : json['report_as_of_date'], period_count: !exists(json, 'period_count') ? undefined : json['period_count'], period_length: !exists(json, 'period_length') ? undefined : json['period_length'] }; } function AgedReportFilterToJSON(value) { if (value === undefined) { return undefined; } if (value === null) { return null; } return { customer_id: value.customer_id, supplier_id: value.supplier_id, report_as_of_date: value.report_as_of_date, period_count: value.period_count, period_length: value.period_length }; } /* tslint:disable */ (function (AllocationType) { AllocationType["invoice"] = "invoice"; AllocationType["order"] = "order"; AllocationType["expense"] = "expense"; AllocationType["credit_memo"] = "credit_memo"; AllocationType["over_payment"] = "over_payment"; AllocationType["pre_payment"] = "pre_payment"; AllocationType["journal_entry"] = "journal_entry"; AllocationType["other"] = "other"; AllocationType["bill"] = "bill"; })(exports.AllocationType || (exports.AllocationType = {})); function AllocationFromJSON(json) { return AllocationFromJSONTyped(json); } function AllocationFromJSONTyped(json, ignoreDiscriminator) { if (json === undefined || json === null) { return json; } return { id: !exists(json, 'id') ? undefined : json['id'], type: !exists(json, 'type') ? undefined : json['type'], code: !exists(json, 'code') ? undefined : json['code'], amount: !exists(json, 'amount') ? undefined : json['amount'], allocation_id: !exists(json, 'allocation_id') ? undefined : json['allocation_id'] }; } function AllocationToJSON(value) { if (value === undefined) { return undefined; } if (value === null) { return null; } return { id: value.id, type: value.type, amount: value.amount, allocation_id: value.allocation_id }; } /* tslint:disable */ (function (ResourceStatus) { ResourceStatus["live"] = "live"; ResourceStatus["beta"] = "beta"; ResourceStatus["development"] = "development"; ResourceStatus["upcoming"] = "upcoming"; ResourceStatus["considering"] = "considering"; })(exports.ResourceStatus || (exports.ResourceStatus = {})); function ResourceStatusFromJSON(json) { return ResourceStatusFromJSONTyped(json); } function ResourceStatusFromJSONTyped(json, ignoreDiscriminator) { return json; } function ResourceStatusToJSON(value) { return value; } /* tslint:disable */ function ApiResourcesFromJSON(json) { return ApiResourcesFromJSONTyped(json); } function ApiResourcesFromJSONTyped(json, ignoreDiscriminator) { if (json === undefined || json === null) { return json; } return { id: !exists(json, 'id') ? undefined : json['id'], name: !exists(json, 'name') ? undefined : json['name'], status: !exists(json, 'status') ? undefined : ResourceStatusFromJSON(json['status']), excluded_from_coverage: !exists(json, 'excluded_from_coverage') ? undefined : json['excluded_from_coverage'] }; } function ApiResourcesToJSON(value) { if (value === undefined) { return undefine