simplify 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/simplify.rb +2 -0
- data/lib/simplify/accesstoken.rb +111 -0
- data/lib/simplify/authentication.rb +64 -0
- data/lib/simplify/cardtoken.rb +32 -30
- data/lib/simplify/chargeback.rb +33 -32
- data/lib/simplify/constants.rb +8 -4
- data/lib/simplify/coupon.rb +42 -48
- data/lib/simplify/customer.rb +43 -48
- data/lib/simplify/deposit.rb +32 -31
- data/lib/simplify/event.rb +5 -13
- data/lib/simplify/invoice.rb +34 -33
- data/lib/simplify/invoiceitem.rb +42 -48
- data/lib/simplify/payment.rb +41 -46
- data/lib/simplify/paymentsapi.rb +158 -26
- data/lib/simplify/plan.rb +42 -48
- data/lib/simplify/refund.rb +41 -46
- data/lib/simplify/subscription.rb +42 -48
- data/lib/simplify/webhook.rb +42 -48
- metadata +70 -65
data/lib/simplify/customer.rb
CHANGED
@@ -33,12 +33,28 @@ module Simplify
|
|
33
33
|
#
|
34
34
|
class Customer < Hash
|
35
35
|
|
36
|
-
#
|
37
|
-
attr_accessor :
|
36
|
+
# Authentication object used to access the API (See Simplify::Authentication for details)
|
37
|
+
attr_accessor :authentication
|
38
38
|
|
39
|
-
#
|
40
|
-
|
39
|
+
# Returns the public key used when accessing this object. <b>Deprecated: please use 'authentication' instead.</b>
|
40
|
+
def public_key
|
41
|
+
return self.authentication.public_key
|
42
|
+
end
|
41
43
|
|
44
|
+
# Sets the public key used when accessing this object. <b>Deprecated: please use 'authentication' instead.</b>
|
45
|
+
def public_key=(k)
|
46
|
+
return self.authentication.public_key = k
|
47
|
+
end
|
48
|
+
|
49
|
+
# Returns the private key used when accessing this object. <b>Deprecated: please use 'authentication' instead.</b>
|
50
|
+
def private_key
|
51
|
+
return self.authentication.private_key
|
52
|
+
end
|
53
|
+
|
54
|
+
# Sets the private key used when accessing this object. <b>Deprecated: please use 'authentication' instead.</b>
|
55
|
+
def private_key=(k)
|
56
|
+
return self.authentication.private_key = k
|
57
|
+
end
|
42
58
|
|
43
59
|
|
44
60
|
# Creates an Customer object
|
@@ -66,28 +82,22 @@ class Customer < Hash
|
|
66
82
|
# * <code>subscriptions => name</code> Name describing subscription
|
67
83
|
# * <code>subscriptions => plan</code> The plan ID that the subscription should be created from.
|
68
84
|
# * <code>subscriptions => quantity</code> Quantity of the plan for the subscription.
|
69
|
-
#
|
70
|
-
#
|
85
|
+
# * <code>token</code> If specified, card associated with card token will be used
|
86
|
+
# auth:: Authentication information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object.
|
71
87
|
# Returns a Customer object.
|
72
|
-
def self.create(parms,
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
if private_key == nil then
|
77
|
-
private_key = Simplify::private_key
|
78
|
-
end
|
79
|
-
|
80
|
-
h = Simplify::PaymentsApi.execute("customer", 'create', parms, public_key, private_key)
|
88
|
+
def self.create(parms, *auth)
|
89
|
+
|
90
|
+
auth_obj = Simplify::PaymentsApi.create_auth_object(auth)
|
91
|
+
h = Simplify::PaymentsApi.execute("customer", 'create', parms, auth_obj)
|
81
92
|
obj = Customer.new()
|
82
|
-
obj.
|
83
|
-
obj
|
84
|
-
obj = obj.merge(h)
|
93
|
+
obj.authentication = auth_obj
|
94
|
+
obj = obj.merge!(h)
|
85
95
|
obj
|
86
96
|
end
|
87
97
|
|
88
98
|
# Delete this object
|
89
99
|
def delete()
|
90
|
-
h = Simplify::PaymentsApi.execute("customer", 'delete', self, self.
|
100
|
+
h = Simplify::PaymentsApi.execute("customer", 'delete', self, self.authentication)
|
91
101
|
self.merge!(h)
|
92
102
|
self
|
93
103
|
end
|
@@ -98,24 +108,16 @@ class Customer < Hash
|
|
98
108
|
# * <code>max</code> Allows up to a max of 50 list items to return. <b>default:20</b>
|
99
109
|
# * <code>offset</code> Used in paging of the list. This is the start offset of the page. <b>default:0</b>
|
100
110
|
# * <code>sorting</code> Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <code>asc</code> for ascending or <code>desc</code> for descending). Sortable properties are: <code> dateCreated</code><code> id</code><code> name</code><code> email</code><code> reference</code>.
|
101
|
-
#
|
102
|
-
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
111
|
+
# auth:: Authentication information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object.
|
103
112
|
# Returns an object where the <code>list</code> property contains the list of Customer objects and the <code>total</code>
|
104
113
|
# property contains the total number of Customer objects available for the given criteria.
|
105
|
-
def self.list(criteria = nil,
|
114
|
+
def self.list(criteria = nil, *auth)
|
106
115
|
|
107
|
-
|
108
|
-
|
109
|
-
end
|
110
|
-
if private_key == nil then
|
111
|
-
private_key = Simplify::private_key
|
112
|
-
end
|
113
|
-
|
114
|
-
h = Simplify::PaymentsApi.execute("customer", 'list', criteria, public_key, private_key)
|
116
|
+
auth_obj = Simplify::PaymentsApi.create_auth_object(auth)
|
117
|
+
h = Simplify::PaymentsApi.execute("customer", 'list', criteria, auth_obj)
|
115
118
|
obj = Customer.new()
|
116
|
-
obj.
|
117
|
-
obj
|
118
|
-
obj = obj.merge(h)
|
119
|
+
obj.authentication = auth_obj
|
120
|
+
obj = obj.merge!(h)
|
119
121
|
obj
|
120
122
|
|
121
123
|
end
|
@@ -123,22 +125,15 @@ class Customer < Hash
|
|
123
125
|
# Retrieve a Customer object from the API
|
124
126
|
#
|
125
127
|
# id:: ID of object to retrieve
|
126
|
-
#
|
127
|
-
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
128
|
+
# auth:: Authentication information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object.
|
128
129
|
# Returns a Customer object.
|
129
|
-
def self.find(id,
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
if private_key == nil then
|
134
|
-
private_key = Simplify::private_key
|
135
|
-
end
|
136
|
-
|
137
|
-
h = Simplify::PaymentsApi.execute("customer", 'show', {"id" => id}, public_key, private_key)
|
130
|
+
def self.find(id, *auth)
|
131
|
+
|
132
|
+
auth_obj = Simplify::PaymentsApi.create_auth_object(auth)
|
133
|
+
h = Simplify::PaymentsApi.execute("customer", 'show', {"id" => id}, auth_obj)
|
138
134
|
obj = Customer.new()
|
139
|
-
obj.
|
140
|
-
obj
|
141
|
-
obj = obj.merge(h)
|
135
|
+
obj.authentication = auth_obj
|
136
|
+
obj = obj.merge!(h)
|
142
137
|
obj
|
143
138
|
end
|
144
139
|
|
@@ -160,7 +155,7 @@ class Customer < Hash
|
|
160
155
|
# * <code>name</code> Customer name <b>(required)</b>
|
161
156
|
# * <code>reference</code> Reference field for external applications use.
|
162
157
|
def update()
|
163
|
-
h = Simplify::PaymentsApi.execute("customer", 'update', self, self.
|
158
|
+
h = Simplify::PaymentsApi.execute("customer", 'update', self, self.authentication)
|
164
159
|
self.merge!(h)
|
165
160
|
self
|
166
161
|
end
|
data/lib/simplify/deposit.rb
CHANGED
@@ -33,12 +33,28 @@ module Simplify
|
|
33
33
|
#
|
34
34
|
class Deposit < Hash
|
35
35
|
|
36
|
-
#
|
37
|
-
attr_accessor :
|
36
|
+
# Authentication object used to access the API (See Simplify::Authentication for details)
|
37
|
+
attr_accessor :authentication
|
38
38
|
|
39
|
-
#
|
40
|
-
|
39
|
+
# Returns the public key used when accessing this object. <b>Deprecated: please use 'authentication' instead.</b>
|
40
|
+
def public_key
|
41
|
+
return self.authentication.public_key
|
42
|
+
end
|
41
43
|
|
44
|
+
# Sets the public key used when accessing this object. <b>Deprecated: please use 'authentication' instead.</b>
|
45
|
+
def public_key=(k)
|
46
|
+
return self.authentication.public_key = k
|
47
|
+
end
|
48
|
+
|
49
|
+
# Returns the private key used when accessing this object. <b>Deprecated: please use 'authentication' instead.</b>
|
50
|
+
def private_key
|
51
|
+
return self.authentication.private_key
|
52
|
+
end
|
53
|
+
|
54
|
+
# Sets the private key used when accessing this object. <b>Deprecated: please use 'authentication' instead.</b>
|
55
|
+
def private_key=(k)
|
56
|
+
return self.authentication.private_key = k
|
57
|
+
end
|
42
58
|
|
43
59
|
|
44
60
|
# Retrieve Deposit objects.
|
@@ -47,24 +63,16 @@ class Deposit < Hash
|
|
47
63
|
# * <code>max</code> Allows up to a max of 50 list items to return. <b>default:20</b>
|
48
64
|
# * <code>offset</code> Used in paging of the list. This is the start offset of the page. <b>default:0</b>
|
49
65
|
# * <code>sorting</code> Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <code>asc</code> for ascending or <code>desc</code> for descending). Sortable properties are: <code> amount</code><code> dateCreated</code><code> depositDate</code>.
|
50
|
-
#
|
51
|
-
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
66
|
+
# auth:: Authentication information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object.
|
52
67
|
# Returns an object where the <code>list</code> property contains the list of Deposit objects and the <code>total</code>
|
53
68
|
# property contains the total number of Deposit objects available for the given criteria.
|
54
|
-
def self.list(criteria = nil,
|
55
|
-
|
56
|
-
if public_key == nil then
|
57
|
-
public_key = Simplify::public_key
|
58
|
-
end
|
59
|
-
if private_key == nil then
|
60
|
-
private_key = Simplify::private_key
|
61
|
-
end
|
69
|
+
def self.list(criteria = nil, *auth)
|
62
70
|
|
63
|
-
|
71
|
+
auth_obj = Simplify::PaymentsApi.create_auth_object(auth)
|
72
|
+
h = Simplify::PaymentsApi.execute("deposit", 'list', criteria, auth_obj)
|
64
73
|
obj = Deposit.new()
|
65
|
-
obj.
|
66
|
-
obj
|
67
|
-
obj = obj.merge(h)
|
74
|
+
obj.authentication = auth_obj
|
75
|
+
obj = obj.merge!(h)
|
68
76
|
obj
|
69
77
|
|
70
78
|
end
|
@@ -72,22 +80,15 @@ class Deposit < Hash
|
|
72
80
|
# Retrieve a Deposit object from the API
|
73
81
|
#
|
74
82
|
# id:: ID of object to retrieve
|
75
|
-
#
|
76
|
-
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
83
|
+
# auth:: Authentication information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object.
|
77
84
|
# Returns a Deposit object.
|
78
|
-
def self.find(id,
|
79
|
-
if public_key == nil then
|
80
|
-
public_key = Simplify::public_key
|
81
|
-
end
|
82
|
-
if private_key == nil then
|
83
|
-
private_key = Simplify::private_key
|
84
|
-
end
|
85
|
+
def self.find(id, *auth)
|
85
86
|
|
86
|
-
|
87
|
+
auth_obj = Simplify::PaymentsApi.create_auth_object(auth)
|
88
|
+
h = Simplify::PaymentsApi.execute("deposit", 'show', {"id" => id}, auth_obj)
|
87
89
|
obj = Deposit.new()
|
88
|
-
obj.
|
89
|
-
obj
|
90
|
-
obj = obj.merge(h)
|
90
|
+
obj.authentication = auth_obj
|
91
|
+
obj = obj.merge!(h)
|
91
92
|
obj
|
92
93
|
end
|
93
94
|
|
data/lib/simplify/event.rb
CHANGED
@@ -37,26 +37,18 @@ class Event < Hash
|
|
37
37
|
# params:: a hash of parameters; valid keys are:
|
38
38
|
# * <code>payload</code> The raw JWS message payload. <b>required</b>
|
39
39
|
# * <code>url</code> The URL for the webhook. If present it must match the URL registered for the webhook.
|
40
|
-
#
|
41
|
-
#
|
42
|
-
|
43
|
-
def self.create(params, public_key = nil, private_key = nil)
|
44
|
-
|
45
|
-
if public_key == nil then
|
46
|
-
public_key = Simplify::public_key
|
47
|
-
end
|
48
|
-
if private_key == nil then
|
49
|
-
private_key = Simplify::private_key
|
50
|
-
end
|
40
|
+
# auth:: Authentication information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object.
|
41
|
+
#
|
42
|
+
def self.create(params, *auth)
|
51
43
|
|
52
|
-
h = Simplify::PaymentsApi.jws_decode(params,
|
44
|
+
h = Simplify::PaymentsApi.jws_decode(params, Simplify::PaymentsApi.create_auth_object(auth))
|
53
45
|
|
54
46
|
if !h['event']
|
55
47
|
raise ApiException.new("Incorrect data in webhook event", nil, nil)
|
56
48
|
end
|
57
49
|
|
58
50
|
obj = Event.new()
|
59
|
-
obj = obj.merge(h['event'])
|
51
|
+
obj = obj.merge!(h['event'])
|
60
52
|
|
61
53
|
obj
|
62
54
|
end
|
data/lib/simplify/invoice.rb
CHANGED
@@ -33,12 +33,28 @@ module Simplify
|
|
33
33
|
#
|
34
34
|
class Invoice < Hash
|
35
35
|
|
36
|
-
#
|
37
|
-
attr_accessor :
|
36
|
+
# Authentication object used to access the API (See Simplify::Authentication for details)
|
37
|
+
attr_accessor :authentication
|
38
38
|
|
39
|
-
#
|
40
|
-
|
39
|
+
# Returns the public key used when accessing this object. <b>Deprecated: please use 'authentication' instead.</b>
|
40
|
+
def public_key
|
41
|
+
return self.authentication.public_key
|
42
|
+
end
|
43
|
+
|
44
|
+
# Sets the public key used when accessing this object. <b>Deprecated: please use 'authentication' instead.</b>
|
45
|
+
def public_key=(k)
|
46
|
+
return self.authentication.public_key = k
|
47
|
+
end
|
48
|
+
|
49
|
+
# Returns the private key used when accessing this object. <b>Deprecated: please use 'authentication' instead.</b>
|
50
|
+
def private_key
|
51
|
+
return self.authentication.private_key
|
52
|
+
end
|
41
53
|
|
54
|
+
# Sets the private key used when accessing this object. <b>Deprecated: please use 'authentication' instead.</b>
|
55
|
+
def private_key=(k)
|
56
|
+
return self.authentication.private_key = k
|
57
|
+
end
|
42
58
|
|
43
59
|
|
44
60
|
# Retrieve Invoice objects.
|
@@ -47,24 +63,16 @@ class Invoice < Hash
|
|
47
63
|
# * <code>max</code> Allows up to a max of 50 list items to return. <b>default:20</b>
|
48
64
|
# * <code>offset</code> Used in paging of the list. This is the start offset of the page. <b>default:0</b>
|
49
65
|
# * <code>sorting</code> Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <code>asc</code> for ascending or <code>desc</code> for descending). Sortable properties are: <code> id</code><code> invoiceDate</code><code> customer</code><code> amount</code><code> processedDate</code>.
|
50
|
-
#
|
51
|
-
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
66
|
+
# auth:: Authentication information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object.
|
52
67
|
# Returns an object where the <code>list</code> property contains the list of Invoice objects and the <code>total</code>
|
53
68
|
# property contains the total number of Invoice objects available for the given criteria.
|
54
|
-
def self.list(criteria = nil,
|
69
|
+
def self.list(criteria = nil, *auth)
|
55
70
|
|
56
|
-
|
57
|
-
|
58
|
-
end
|
59
|
-
if private_key == nil then
|
60
|
-
private_key = Simplify::private_key
|
61
|
-
end
|
62
|
-
|
63
|
-
h = Simplify::PaymentsApi.execute("invoice", 'list', criteria, public_key, private_key)
|
71
|
+
auth_obj = Simplify::PaymentsApi.create_auth_object(auth)
|
72
|
+
h = Simplify::PaymentsApi.execute("invoice", 'list', criteria, auth_obj)
|
64
73
|
obj = Invoice.new()
|
65
|
-
obj.
|
66
|
-
obj
|
67
|
-
obj = obj.merge(h)
|
74
|
+
obj.authentication = auth_obj
|
75
|
+
obj = obj.merge!(h)
|
68
76
|
obj
|
69
77
|
|
70
78
|
end
|
@@ -72,22 +80,15 @@ class Invoice < Hash
|
|
72
80
|
# Retrieve a Invoice object from the API
|
73
81
|
#
|
74
82
|
# id:: ID of object to retrieve
|
75
|
-
#
|
76
|
-
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
83
|
+
# auth:: Authentication information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object.
|
77
84
|
# Returns a Invoice object.
|
78
|
-
def self.find(id,
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
if private_key == nil then
|
83
|
-
private_key = Simplify::private_key
|
84
|
-
end
|
85
|
-
|
86
|
-
h = Simplify::PaymentsApi.execute("invoice", 'show', {"id" => id}, public_key, private_key)
|
85
|
+
def self.find(id, *auth)
|
86
|
+
|
87
|
+
auth_obj = Simplify::PaymentsApi.create_auth_object(auth)
|
88
|
+
h = Simplify::PaymentsApi.execute("invoice", 'show', {"id" => id}, auth_obj)
|
87
89
|
obj = Invoice.new()
|
88
|
-
obj.
|
89
|
-
obj
|
90
|
-
obj = obj.merge(h)
|
90
|
+
obj.authentication = auth_obj
|
91
|
+
obj = obj.merge!(h)
|
91
92
|
obj
|
92
93
|
end
|
93
94
|
|
@@ -96,7 +97,7 @@ class Invoice < Hash
|
|
96
97
|
# The properties that can be updated:
|
97
98
|
# * <code>status</code> Status of the invoice. Examples: OPEN = Invoice has not been processed and can have invoice items added to it. PAID = Invoice has been paid. UNPAID = Invoice was not paid when the card was processed. System will try up to 5 times to process the card. <b>(required)</b>
|
98
99
|
def update()
|
99
|
-
h = Simplify::PaymentsApi.execute("invoice", 'update', self, self.
|
100
|
+
h = Simplify::PaymentsApi.execute("invoice", 'update', self, self.authentication)
|
100
101
|
self.merge!(h)
|
101
102
|
self
|
102
103
|
end
|
data/lib/simplify/invoiceitem.rb
CHANGED
@@ -33,12 +33,28 @@ module Simplify
|
|
33
33
|
#
|
34
34
|
class InvoiceItem < Hash
|
35
35
|
|
36
|
-
#
|
37
|
-
attr_accessor :
|
36
|
+
# Authentication object used to access the API (See Simplify::Authentication for details)
|
37
|
+
attr_accessor :authentication
|
38
38
|
|
39
|
-
#
|
40
|
-
|
39
|
+
# Returns the public key used when accessing this object. <b>Deprecated: please use 'authentication' instead.</b>
|
40
|
+
def public_key
|
41
|
+
return self.authentication.public_key
|
42
|
+
end
|
41
43
|
|
44
|
+
# Sets the public key used when accessing this object. <b>Deprecated: please use 'authentication' instead.</b>
|
45
|
+
def public_key=(k)
|
46
|
+
return self.authentication.public_key = k
|
47
|
+
end
|
48
|
+
|
49
|
+
# Returns the private key used when accessing this object. <b>Deprecated: please use 'authentication' instead.</b>
|
50
|
+
def private_key
|
51
|
+
return self.authentication.private_key
|
52
|
+
end
|
53
|
+
|
54
|
+
# Sets the private key used when accessing this object. <b>Deprecated: please use 'authentication' instead.</b>
|
55
|
+
def private_key=(k)
|
56
|
+
return self.authentication.private_key = k
|
57
|
+
end
|
42
58
|
|
43
59
|
|
44
60
|
# Creates an InvoiceItem object
|
@@ -48,28 +64,21 @@ class InvoiceItem < Hash
|
|
48
64
|
# * <code>currency</code> Currency code (ISO-4217) for the invoice item. Must match the currency associated with your account. <b>required </b><b>default:USD</b>
|
49
65
|
# * <code>description</code> Individual items of an invoice
|
50
66
|
# * <code>invoice</code> Description of the invoice item <b>required </b>
|
51
|
-
#
|
52
|
-
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
67
|
+
# auth:: Authentication information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object.
|
53
68
|
# Returns a InvoiceItem object.
|
54
|
-
def self.create(parms,
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
if private_key == nil then
|
59
|
-
private_key = Simplify::private_key
|
60
|
-
end
|
61
|
-
|
62
|
-
h = Simplify::PaymentsApi.execute("invoiceItem", 'create', parms, public_key, private_key)
|
69
|
+
def self.create(parms, *auth)
|
70
|
+
|
71
|
+
auth_obj = Simplify::PaymentsApi.create_auth_object(auth)
|
72
|
+
h = Simplify::PaymentsApi.execute("invoiceItem", 'create', parms, auth_obj)
|
63
73
|
obj = InvoiceItem.new()
|
64
|
-
obj.
|
65
|
-
obj
|
66
|
-
obj = obj.merge(h)
|
74
|
+
obj.authentication = auth_obj
|
75
|
+
obj = obj.merge!(h)
|
67
76
|
obj
|
68
77
|
end
|
69
78
|
|
70
79
|
# Delete this object
|
71
80
|
def delete()
|
72
|
-
h = Simplify::PaymentsApi.execute("invoiceItem", 'delete', self, self.
|
81
|
+
h = Simplify::PaymentsApi.execute("invoiceItem", 'delete', self, self.authentication)
|
73
82
|
self.merge!(h)
|
74
83
|
self
|
75
84
|
end
|
@@ -80,24 +89,16 @@ class InvoiceItem < Hash
|
|
80
89
|
# * <code>max</code> Allows up to a max of 50 list items to return. <b>default:20</b>
|
81
90
|
# * <code>offset</code> Used in paging of the list. This is the start offset of the page. <b>default:0</b>
|
82
91
|
# * <code>sorting</code> Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <code>asc</code> for ascending or <code>desc</code> for descending). Sortable properties are: <code> id</code><code> amount</code><code> description</code><code> invoice</code>.
|
83
|
-
#
|
84
|
-
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
92
|
+
# auth:: Authentication information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object.
|
85
93
|
# Returns an object where the <code>list</code> property contains the list of InvoiceItem objects and the <code>total</code>
|
86
94
|
# property contains the total number of InvoiceItem objects available for the given criteria.
|
87
|
-
def self.list(criteria = nil,
|
95
|
+
def self.list(criteria = nil, *auth)
|
88
96
|
|
89
|
-
|
90
|
-
|
91
|
-
end
|
92
|
-
if private_key == nil then
|
93
|
-
private_key = Simplify::private_key
|
94
|
-
end
|
95
|
-
|
96
|
-
h = Simplify::PaymentsApi.execute("invoiceItem", 'list', criteria, public_key, private_key)
|
97
|
+
auth_obj = Simplify::PaymentsApi.create_auth_object(auth)
|
98
|
+
h = Simplify::PaymentsApi.execute("invoiceItem", 'list', criteria, auth_obj)
|
97
99
|
obj = InvoiceItem.new()
|
98
|
-
obj.
|
99
|
-
obj
|
100
|
-
obj = obj.merge(h)
|
100
|
+
obj.authentication = auth_obj
|
101
|
+
obj = obj.merge!(h)
|
101
102
|
obj
|
102
103
|
|
103
104
|
end
|
@@ -105,22 +106,15 @@ class InvoiceItem < Hash
|
|
105
106
|
# Retrieve a InvoiceItem object from the API
|
106
107
|
#
|
107
108
|
# id:: ID of object to retrieve
|
108
|
-
#
|
109
|
-
# private_key:: Private key to use for the API call. If nil, the value of Simplify::private_key will be used.
|
109
|
+
# auth:: Authentication information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. For backwards compatibility the public and private keys may be passed instead of the authentication object.
|
110
110
|
# Returns a InvoiceItem object.
|
111
|
-
def self.find(id,
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
if private_key == nil then
|
116
|
-
private_key = Simplify::private_key
|
117
|
-
end
|
118
|
-
|
119
|
-
h = Simplify::PaymentsApi.execute("invoiceItem", 'show', {"id" => id}, public_key, private_key)
|
111
|
+
def self.find(id, *auth)
|
112
|
+
|
113
|
+
auth_obj = Simplify::PaymentsApi.create_auth_object(auth)
|
114
|
+
h = Simplify::PaymentsApi.execute("invoiceItem", 'show', {"id" => id}, auth_obj)
|
120
115
|
obj = InvoiceItem.new()
|
121
|
-
obj.
|
122
|
-
obj
|
123
|
-
obj = obj.merge(h)
|
116
|
+
obj.authentication = auth_obj
|
117
|
+
obj = obj.merge!(h)
|
124
118
|
obj
|
125
119
|
end
|
126
120
|
|
@@ -131,7 +125,7 @@ class InvoiceItem < Hash
|
|
131
125
|
# * <code>currency</code> Currency code (ISO-4217) for the invoice item. Must match the currency associated with your account.
|
132
126
|
# * <code>description</code> Individual items of an invoice
|
133
127
|
def update()
|
134
|
-
h = Simplify::PaymentsApi.execute("invoiceItem", 'update', self, self.
|
128
|
+
h = Simplify::PaymentsApi.execute("invoiceItem", 'update', self, self.authentication)
|
135
129
|
self.merge!(h)
|
136
130
|
self
|
137
131
|
end
|