@apideck/node
Advanced tools
Comparing version 0.2.0 to 1.0.0-beta.0
@@ -1,57 +0,15 @@ | ||
import * as Crm from './gen/crm'; | ||
export declare class Mapper { | ||
static toInternal(requestParameters: Crm.CompaniesAllRequest | Crm.CompaniesOneRequest | Crm.CompaniesAddRequest | Crm.CompaniesUpdateRequest | Crm.CompaniesDeleteRequest): any; | ||
} | ||
export declare class CompaniesApi { | ||
readonly config: Crm.Configuration; | ||
private companies; | ||
constructor(config: Crm.Configuration); | ||
list(parameters: Crm.CompaniesAllRequest): Promise<Crm.GetCompaniesResponse>; | ||
retrieve(parameters: Crm.CompaniesOneRequest): Promise<Crm.GetCompanyResponse>; | ||
create(parameters: Crm.CompaniesAddRequest): Promise<Crm.CreateCompanyResponse>; | ||
update(parameters: Crm.CompaniesUpdateRequest): Promise<Crm.UpdateCompanyResponse>; | ||
delete(parameters: Crm.CompaniesDeleteRequest): Promise<Crm.DeleteCompanyResponse>; | ||
} | ||
export declare class ContactsApi { | ||
readonly config: Crm.Configuration; | ||
private contacts; | ||
constructor(config: Crm.Configuration); | ||
list(parameters: Crm.ContactsAllRequest): Promise<Crm.GetContactsResponse>; | ||
retrieve(parameters: Crm.ContactsOneRequest): Promise<Crm.GetContactResponse>; | ||
create(parameters: Crm.ContactsAddRequest): Promise<Crm.CreateContactResponse>; | ||
update(parameters: Crm.ContactsUpdateRequest): Promise<Crm.UpdateContactResponse>; | ||
delete(parameters: Crm.ContactsDeleteRequest): Promise<Crm.DeleteContactResponse>; | ||
} | ||
export declare class LeadsApi { | ||
readonly config: Crm.Configuration; | ||
private leads; | ||
constructor(config: Crm.Configuration); | ||
list(parameters: Crm.LeadsAllRequest): Promise<Crm.GetLeadsResponse>; | ||
retrieve(parameters: Crm.LeadsOneRequest): Promise<Crm.GetLeadResponse>; | ||
create(parameters: Crm.LeadsAddRequest): Promise<Crm.CreateLeadResponse>; | ||
update(parameters: Crm.LeadsUpdateRequest): Promise<Crm.UpdateLeadResponse>; | ||
delete(parameters: Crm.LeadsDeleteRequest): Promise<Crm.DeleteLeadResponse>; | ||
} | ||
export declare class OpportunitiesApi { | ||
readonly config: Crm.Configuration; | ||
private opportunities; | ||
constructor(config: Crm.Configuration); | ||
list(parameters: Crm.OpportunitiesAllRequest): Promise<Crm.GetOpportunitiesResponse>; | ||
retrieve(parameters: Crm.OpportunitiesOneRequest): Promise<Crm.GetOpportunityResponse>; | ||
create(parameters: Crm.OpportunitiesAddRequest): Promise<Crm.CreateOpportunityResponse>; | ||
update(parameters: Crm.OpportunitiesUpdateRequest): Promise<Crm.UpdateOpportunityResponse>; | ||
delete(parameters: Crm.OpportunitiesDeleteRequest): Promise<Crm.DeleteOpportunityResponse>; | ||
} | ||
export declare class CrmApi { | ||
readonly configParameters: Crm.ConfigurationParameters; | ||
readonly companies: CompaniesApi; | ||
readonly contacts: ContactsApi; | ||
readonly leads: LeadsApi; | ||
readonly opportunities: OpportunitiesApi; | ||
constructor(configParameters: Crm.ConfigurationParameters); | ||
} | ||
import { CrmApi, LeadApi, VaultApi } from './gen/'; | ||
export declare type ApideckConfiguration = { | ||
basePath?: string; | ||
apiKey: string; | ||
appId: string; | ||
consumerId?: string; | ||
serviceId?: string; | ||
}; | ||
export declare class Apideck { | ||
readonly config: Crm.ConfigurationParameters; | ||
readonly config: ApideckConfiguration; | ||
readonly crm: CrmApi; | ||
constructor(config: Crm.ConfigurationParameters); | ||
readonly lead: LeadApi; | ||
readonly vault: VaultApi; | ||
constructor(config: ApideckConfiguration); | ||
} |
import { Apideck } from './Apideck'; | ||
export * from './gen/crm'; | ||
export * from './gen'; | ||
export { Apideck }; | ||
export default Apideck; |
{ | ||
"name": "@apideck/node", | ||
"version": "0.2.0", | ||
"version": "1.0.0-beta.0", | ||
"description": "Apideck API wrapper", | ||
@@ -8,4 +8,4 @@ "keywords": [ | ||
"api", | ||
"unified apis", | ||
"crm" | ||
"unify", | ||
"unified apis" | ||
], | ||
@@ -15,2 +15,4 @@ "homepage": "https://apideck.com", | ||
"contributors": [ | ||
"Nick Lloyd <nick@apideck.com>", | ||
"Elias Meire <elias@apideck.com>", | ||
"Geert Wille <geert@apideck.com>" | ||
@@ -20,5 +22,5 @@ ], | ||
"type": "git", | ||
"url": "git://github.com/apideck-libraries/apideck-node.git" | ||
"url": "git://github.com/apideck-libraries/node-sdk.git" | ||
}, | ||
"bugs:": "https://github.com/apideck-libraries/apideck-node/issues", | ||
"bugs:": "https://github.com/apideck-libraries/node-sdk/issues", | ||
"engines": { | ||
@@ -34,2 +36,3 @@ "node": ">=10" | ||
"lint": "tsdx lint", | ||
"test": "DEBUG=nock.* tsdx test", | ||
"prepare": "tsdx build", | ||
@@ -43,8 +46,2 @@ "release": "np" | ||
}, | ||
"prettier": { | ||
"printWidth": 80, | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "es5" | ||
}, | ||
"license": "Apache-2.0", | ||
@@ -56,6 +53,10 @@ "peerDependencies": {}, | ||
"devDependencies": { | ||
"@types/jest": "^27.0.0", | ||
"@types/node-fetch": "^2.5.8", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"husky": "^5.2.0", | ||
"jest": "^27.0.6", | ||
"jest-fetch-mock": "^3.0.3", | ||
"lint-staged": "^10.5.4", | ||
"nock": "^13.1.1", | ||
"np": "^7.4.0", | ||
@@ -69,3 +70,8 @@ "prettier": "^2.2.1", | ||
"dist", | ||
"src" | ||
"src/index.ts", | ||
"src/Apideck.ts", | ||
"src/gen/apis", | ||
"src/gen/models", | ||
"src/gen/index.ts", | ||
"src/gen/runtime.ts" | ||
], | ||
@@ -72,0 +78,0 @@ "np": { |
123
README.md
@@ -17,3 +17,3 @@ # Apideck Node.js library | ||
```console | ||
$ npm install apideck | ||
$ npm install @apideck/node | ||
``` | ||
@@ -24,3 +24,3 @@ | ||
```console | ||
$ yarn add apideck | ||
$ yarn add @apideck/node | ||
``` | ||
@@ -32,72 +32,35 @@ | ||
to the [docs][2]. | ||
All endpoints require a valid apiKey so that's the only required parameter to initialize a new Apideck client: | ||
### Configuration | ||
A new Apideck instance is initialized by passing in required settings to the configuration. | ||
```typescript | ||
import Apideck from 'apideck'; | ||
import Apideck from @apideck/node; | ||
const apideck = new Apideck({ | ||
apiKey: <insert-api-key-here>, | ||
applicationId: <insert-application-id-here>, | ||
consumerId: <insert-consumer-id-here>, | ||
serviceId: <insert-service-id-here> | ||
}); | ||
``` | ||
apiKey: '<insert-api-key-here>', | ||
appId: '<insert-application-id-here>', | ||
consumerId: '<insert-consumer-id-here>', | ||
serviceId: '<insert-service-id-here>' | ||
}) | ||
All top level parameters (except for apiKey) can be overriden in specific resource calls. | ||
const { crm } = apideck | ||
```typescript | ||
const response = await apideck.crm.contacts.list({ | ||
limit: '10', | ||
serviceId: '<insert-service-id-here>', | ||
consumerId: <insert-consumer-id-here> | ||
}) | ||
``` | ||
## Methods | ||
Once you created a new Apideck client you can use following methods: | ||
Top level parameters (except for apiKey) can be overriden in specific resource calls. | ||
```typescript | ||
import Apideck from 'apideck'; | ||
// Declare Unify Api to use | ||
const { crm } = apideck | ||
const apideck = new Apideck({ | ||
apiKey: <insert-api-key-here>, | ||
applicationId: <insert-application-id-here>, | ||
consumerId: <insert-consumer-id-here>, | ||
serviceId: <insert-service-id-here> | ||
}); | ||
// Override consumerId serviceId as declared in initial configuration for this operation. | ||
const response = await crm.contactsAll({ | ||
serviceId: '<insert-other-service-id-here>', | ||
limit: '10' | ||
}) | ||
``` | ||
### CompaniesApi | ||
```typescript | ||
apideck.companies.list(parameters); | ||
apideck.companies.retrieve(parameters); | ||
apideck.companies.create(parameters); | ||
apideck.companies.update(parameters); | ||
apideck.companies.delete(parameters); | ||
``` | ||
### ContactsApi | ||
```typescript | ||
apideck.contacts.list(parameters); | ||
apideck.contacts.retrieve(parameters); | ||
apideck.contacts.create(parameters); | ||
apideck.contacts.update(parameters); | ||
apideck.contacts.delete(parameters); | ||
``` | ||
### LeadsApi | ||
```typescript | ||
apideck.leads.list(parameters); | ||
apideck.leads.retrieve(parameters); | ||
apideck.leads.create(parameters); | ||
apideck.leads.update(parameters); | ||
apideck.leads.delete(parameters); | ||
``` | ||
### OpportunitiesApi | ||
```typescript | ||
apideck.opportunities.list(parameters); | ||
apideck.opportunities.retrieve(parameters); | ||
apideck.opportunities.create(parameters); | ||
apideck.opportunities.update(parameters); | ||
apideck.opportunities.delete(parameters); | ||
``` | ||
## Example | ||
@@ -108,16 +71,19 @@ | ||
```typescript | ||
import { Apideck, PhoneNumberType } from 'apideck' | ||
import Apideck, { PhoneNumberType } from @apideck/node; | ||
const apideck = new Apideck({ | ||
apiKey: <insert-api-key-here>, | ||
applicationId: <insert-application-id-here>, | ||
consumerId: <insert-consumer-id-here>, | ||
serviceId: <insert-service-id-here> | ||
}); | ||
apiKey: '<insert-api-key-here'>, | ||
appId: '<insert-application-id-here>', | ||
consumerId: '<insert-consumer-id-here>', | ||
serviceId: '<insert-service-id-here>' | ||
}) | ||
const { data } = await apideck.crm.contacts.list({ | ||
const { crm } = apideck | ||
const { data } = await crm.contactsAll({ | ||
limit: 10 | ||
}) | ||
const result = await apideck.crm.contacts.update({ | ||
const result = await crm.contactsUpdate({ | ||
id: data[0].id!, | ||
@@ -143,2 +109,21 @@ contact: { | ||
<a name="documentation-for-api-endpoints"></a> | ||
## Apideck Unified Apis | ||
The following Apis are currently available: | ||
### CrmApi | ||
Read the full documentation of the CrmApi [here](./src/gen/docs/apis/CrmApi.md). | ||
### LeadApi | ||
Read the full documentation of the LeadApi [here](./src/gen/docs/apis/LeadApi.md). | ||
### VaultApi | ||
Read the full documentation of the VaultApi [here](./src/gen/docs/apis/VaultApi.md). | ||
## Support | ||
@@ -154,3 +139,3 @@ | ||
[2]: https://developers.apideck.com/ | ||
[3]: https://github.com/apideck-libraries/apideck-node/issues/new | ||
[4]: https://github.com/apideck-libraries/apideck-node/blob/master/LICENSE | ||
[3]: https://github.com/apideck-libraries/node-sdk/issues/new | ||
[4]: https://github.com/apideck-libraries/node-sdk/blob/master/LICENSE |
@@ -1,198 +0,42 @@ | ||
import * as Crm from './gen/crm'; | ||
import fetch from 'node-fetch' | ||
import { CrmApi, LeadApi, VaultApi } from './gen/' | ||
import { Configuration } from './gen/runtime' | ||
export class Mapper { | ||
public static toInternal( | ||
requestParameters: | ||
| Crm.CompaniesAllRequest | ||
| Crm.CompaniesOneRequest | ||
| Crm.CompaniesAddRequest | ||
| Crm.CompaniesUpdateRequest | ||
| Crm.CompaniesDeleteRequest | ||
): any { | ||
const mappedRequestParameters = { | ||
...requestParameters, | ||
xApideckAppId: requestParameters.applicationId, | ||
xApideckConsumerId: requestParameters.consumerId, | ||
xApideckServiceId: requestParameters.serviceId, | ||
}; | ||
const isNode = | ||
typeof process !== 'undefined' && process.versions != null && process.versions.node != null | ||
return mappedRequestParameters; | ||
} | ||
export type ApideckConfiguration = { | ||
basePath?: string | ||
apiKey: string | ||
appId: string | ||
consumerId?: string | ||
serviceId?: string | ||
} | ||
export class CompaniesApi { | ||
private companies: Crm.CompaniesApi; | ||
constructor(readonly config: Crm.Configuration) { | ||
this.companies = new Crm.CompaniesApi(config); | ||
} | ||
async list(parameters: Crm.CompaniesAllRequest) { | ||
return this.companies.companiesAll( | ||
Mapper.toInternal(parameters) as Crm.CompaniesAllRequestInternal | ||
); | ||
} | ||
async retrieve(parameters: Crm.CompaniesOneRequest) { | ||
return this.companies.companiesOne( | ||
Mapper.toInternal(parameters as Crm.CompaniesOneRequestInternal) | ||
); | ||
} | ||
async create(parameters: Crm.CompaniesAddRequest) { | ||
return this.companies.companiesAdd( | ||
Mapper.toInternal(parameters as Crm.CompaniesAddRequestInternal) | ||
); | ||
} | ||
async update(parameters: Crm.CompaniesUpdateRequest) { | ||
return this.companies.companiesUpdate( | ||
Mapper.toInternal(parameters) as Crm.CompaniesUpdateRequestInternal | ||
); | ||
} | ||
async delete(parameters: Crm.CompaniesDeleteRequest) { | ||
return this.companies.companiesDelete( | ||
Mapper.toInternal(parameters) as Crm.CompaniesDeleteRequestInternal | ||
); | ||
} | ||
} | ||
export class ContactsApi { | ||
private contacts: Crm.ContactsApi; | ||
constructor(readonly config: Crm.Configuration) { | ||
this.contacts = new Crm.ContactsApi(config); | ||
} | ||
async list(parameters: Crm.ContactsAllRequest) { | ||
return this.contacts.contactsAll( | ||
Mapper.toInternal(parameters) as Crm.ContactsAllRequestInternal | ||
); | ||
} | ||
async retrieve(parameters: Crm.ContactsOneRequest) { | ||
return this.contacts.contactsOne( | ||
Mapper.toInternal(parameters as Crm.ContactsOneRequestInternal) | ||
); | ||
} | ||
async create(parameters: Crm.ContactsAddRequest) { | ||
return this.contacts.contactsAdd( | ||
Mapper.toInternal(parameters as Crm.ContactsAddRequestInternal) | ||
); | ||
} | ||
async update(parameters: Crm.ContactsUpdateRequest) { | ||
return this.contacts.contactsUpdate( | ||
Mapper.toInternal(parameters) as Crm.ContactsUpdateRequestInternal | ||
); | ||
} | ||
async delete(parameters: Crm.ContactsDeleteRequest) { | ||
return this.contacts.contactsDelete( | ||
Mapper.toInternal(parameters) as Crm.ContactsDeleteRequestInternal | ||
); | ||
} | ||
} | ||
export class LeadsApi { | ||
private leads: Crm.LeadsApi; | ||
constructor(readonly config: Crm.Configuration) { | ||
this.leads = new Crm.LeadsApi(config); | ||
} | ||
async list(parameters: Crm.LeadsAllRequest) { | ||
return this.leads.leadsAll( | ||
Mapper.toInternal(parameters) as Crm.LeadsAllRequestInternal | ||
); | ||
} | ||
async retrieve(parameters: Crm.LeadsOneRequest) { | ||
return this.leads.leadsOne( | ||
Mapper.toInternal(parameters as Crm.LeadsOneRequestInternal) | ||
); | ||
} | ||
async create(parameters: Crm.LeadsAddRequest) { | ||
return this.leads.leadsAdd( | ||
Mapper.toInternal(parameters as Crm.LeadsAddRequestInternal) | ||
); | ||
} | ||
async update(parameters: Crm.LeadsUpdateRequest) { | ||
return this.leads.leadsUpdate( | ||
Mapper.toInternal(parameters) as Crm.LeadsUpdateRequestInternal | ||
); | ||
} | ||
async delete(parameters: Crm.LeadsDeleteRequest) { | ||
return this.leads.leadsDelete( | ||
Mapper.toInternal(parameters) as Crm.LeadsDeleteRequestInternal | ||
); | ||
} | ||
} | ||
export class OpportunitiesApi { | ||
private opportunities: Crm.OpportunitiesApi; | ||
constructor(readonly config: Crm.Configuration) { | ||
this.opportunities = new Crm.OpportunitiesApi(config); | ||
} | ||
async list(parameters: Crm.OpportunitiesAllRequest) { | ||
return this.opportunities.opportunitiesAll( | ||
Mapper.toInternal(parameters) as Crm.OpportunitiesAllRequestInternal | ||
); | ||
} | ||
async retrieve(parameters: Crm.OpportunitiesOneRequest) { | ||
return this.opportunities.opportunitiesOne( | ||
Mapper.toInternal(parameters as Crm.OpportunitiesOneRequestInternal) | ||
); | ||
} | ||
async create(parameters: Crm.OpportunitiesAddRequest) { | ||
return this.opportunities.opportunitiesAdd( | ||
Mapper.toInternal(parameters as Crm.OpportunitiesAddRequestInternal) | ||
); | ||
} | ||
async update(parameters: Crm.OpportunitiesUpdateRequest) { | ||
return this.opportunities.opportunitiesUpdate( | ||
Mapper.toInternal(parameters) as Crm.OpportunitiesUpdateRequestInternal | ||
); | ||
} | ||
async delete(parameters: Crm.OpportunitiesDeleteRequest) { | ||
return this.opportunities.opportunitiesDelete( | ||
Mapper.toInternal(parameters) as Crm.OpportunitiesDeleteRequestInternal | ||
); | ||
} | ||
} | ||
export class CrmApi { | ||
readonly companies: CompaniesApi; | ||
readonly contacts: ContactsApi; | ||
readonly leads: LeadsApi; | ||
readonly opportunities: OpportunitiesApi; | ||
constructor(readonly configParameters: Crm.ConfigurationParameters) { | ||
const config = new Crm.Configuration(configParameters); | ||
this.companies = new CompaniesApi(config); | ||
this.contacts = new ContactsApi(config); | ||
this.leads = new LeadsApi(config); | ||
this.opportunities = new OpportunitiesApi(config); | ||
} | ||
} | ||
const isNode = | ||
typeof process !== 'undefined' && | ||
process.versions != null && | ||
process.versions.node != null; | ||
export class Apideck { | ||
readonly crm: CrmApi; | ||
constructor(readonly config: Crm.ConfigurationParameters) { | ||
readonly crm: CrmApi | ||
readonly lead: LeadApi | ||
readonly vault: VaultApi | ||
constructor(readonly config: ApideckConfiguration) { | ||
if (!isNode) { | ||
console.warn( | ||
"THIS IS A SERVERSIDE (Node.js) LIBRARY AND SHOULDN'T BE USED IN THE BROWSER OR YOU RISK LEAKING YOUR APIKEYS. PLEASE BE CAREFULL AND DON'T SHIP THIS TO PRODUCTION." | ||
); | ||
"THIS IS A SERVERSIDE (Node.JS) LIBRARY AND SHOULDN'T BE USED IN THE BROWSER AS YOU RISK LEAKING YOUR API KEYS." | ||
) | ||
} | ||
this.crm = new CrmApi(config); | ||
const configuration = new Configuration({ | ||
fetchApi: fetch as any, | ||
basePath: config.basePath, | ||
apiKey: `Bearer ${config.apiKey}`, | ||
headers: { | ||
'x-apideck-app-id': config.appId, | ||
'x-apideck-consumer-id': config.consumerId || '', | ||
'x-apideck-service-id': config?.serviceId || '' | ||
} | ||
}) | ||
this.crm = new CrmApi(configuration) | ||
this.lead = new LeadApi(configuration) | ||
this.vault = new VaultApi(configuration) | ||
} | ||
} |
@@ -1,5 +0,5 @@ | ||
import { Apideck } from './Apideck'; | ||
export * from './gen/crm'; | ||
import { Apideck } from './Apideck' | ||
export * from './gen' | ||
export { Apideck } | ||
export { Apideck }; | ||
export default Apideck; | ||
export default Apideck |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3755662
256
46197
13
136
7