unleashed 0.1.13 → 0.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +37 -1
- data/lib/unleashed/resources/currency_resource.rb +3 -6
- data/lib/unleashed/resources/customer_resource.rb +45 -7
- data/lib/unleashed/resources/invoice_resource.rb +56 -4
- data/lib/unleashed/resources/payment_term_resource.rb +22 -18
- data/lib/unleashed/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 163e4108af74a8837955b70ece495fce05e57d754dea7456fe4728acf6cfe898
|
4
|
+
data.tar.gz: 0a483a88892922a15831688c082dbc2e1b2f26b14263186ca39cb283064b9be3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acbf6829e4329b7e330ccdbe6cea08fa4b2cc4c5d07d2c4cadbea1f3906a8edae529e1a92931eb1c0d98adabfc07efe2d52fb0eba8040b6b477db0d517b6c495
|
7
|
+
data.tar.gz: cf3eb8666c697dc75739735ad1b00400eb564328dcfc54d8a0432236b9958c22ceef757a4dd66c0c7d50595cb9fbc3c123758c62dc50ecb46bab464f53453478
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
+
## [0.1.14] - 2020-02-23
|
6
|
+
|
7
|
+
- Update options, queries, comments of `currencies`, `customers`, `invoices`, `payment terms`.
|
8
|
+
- Replace `create` method by `create_or_update` method of `customers`
|
9
|
+
|
5
10
|
## [0.1.13] - 2019-12-05
|
6
11
|
|
7
12
|
- Update version.
|
data/README.md
CHANGED
@@ -75,7 +75,7 @@ client = Unleashed::Client.new(options)
|
|
75
75
|
#### Create a new Customer
|
76
76
|
|
77
77
|
```ruby
|
78
|
-
customer = client.customers.
|
78
|
+
customer = client.customers.create_or_update(
|
79
79
|
Guid: '59f21e05-07fe-4d9d-b460-a09db4c3caa9',
|
80
80
|
Addresses: [
|
81
81
|
{
|
@@ -195,6 +195,26 @@ customer = client.customers.update(
|
|
195
195
|
#### Get all customers
|
196
196
|
|
197
197
|
```ruby
|
198
|
+
# List all customers
|
199
|
+
# /Customers - also returns the first 200 customers because page number 1 is the default.
|
200
|
+
#
|
201
|
+
# @param options [Hash] Optional options.
|
202
|
+
# @option PageSize: Can ask for up to 200 customers. Default: 200
|
203
|
+
# @option Page: Page index. Default: 1
|
204
|
+
# @option CustomerType: Only returns customers that matches the specified customer type.
|
205
|
+
# @option SellPriceTier: Only returns customers that are assigned to the specified sell price tier.
|
206
|
+
# @option Currency: Only returns customers with currency code exactly matching the specified value.
|
207
|
+
# @option Customer: Returns customers whose customer code or customer name contains the specified value. It is case-sensitive.
|
208
|
+
# @option CustomerCode: Only returns customers that start with the specific customer code.
|
209
|
+
# @option CustomerName: Only returns customers that start with the specific customer name.
|
210
|
+
# @option ContactEmail: Only returns customers that have a contact email that starts with the specified email address.
|
211
|
+
# @option ModifiedSince: Only returns customers modified since a specified date.
|
212
|
+
# @option IncludeObsolete: Returns all customers, including obsolete, if set to `true`. If set to `false` or if it is not specified then returns only active (ie. non-obsolete) customers.
|
213
|
+
# @option XeroContactId: Only returns customers that start with the specific Xero Contact Id.
|
214
|
+
# @option OrderBy: Orders the list by `LastModifiedOn` or `CreatedOn` date. By default the list is ordered by `CustomerCode`.
|
215
|
+
# @option Sort: Orders the list by `CreatedOn` date sorted in ascending or descending order.
|
216
|
+
#
|
217
|
+
# @return [Array<Unleashed::Customer>] List all customers.
|
198
218
|
client.customers.all
|
199
219
|
```
|
200
220
|
|
@@ -221,6 +241,22 @@ client.customers.last
|
|
221
241
|
#### Get all invoices
|
222
242
|
|
223
243
|
```ruby
|
244
|
+
# List all invoices
|
245
|
+
# /Invoices - also returns the first 200 invoices because page number 1 is the default.
|
246
|
+
#
|
247
|
+
# @param options [Hash] Optional options.
|
248
|
+
# @option Page: Page index. Default: 1
|
249
|
+
# @option PageSize: Specifies the page size for pagination. Default page size is 200 invoices.
|
250
|
+
# @option CustomerCode: Returns invoices that matches the specific customer code.
|
251
|
+
# @option StartDate: Returns invoices created after a specified date, must be UTC format.
|
252
|
+
# @option EndDate: Returns invoices created before a specified date, must be UTC format.
|
253
|
+
# @option ModifiedSince: Returns invoices created or edited after a specified date, must be UTC format.
|
254
|
+
# @option OrderNumber: Returns the invoices associated with the Sales Order Number.
|
255
|
+
# @option InvoiceNumber: Returns a single invoice with the specified invoice number. If set, it overrides all other filters.
|
256
|
+
# @option InvoiceStatus: Returns invoices with the specified status. Multiple selection can be specified as comma separated.For example: `invoiceStatus=Completed,Parked`. If no invoiceStatus filter is specified, then we exclude “Deleted” by default.
|
257
|
+
# @option SerialBatch: False by default. If set to true then the attributes SerialNumbers and BatchNumbers are displayed.
|
258
|
+
#
|
259
|
+
# @return [Array<Unleashed::Invoice>] List all invoices.
|
224
260
|
client.invoices.all
|
225
261
|
```
|
226
262
|
|
@@ -10,13 +10,10 @@ module Unleashed
|
|
10
10
|
# List all currencies
|
11
11
|
# /Currencies - also returns the first 200 currencies because page number 1 is the default.
|
12
12
|
#
|
13
|
-
# @param options [Hash] Optional options.
|
14
|
-
# @option options [Integer] :page_size Can ask for up to 200 currencies. default: 10
|
15
|
-
# @option options [Integer] :page Page index. default: 1
|
16
|
-
#
|
17
13
|
# @return [Array<Unleashed::Currency>] List all currencies.
|
18
|
-
def all
|
19
|
-
|
14
|
+
def all
|
15
|
+
endpoint = 'Currencies'
|
16
|
+
response = JSON.parse(@client.get(endpoint, options).body)
|
20
17
|
currencies = response.key?('Items') ? response['Items'] : []
|
21
18
|
currencies.map { |attributes| Unleashed::Currency.new(@client, attributes) }
|
22
19
|
end
|
@@ -14,12 +14,33 @@ module Unleashed
|
|
14
14
|
# /Customers - also returns the first 200 customers because page number 1 is the default.
|
15
15
|
#
|
16
16
|
# @param options [Hash] Optional options.
|
17
|
-
# @option
|
18
|
-
# @option
|
17
|
+
# @option PageSize: Can ask for up to 200 customers. Default: 200
|
18
|
+
# @option Page: Page index. Default: 1
|
19
|
+
# @option CustomerType: Only returns customers that matches the specified customer type.
|
20
|
+
# @option SellPriceTier: Only returns customers that are assigned to the specified sell price tier.
|
21
|
+
# @option Currency: Only returns customers with currency code exactly matching the specified value.
|
22
|
+
# @option Customer: Returns customers whose customer code or customer name contains the specified value. It is case-sensitive.
|
23
|
+
# @option CustomerCode: Only returns customers that start with the specific customer code.
|
24
|
+
# @option CustomerName: Only returns customers that start with the specific customer name.
|
25
|
+
# @option ContactEmail: Only returns customers that have a contact email that starts with the specified email address.
|
26
|
+
# @option ModifiedSince: Only returns customers modified since a specified date.
|
27
|
+
# @option IncludeObsolete: Returns all customers, including obsolete, if set to `true`. If set to `false` or if it is not specified then returns only active (ie. non-obsolete) customers.
|
28
|
+
# @option XeroContactId: Only returns customers that start with the specific Xero Contact Id.
|
29
|
+
# @option OrderBy: Orders the list by `LastModifiedOn` or `CreatedOn` date. By default the list is ordered by `CustomerCode`.
|
30
|
+
# @option Sort: Orders the list by `CreatedOn` date sorted in ascending or descending order.
|
19
31
|
#
|
20
32
|
# @return [Array<Unleashed::Customer>] List all customers.
|
21
|
-
def all(options = {
|
22
|
-
|
33
|
+
def all(options = { Page: 1, PageSize: 200 })
|
34
|
+
endpoint = 'Customers'
|
35
|
+
params = options.dup
|
36
|
+
|
37
|
+
# Handle Page option
|
38
|
+
if params[:Page].present?
|
39
|
+
endpoint << "/#{params[:Page]}"
|
40
|
+
params.delete :Page
|
41
|
+
end
|
42
|
+
|
43
|
+
response = JSON.parse(@client.get(endpoint, params).body)
|
23
44
|
customers = response.key?('Items') ? response['Items'] : []
|
24
45
|
customers.map { |attributes| Unleashed::Customer.new(@client, attributes) }
|
25
46
|
end
|
@@ -31,7 +52,8 @@ module Unleashed
|
|
31
52
|
#
|
32
53
|
# @return [Unleashed::Customer]
|
33
54
|
def find(id)
|
34
|
-
|
55
|
+
endpoint = "Customers/#{id}"
|
56
|
+
response = JSON.parse(@client.get(endpoint).body)
|
35
57
|
Unleashed::Customer.new(@client, response)
|
36
58
|
end
|
37
59
|
|
@@ -52,11 +74,27 @@ module Unleashed
|
|
52
74
|
# Create a new customer
|
53
75
|
#
|
54
76
|
# @param attributes [Hash] Customer's attributes.
|
77
|
+
# attributes = { Guid: "59f21e05-07fe-4d9d-b460-a09db4c3caa9", Addresses: [ { AddressType: "Shipping",
|
78
|
+
# AddressName: "Example Address", StreetAddress: "Example Address",
|
79
|
+
# StreetAddress2: "Example Address 2", Suburb: "Example Suburb", City: "Auckland",
|
80
|
+
# Region: "Auckland", Country: "New Zealand", PostalCode: "1061", IsDefault: false,
|
81
|
+
# DeliveryInstruction: "Have a good day" } ], TaxCode: "", TaxRate: nil,
|
82
|
+
# CustomerCode: "UnleashedCustomer", CustomerName: "Unleashed Customer", GSTVATNumber: nil,
|
83
|
+
# BankName: nil, BankBranch: nil, BankAccount: nil, Website: nil, PhoneNumber: nil, FaxNumber: nil,
|
84
|
+
# MobileNumber: nil, DDINumber: nil, TollFreeNumber: nil, Email: nil, EmailCC: nil,
|
85
|
+
# Currency: { CurrencyCode: "NZD", Description: "New Zealand, Dollars",
|
86
|
+
# Guid: "6cb5d67a-1c96-4fa8-bf59-b23c2d69f22a" }, Notes: nil, Taxable: true, SalesPerson: nil,
|
87
|
+
# DiscountRate: 0, PrintPackingSlipInsteadOfInvoice: false, PrintInvoice: false,
|
88
|
+
# StopCredit: false, Obsolete: false, XeroSalesAccount: nil, XeroCostOfGoodsAccount: nil,
|
89
|
+
# SellPriceTier: "", SellPriceTierReference: nil, CustomerType: "Cash",
|
90
|
+
# PaymentTerm: "20th Month following", ContactFirstName: nil, ContactLastName: nil }
|
55
91
|
#
|
56
92
|
# @return [Unleashed::Customer]
|
57
|
-
def
|
93
|
+
def create_or_update(attributes)
|
58
94
|
id = attributes[:Guid].present? ? attributes[:Guid] : ''
|
59
|
-
|
95
|
+
endpoint = 'Customers'
|
96
|
+
endpoint << "/#{id}" if id.present?
|
97
|
+
response = JSON.parse(@client.post(endpoint, attributes).body)
|
60
98
|
Unleashed::Customer.new(@client, response)
|
61
99
|
end
|
62
100
|
end
|
@@ -14,12 +14,64 @@ module Unleashed
|
|
14
14
|
# /Invoices - also returns the first 200 invoices because page number 1 is the default.
|
15
15
|
#
|
16
16
|
# @param options [Hash] Optional options.
|
17
|
-
# @option
|
18
|
-
# @option
|
17
|
+
# @option Page: Page index. Default: 1
|
18
|
+
# @option PageSize: Specifies the page size for pagination. Default page size is 200 invoices.
|
19
|
+
# @option CustomerCode: Returns invoices that matches the specific customer code.
|
20
|
+
# @option StartDate: Returns invoices created after a specified date, must be UTC format.
|
21
|
+
# @option EndDate: Returns invoices created before a specified date, must be UTC format.
|
22
|
+
# @option ModifiedSince: Returns invoices created or edited after a specified date, must be UTC format.
|
23
|
+
# @option OrderNumber: Returns the invoices associated with the Sales Order Number.
|
24
|
+
# @option InvoiceNumber: Returns a single invoice with the specified invoice number. If set, it overrides all other filters.
|
25
|
+
# @option InvoiceStatus: Returns invoices with the specified status. Multiple selection can be specified as comma separated.For example: `invoiceStatus=Completed,Parked`. If no invoiceStatus filter is specified, then we exclude “Deleted” by default.
|
26
|
+
# @option SerialBatch: False by default. If set to true then the attributes SerialNumbers and BatchNumbers are displayed.
|
19
27
|
#
|
20
28
|
# @return [Array<Unleashed::Invoice>] List all invoices.
|
21
|
-
|
22
|
-
|
29
|
+
# { Pagination: { NumberOfItems: 2, PageSize: 200, PageNumber: 1, NumberOfPages: 1 },
|
30
|
+
# Items: [ { InvoiceNumber: "SI-137", OrderNumber: "SO-137", QuoteNumber: nil,
|
31
|
+
# InvoiceDate: "/Date(1565058456626)/", DueDate: "/Date(1568937600000)/",
|
32
|
+
# InvoiceStatus: "Completed", Customer: { CustomerCode: "WADE",
|
33
|
+
# CustomerName: "Wade's Apparel & Accessories", CurrencyId: 110,
|
34
|
+
# Guid: "b9f21e05-07fe-4d9d-b460-a09db4c3caa9", LastModifiedOn: "/Date(1559778437146)/" },
|
35
|
+
# Comments: nil, PostalAddress: nil, DeliveryAddress: { AddressType: nil,
|
36
|
+
# AddressName: nil, StreetAddress: nil, StreetAddress2: nil, Suburb: nil, City: nil,
|
37
|
+
# Region: nil, Country: nil, PostalCode: nil, IsDefault: false },
|
38
|
+
# DeliveryInstruction: "Handle with care.", SubTotal: 25.0, TaxTotal: 5.0, Total: 30.0,
|
39
|
+
# BCSubTotal: 25.27, BCTaxTotal: 5.05, BCTotal: 30.32, CreatedBy: "james@JamesInc.com",
|
40
|
+
# PaymentTerm: "20th Month following", InvoiceLines: [ { LineNumber: 1, LineType: nil,
|
41
|
+
# Product: { Guid: "23280680-a2bd-4873-a390-501e0f3399d1", ProductCode: "NAIL-M",
|
42
|
+
# ProductDescription: "Medium Nails" }, OrderQuantity: 1.0, InvoiceQuantity: 1.0,
|
43
|
+
# UnitPrice: 25.0, DiscountRate: 0.0, LineTotal: 25.0, Comments: "", TaxRate: 0.2,
|
44
|
+
# LineTax: 5.0, BCUnitPrice: 25.2729, SerialNumbers: nil, BatchNumbers: nil,
|
45
|
+
# Guid: "866e295f-76fb-49e7-9407-b2ed4e0a5d0d", LastModifiedOn: "/Date(1565058457156)/" } ],
|
46
|
+
# Guid: "10a1571d-8c5a-4e5e-bbba-bc3215a27e17", LastModifiedOn: "/Date(1565058457161)/" },
|
47
|
+
# { InvoiceNumber: "SI-136", OrderNumber: "SO-136", QuoteNumber: nil,
|
48
|
+
# InvoiceDate: "/Date(1565058268231)/", DueDate: "/Date(1568937600000)/",
|
49
|
+
# InvoiceStatus: "Completed", Customer: { CustomerCode: "WADE",
|
50
|
+
# CustomerName: "Wade's Apparel & Accessories", CurrencyId: 110,
|
51
|
+
# Guid: "b9f21e05-07fe-4d9d-b460-a09db4c3caa9", LastModifiedOn: "/Date(1559778437146)/" },
|
52
|
+
# Comments: nil, PostalAddress: nil, DeliveryAddress: { AddressType: nil,
|
53
|
+
# AddressName: nil, StreetAddress: nil, StreetAddress2: nil, Suburb: nil, City: nil,
|
54
|
+
# Region: nil, Country: nil, PostalCode: nil, IsDefault: false },
|
55
|
+
# DeliveryInstruction: nil, SubTotal: 25.0, TaxTotal: 5.0, Total: 30.0,
|
56
|
+
# BCSubTotal: 25.27, BCTaxTotal: 5.05, BCTotal: 30.32, CreatedBy: "james@JamesInc.com",
|
57
|
+
# PaymentTerm: "20th Month following", InvoiceLines: [ { LineNumber: 1, LineType: nil,
|
58
|
+
# Product: { Guid: "23280680-a2bd-4873-a390-501e0f3399d1", ProductCode: "NAIL-M",
|
59
|
+
# ProductDescription: "Medium Nails" }, OrderQuantity: 1.0, InvoiceQuantity: 1.0,
|
60
|
+
# UnitPrice: 25.0, DiscountRate: 0.0, LineTotal: 25.0, Comments: "", TaxRate: 0.2,
|
61
|
+
# LineTax: 5.0, BCUnitPrice: 25.2729, SerialNumbers: nil, BatchNumbers: nil,
|
62
|
+
# Guid: "2b994962-e446-4b18-b8c7-5f445adde8cc", LastModifiedOn: "/Date(1565058268757)/" } ],
|
63
|
+
# Guid: "5cc41e1e-468f-4c01-beb9-a077fc06df46", LastModifiedOn: "/Date(1565058268764)/" } ] }
|
64
|
+
def all(options = { Page: 1, PageSize: 200 })
|
65
|
+
endpoint = 'Invoices'
|
66
|
+
params = options.dup
|
67
|
+
|
68
|
+
# Handle Page option
|
69
|
+
if params[:Page].present?
|
70
|
+
endpoint << "/#{params[:Page]}"
|
71
|
+
params.delete :Page
|
72
|
+
end
|
73
|
+
|
74
|
+
response = JSON.parse(@client.get(endpoint, params).body)
|
23
75
|
invoices = response.key?('Items') ? response['Items'] : []
|
24
76
|
invoices.map { |attributes| Unleashed::Invoice.new(@client, attributes) }
|
25
77
|
end
|
@@ -11,13 +11,28 @@ module Unleashed
|
|
11
11
|
# List all payment_terms
|
12
12
|
# /PaymentTerms - also returns the first 200 payment_terms because page number 1 is the default.
|
13
13
|
#
|
14
|
-
# @
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
|
20
|
-
|
14
|
+
# @return [Array<Unleashed::PaymentTerm>] List all payment terms.
|
15
|
+
# {
|
16
|
+
# "Items": [
|
17
|
+
# {
|
18
|
+
# "Guid": "6223b37e-2ee4-41ed-a215-5f14c53e8f7f",
|
19
|
+
# "Type": "DaysOfTheMonthFollowing",
|
20
|
+
# "Days": 20,
|
21
|
+
# "Obsolete": false,
|
22
|
+
# "PaymentTermDescription": "20th Month following"
|
23
|
+
# },
|
24
|
+
# {
|
25
|
+
# "Guid": "6488bee4-ea4c-4a25-ba1b-a86965120e34",
|
26
|
+
# "Type": "DaysOfTheMonthFollowing",
|
27
|
+
# "Days": 25,
|
28
|
+
# "Obsolete": false,
|
29
|
+
# "PaymentTermDescription": "25th Month following"
|
30
|
+
# }
|
31
|
+
# ]
|
32
|
+
# }
|
33
|
+
def all
|
34
|
+
endpoint = 'PaymentTerms'
|
35
|
+
response = JSON.parse(@client.get(endpoint).body)
|
21
36
|
payment_terms = response.key?('Items') ? response['Items'] : []
|
22
37
|
payment_terms.map { |attributes| Unleashed::PaymentTerm.new(@client, attributes) }
|
23
38
|
end
|
@@ -35,16 +50,5 @@ module Unleashed
|
|
35
50
|
def last
|
36
51
|
all.last
|
37
52
|
end
|
38
|
-
|
39
|
-
# Create a new payment_term
|
40
|
-
#
|
41
|
-
# @param attributes [Hash] PaymentTerm's attributes.
|
42
|
-
#
|
43
|
-
# @return [Unleashed::PaymentTerm]
|
44
|
-
def create(attributes)
|
45
|
-
id = attributes[:Guid].present? ? attributes[:Guid] : ''
|
46
|
-
response = JSON.parse(@client.post("PaymentTerms/#{id}", attributes).body)
|
47
|
-
Unleashed::PaymentTerm.new(@client, response)
|
48
|
-
end
|
49
53
|
end
|
50
54
|
end
|
data/lib/unleashed/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unleashed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nhan Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|