promisepay 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,26 +1,26 @@
1
- module Promisepay
2
- # Manage Card accounts
3
- class CardAccount < Account
4
- # Get the user the card account belongs to.
5
- #
6
- # @see http://docs.promisepay.com/v2.2/docs/card_accountsidusers
7
- #
8
- # @return [Promisepay::User]
9
- def user
10
- response = JSON.parse(@client.get("card_accounts/#{send(:id)}/users").body)
11
- Promisepay::User.new(@client, response['users'])
12
- end
13
-
14
- # Deletes a card account for a user on a marketplace.
15
- # Sets the account to in-active.
16
- #
17
- # @see http://docs.promisepay.com/v2.2/docs/card_accountsid
18
- #
19
- # @return [Boolean]
20
- def deactivate
21
- @client.delete("card_accounts/#{id}")
22
- @attributes['active'] = false
23
- true
24
- end
25
- end
26
- end
1
+ module Promisepay
2
+ # Manage Card accounts
3
+ class CardAccount < Account
4
+ # Get the user the card account belongs to.
5
+ #
6
+ # @see http://docs.promisepay.com/v2.2/docs/card_accountsidusers
7
+ #
8
+ # @return [Promisepay::User]
9
+ def user
10
+ response = JSON.parse(@client.get("card_accounts/#{send(:id)}/users").body)
11
+ Promisepay::User.new(@client, response['users'])
12
+ end
13
+
14
+ # Deletes a card account for a user on a marketplace.
15
+ # Sets the account to in-active.
16
+ #
17
+ # @see http://docs.promisepay.com/v2.2/docs/card_accountsid
18
+ #
19
+ # @return [Boolean]
20
+ def deactivate
21
+ @client.delete("card_accounts/#{id}")
22
+ @attributes['active'] = false
23
+ true
24
+ end
25
+ end
26
+ end
@@ -1,5 +1,5 @@
1
- module Promisepay
2
- # Manage Fees
3
- class Fee < BaseModel
4
- end
5
- end
1
+ module Promisepay
2
+ # Manage Fees
3
+ class Fee < BaseModel
4
+ end
5
+ end
@@ -1,197 +1,197 @@
1
- module Promisepay
2
- # Manage Items
3
- class Item < BaseModel
4
- # Update the attributes of an item.
5
- #
6
- # @see http://docs.promisepay.com/v2.2/docs/itemsiduseraction
7
- #
8
- # @param attributes [Hash] Item's attributes to be updated.
9
- #
10
- # @return [self]
11
- def update(attributes)
12
- response = JSON.parse(@client.patch("items/#{send(:id)}", attributes).body)
13
- @attributes = response['items']
14
- self
15
- end
16
-
17
- # Show the item status for a marketplace.
18
- #
19
- # @see http://docs.promisepay.com/v2.2/docs/itemsidstatus
20
- #
21
- # @return [Hash]
22
- def status
23
- response = JSON.parse(@client.get("items/#{send(:id)}/status").body)
24
- response['items']
25
- end
26
-
27
- # Show the buyer detail for a single item for a marketplace.
28
- #
29
- # @see http://docs.promisepay.com/v2.2/docs/itemsidbuyers
30
- #
31
- # @return [Promisepay::User]
32
- def buyer
33
- response = JSON.parse(@client.get("items/#{send(:id)}/buyers").body)
34
- Promisepay::User.new(@client, response['users'])
35
- end
36
-
37
- # Show the seller detail for a single item for a marketplace.
38
- #
39
- # @see http://docs.promisepay.com/v2.2/docs/itemsidbuyers
40
- #
41
- # @return [Promisepay::User]
42
- def seller
43
- response = JSON.parse(@client.get("items/#{send(:id)}/sellers").body)
44
- Promisepay::User.new(@client, response['users'])
45
- end
46
-
47
- # Get fees associated to the item.
48
- #
49
- # @see http://docs.promisepay.com/v2.2/docs/itemsidfees
50
- #
51
- # @param options [Hash] Optional options.
52
- # @option options [Integer] :limit Can ask for up to 200 fees. default: 10
53
- # @option options [Integer] :offset Pagination help. default: 0
54
- #
55
- # @return [Array<Promisepay::Fee>]
56
- def fees(options = {})
57
- response = JSON.parse(@client.get("items/#{send(:id)}/fees", options).body)
58
- fees = response.key?('fees') ? response['fees'] : []
59
- fees.map { |attributes| Promisepay::Fee.new(@client, attributes) }
60
- end
61
-
62
- # Get historical transaction for the item.
63
- #
64
- # @see http://docs.promisepay.com/v2.2/docs/itemsidtransactions
65
- #
66
- # @param options [Hash] Optional options.
67
- # @option options [Integer] :limit Can ask for up to 200 transactions. default: 10
68
- # @option options [Integer] :offset Pagination help. default: 0
69
- #
70
- # @return [Array<Promisepay::Transaction>]
71
- def transactions(options = {})
72
- response = JSON.parse(@client.get("items/#{send(:id)}/transactions", options).body)
73
- transactions = response.key?('transactions') ? response['transactions'] : []
74
- transactions.map { |attributes| Promisepay::Transaction.new(@client, attributes) }
75
- end
76
-
77
- # Show the wire details for payment.
78
- #
79
- # @see http://docs.promisepay.com/v2.2/docs/itemsidwire_details
80
- #
81
- # @return [Hash]
82
- def wire_details
83
- response = JSON.parse(@client.get("items/#{send(:id)}/wire_details").body)
84
- response['items']['wire_details']
85
- end
86
-
87
- # Show the bpay details details for payment.
88
- #
89
- # @see http://docs.promisepay.com/v2.2/docs/itemsidbpay_details
90
- #
91
- # @return [Hash]
92
- def bpay_details
93
- response = JSON.parse(@client.get("items/#{send(:id)}/bpay_details").body)
94
- response['items']['bpay_details']
95
- end
96
-
97
- # .
98
- #
99
- # @see http://docs.promisepay.com/v2.2/docs/itemsidaction
100
- #
101
- # @return [Boolean]
102
- def make_payment(options = {})
103
- @client.patch("items/#{send(:id)}/make_payment", options).body
104
- true
105
- end
106
-
107
- # .
108
- #
109
- # @see http://docs.promisepay.com/v2.2/docs/itemsidrequest_payment
110
- #
111
- # @return [Boolean]
112
- def request_payment(options = {})
113
- @client.patch("items/#{send(:id)}/request_payment", options).body
114
- true
115
- end
116
-
117
- # .
118
- #
119
- # @see http://docs.promisepay.com/v2.2/docs/itemsidrequest_payment
120
- #
121
- # @return [Boolean]
122
- def release_payment(options = {})
123
- @client.patch("items/#{send(:id)}/release_payment", options).body
124
- true
125
- end
126
-
127
- # .
128
- #
129
- # @see http://docs.promisepay.com/v2.2/docs/itemsidrequest_release
130
- #
131
- # @return [Boolean]
132
- def request_release(options = {})
133
- @client.patch("items/#{send(:id)}/request_release", options).body
134
- true
135
- end
136
-
137
- # .
138
- #
139
- # @see http://docs.promisepay.com/v2.2/docs/itemsidacknowledge_wire
140
- #
141
- # @return [Boolean]
142
- def acknowledge_wire(options = {})
143
- @client.patch("items/#{send(:id)}/acknowledge_wire", options).body
144
- true
145
- end
146
-
147
- # .
148
- #
149
- # @see http://docs.promisepay.com/v2.2/docs/itemsidacknowledge_paypal
150
- #
151
- # @return [Boolean]
152
- def acknowledge_paypal(options = {})
153
- @client.patch("items/#{send(:id)}/acknowledge_paypal", options).body
154
- true
155
- end
156
-
157
- # .
158
- #
159
- # @see http://docs.promisepay.com/v2.2/docs/itemsidrevert_wire
160
- #
161
- # @return [Boolean]
162
- def revert_wire(options = {})
163
- @client.patch("items/#{send(:id)}/revert_wire", options).body
164
- true
165
- end
166
-
167
- # .
168
- #
169
- # @see http://docs.promisepay.com/v2.2/docs/itemsidrequest_refund
170
- #
171
- # @return [Boolean]
172
- def request_refund(options = {})
173
- @client.patch("items/#{send(:id)}/request_refund", options).body
174
- true
175
- end
176
-
177
- # .
178
- #
179
- # @see http://docs.promisepay.com/v2.2/docs/itemsidrefund
180
- #
181
- # @return [Boolean]
182
- def refund(options = {})
183
- @client.patch("items/#{send(:id)}/refund", options).body
184
- true
185
- end
186
-
187
- # .
188
- #
189
- # @see http://docs.promisepay.com/v2.2/docs/itemsidcancel
190
- #
191
- # @return [Boolean]
192
- def cancel
193
- @client.patch("items/#{id}/cancel")
194
- true
195
- end
196
- end
197
- end
1
+ module Promisepay
2
+ # Manage Items
3
+ class Item < BaseModel
4
+ # Update the attributes of an item.
5
+ #
6
+ # @see http://docs.promisepay.com/v2.2/docs/itemsiduseraction
7
+ #
8
+ # @param attributes [Hash] Item's attributes to be updated.
9
+ #
10
+ # @return [self]
11
+ def update(attributes)
12
+ response = JSON.parse(@client.patch("items/#{send(:id)}", attributes).body)
13
+ @attributes = response['items']
14
+ self
15
+ end
16
+
17
+ # Show the item status for a marketplace.
18
+ #
19
+ # @see http://docs.promisepay.com/v2.2/docs/itemsidstatus
20
+ #
21
+ # @return [Hash]
22
+ def status
23
+ response = JSON.parse(@client.get("items/#{send(:id)}/status").body)
24
+ response['items']
25
+ end
26
+
27
+ # Show the buyer detail for a single item for a marketplace.
28
+ #
29
+ # @see http://docs.promisepay.com/v2.2/docs/itemsidbuyers
30
+ #
31
+ # @return [Promisepay::User]
32
+ def buyer
33
+ response = JSON.parse(@client.get("items/#{send(:id)}/buyers").body)
34
+ Promisepay::User.new(@client, response['users'])
35
+ end
36
+
37
+ # Show the seller detail for a single item for a marketplace.
38
+ #
39
+ # @see http://docs.promisepay.com/v2.2/docs/itemsidbuyers
40
+ #
41
+ # @return [Promisepay::User]
42
+ def seller
43
+ response = JSON.parse(@client.get("items/#{send(:id)}/sellers").body)
44
+ Promisepay::User.new(@client, response['users'])
45
+ end
46
+
47
+ # Get fees associated to the item.
48
+ #
49
+ # @see http://docs.promisepay.com/v2.2/docs/itemsidfees
50
+ #
51
+ # @param options [Hash] Optional options.
52
+ # @option options [Integer] :limit Can ask for up to 200 fees. default: 10
53
+ # @option options [Integer] :offset Pagination help. default: 0
54
+ #
55
+ # @return [Array<Promisepay::Fee>]
56
+ def fees(options = {})
57
+ response = JSON.parse(@client.get("items/#{send(:id)}/fees", options).body)
58
+ fees = response.key?('fees') ? response['fees'] : []
59
+ fees.map { |attributes| Promisepay::Fee.new(@client, attributes) }
60
+ end
61
+
62
+ # Get historical transaction for the item.
63
+ #
64
+ # @see http://docs.promisepay.com/v2.2/docs/itemsidtransactions
65
+ #
66
+ # @param options [Hash] Optional options.
67
+ # @option options [Integer] :limit Can ask for up to 200 transactions. default: 10
68
+ # @option options [Integer] :offset Pagination help. default: 0
69
+ #
70
+ # @return [Array<Promisepay::Transaction>]
71
+ def transactions(options = {})
72
+ response = JSON.parse(@client.get("items/#{send(:id)}/transactions", options).body)
73
+ transactions = response.key?('transactions') ? response['transactions'] : []
74
+ transactions.map { |attributes| Promisepay::Transaction.new(@client, attributes) }
75
+ end
76
+
77
+ # Show the wire details for payment.
78
+ #
79
+ # @see http://docs.promisepay.com/v2.2/docs/itemsidwire_details
80
+ #
81
+ # @return [Hash]
82
+ def wire_details
83
+ response = JSON.parse(@client.get("items/#{send(:id)}/wire_details").body)
84
+ response['items']['wire_details']
85
+ end
86
+
87
+ # Show the bpay details details for payment.
88
+ #
89
+ # @see http://docs.promisepay.com/v2.2/docs/itemsidbpay_details
90
+ #
91
+ # @return [Hash]
92
+ def bpay_details
93
+ response = JSON.parse(@client.get("items/#{send(:id)}/bpay_details").body)
94
+ response['items']['bpay_details']
95
+ end
96
+
97
+ # .
98
+ #
99
+ # @see http://docs.promisepay.com/v2.2/docs/itemsidaction
100
+ #
101
+ # @return [Boolean]
102
+ def make_payment(options = {})
103
+ @client.patch("items/#{send(:id)}/make_payment", options).body
104
+ true
105
+ end
106
+
107
+ # .
108
+ #
109
+ # @see http://docs.promisepay.com/v2.2/docs/itemsidrequest_payment
110
+ #
111
+ # @return [Boolean]
112
+ def request_payment(options = {})
113
+ @client.patch("items/#{send(:id)}/request_payment", options).body
114
+ true
115
+ end
116
+
117
+ # .
118
+ #
119
+ # @see http://docs.promisepay.com/v2.2/docs/itemsidrequest_payment
120
+ #
121
+ # @return [Boolean]
122
+ def release_payment(options = {})
123
+ @client.patch("items/#{send(:id)}/release_payment", options).body
124
+ true
125
+ end
126
+
127
+ # .
128
+ #
129
+ # @see http://docs.promisepay.com/v2.2/docs/itemsidrequest_release
130
+ #
131
+ # @return [Boolean]
132
+ def request_release(options = {})
133
+ @client.patch("items/#{send(:id)}/request_release", options).body
134
+ true
135
+ end
136
+
137
+ # .
138
+ #
139
+ # @see http://docs.promisepay.com/v2.2/docs/itemsidacknowledge_wire
140
+ #
141
+ # @return [Boolean]
142
+ def acknowledge_wire(options = {})
143
+ @client.patch("items/#{send(:id)}/acknowledge_wire", options).body
144
+ true
145
+ end
146
+
147
+ # .
148
+ #
149
+ # @see http://docs.promisepay.com/v2.2/docs/itemsidacknowledge_paypal
150
+ #
151
+ # @return [Boolean]
152
+ def acknowledge_paypal(options = {})
153
+ @client.patch("items/#{send(:id)}/acknowledge_paypal", options).body
154
+ true
155
+ end
156
+
157
+ # .
158
+ #
159
+ # @see http://docs.promisepay.com/v2.2/docs/itemsidrevert_wire
160
+ #
161
+ # @return [Boolean]
162
+ def revert_wire(options = {})
163
+ @client.patch("items/#{send(:id)}/revert_wire", options).body
164
+ true
165
+ end
166
+
167
+ # .
168
+ #
169
+ # @see http://docs.promisepay.com/v2.2/docs/itemsidrequest_refund
170
+ #
171
+ # @return [Boolean]
172
+ def request_refund(options = {})
173
+ @client.patch("items/#{send(:id)}/request_refund", options).body
174
+ true
175
+ end
176
+
177
+ # .
178
+ #
179
+ # @see http://docs.promisepay.com/v2.2/docs/itemsidrefund
180
+ #
181
+ # @return [Boolean]
182
+ def refund(options = {})
183
+ @client.patch("items/#{send(:id)}/refund", options).body
184
+ true
185
+ end
186
+
187
+ # .
188
+ #
189
+ # @see http://docs.promisepay.com/v2.2/docs/itemsidcancel
190
+ #
191
+ # @return [Boolean]
192
+ def cancel
193
+ @client.patch("items/#{id}/cancel")
194
+ true
195
+ end
196
+ end
197
+ end