1.0.3 • Published 1 year ago

@pacely-next/office v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

@pacely/office

Authentication

Strategies

Our authentication strategies currently includes:

ProtocolGrant typeCurrent stats
OAuth2Client Credentialsready
OAuth2Authorization Codenot started
OAuth2Device Codenot started
JWTJSON Web Tokensnot started

Constructor options

OptionTypeDescriptionDefault
providerstringChoose provider.poweroffice
authobjectObject containing keys etc.-
testingboolWhether to authenticate with a demo api.false

Example

import Office from '@pacely/office'

let authenticated: boolean = false;

const office = new Office({
    provider: 'poweroffice',
    testing: true,
    auth: {
        client_id: '<Client ID>',
        client_key: '<Client key>'
    }
});

// Authenticate with the choosen provider
office.authenticate().then((authStatus: boolean) => {
    authenticated = authStatus
});

Resources

Customers

const provider = office.provider;

if (provider.authenticated) {
    const customers: CustomerModel[] = provider.customers({ allFields: true }).all();
    
    customers.map((customer: CustomerModel) => {
        console.log(customer.name); // ACME AS
    })
}

Invoices

Get invoices

const provider = office.provider;

if (provider.authenticated) {
    const invoices: Invoice[] = provider.invoices.find({
        filter: {
            projectCode: 1234,
            totalAmount: {
                operator: 'gt',
                value: 200
            }
        },
        order: {
            totalAmount: 'asc'
        },
        top: 10
    });
    
    invoices.map((invoice: Invoice) => {
        console.log(invoice.totalAmount);
    })
}

Project

if (provider.authenticated) {
    const projects: Project[] = provider.projects.all();
    const project: Project = provider.projects.find(id);
    const projectActivities: ProjectActivity[] = provider.projects.activities.all();
    const customers: CustomerModel[] = await office.customers().all();
}

API'er

https://github.com/nuxt-community/auth-module/blob/dev/src/index.ts

1.0.3

1 year ago