pr-pin 0.4.0 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +88 -55
- data/lib/pr/pin.rb +8 -0
- data/lib/pr/pin/adapter/commands.rb +3 -0
- data/lib/pr/pin/relations/charges.rb +4 -0
- data/lib/pr/pin/relations/customers.rb +5 -0
- data/lib/pr/pin/relations/ledger.rb +19 -0
- data/lib/pr/pin/relations/refunds.rb +22 -0
- data/lib/pr/pin/relations/subscriptions.rb +2 -2
- data/lib/pr/pin/repositories.rb +2 -1
- data/lib/pr/pin/repositories/charges.rb +31 -1
- data/lib/pr/pin/repositories/customers.rb +28 -1
- data/lib/pr/pin/repositories/ledger.rb +18 -0
- data/lib/pr/pin/repositories/plans.rb +28 -1
- data/lib/pr/pin/repositories/refunds.rb +41 -0
- data/lib/pr/pin/repositories/subscriptions.rb +24 -3
- data/lib/pr/pin/version.rb +1 -1
- metadata +20 -17
- data/lib/pr/pin/repositories/concerns/common.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5c46e7b7fb9f7caf1043adf2acb0d7d65d361dd1a92eb94ab6a883ca038c2c2
|
4
|
+
data.tar.gz: 247e327a750a9502459c5cf9d79f893eccded38bb092c8338de84ee4e238163f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fe319516a83e0034ab58cb27e050e442767ddef0edba2afbac269fbaac2c66e9444604f3bccfeac8dfa4522b9faf96c75d849dc30e3d8baea530b3397218107
|
7
|
+
data.tar.gz: c05ca50f8ab613b86f97b294da0dc73b0b2a02fa077385cb422d0f826edb1e89ea7975fc3ed3fe72998cfa7886a20ee44850c85b2bfc32b8352bf7c13c541605
|
data/README.md
CHANGED
@@ -66,6 +66,10 @@ charge = PR::Pin.charges.create(
|
|
66
66
|
charge.success? # => true
|
67
67
|
charge.error? # => false
|
68
68
|
charge # => #<PR::Pin::Struct::Charge>
|
69
|
+
|
70
|
+
# Find a charge by token
|
71
|
+
PR::Pin.charges.find('ch_1ee2d1')
|
72
|
+
# => #<PR::Pin::Struct::Charge>
|
69
73
|
```
|
70
74
|
|
71
75
|
### Recurring payments
|
@@ -88,6 +92,35 @@ subscription = PR::Pin.subscriptions.create(
|
|
88
92
|
subscription.success? # => true
|
89
93
|
subscription.error? # => false
|
90
94
|
subscription # => #<PR::Pin::Struct::Subscription>
|
95
|
+
|
96
|
+
ledger = PR::Pin.ledger.for_subscription('sub_293857')
|
97
|
+
subscription.success? # => true
|
98
|
+
subscription.error? # => false
|
99
|
+
ledger
|
100
|
+
# => [
|
101
|
+
# #<PR::Pin::Struct::Ledger type="credit" annotation="charge_credit" amount=1026 currency="AUD" created_at=#<DateTime: 2020-07-02T02:19:50+00:00 ((2459033j,8390s,0n),+0s,2299161j)>>,
|
102
|
+
# #<PR::Pin::Struct::Ledger type="debit" annotation="interval_fee" amount=1026 currency="AUD" created_at=#<DateTime: 2020-07-02T02:19:47+00:00 ((2459033j,8387s,0n),+0s,2299161j)>>,
|
103
|
+
# #<PR::Pin::Struct::Ledger type="debit" annotation="setup_fee" amount=0 currency="AUD" created_at=#<DateTime: 2020-07-02T02:19:47+00:00 ((2459033j,8387s,0n),+0s,2299161j)>>
|
104
|
+
# ]
|
105
|
+
```
|
106
|
+
|
107
|
+
### Refunds
|
108
|
+
```ruby
|
109
|
+
# List refunds (paginated)
|
110
|
+
refunds = PR::Pin.refunds.list
|
111
|
+
# => [#<PR::Pin::Struct::Refund>, ...]
|
112
|
+
|
113
|
+
# Find a specific refund
|
114
|
+
refund = PR::Pin.refunds.find('rf_1e5429')
|
115
|
+
# => #<PR::Pin::Struct::Refund>
|
116
|
+
|
117
|
+
# Create a refund for a charge
|
118
|
+
PR::Pin.refunds.create_for_charge('ch_1ee2d1')
|
119
|
+
# => #<PR::Pin::Struct::Refund>
|
120
|
+
|
121
|
+
# List all refunds by charge
|
122
|
+
PR::Pin.refunds.for_charge('ch_1ee2d1')
|
123
|
+
# => [#<PR::Pin::Struct::Refund>, ...]
|
91
124
|
```
|
92
125
|
|
93
126
|
### Errors - See [PR::Pin::API::Error](https://github.com/PetRescue/pr-pin/blob/master/lib/pr/pin/api/error.rb)
|
@@ -108,61 +141,61 @@ Coverage of https://pinpayments.com/developers/api-reference
|
|
108
141
|
|
109
142
|
| Relation | Endpoint | Description | Docs | Implemented |
|
110
143
|
|--|--|--|--|--|
|
111
|
-
| Balance | GET /balance | Returns the current balance of your Pin Payments account | [:link:](https://pinpayments.com/developers/api-reference/balance) | :x: |
|
112
|
-
| Bank Accounts | POST /bank_accounts | Creates a bank account token | [:link:](https://pinpayments.com/developers/api-reference/bank-accounts) | :x: |
|
113
|
-
| Cards | POST /cards | Securely stores a card's details | [:link:](https://pinpayments.com/developers/api-reference/cards) | :x: |
|
114
|
-
| Charges | POST /charges | Creates a new charge | [:link:](https://pinpayments.com/developers/api-reference/charges#post-charges) | :heavy_check_mark: |
|
115
|
-
| Charges | PUT /charges
|
116
|
-
| Charges | GET /charges | Returns a paginated list of all charges | [:link:](https://pinpayments.com/developers/api-reference/charges#get-charges) | :heavy_check_mark: |
|
117
|
-
| Charges | GET /charges/search | Returns a paginated list of charges matching the search criteria | [:link:](https://pinpayments.com/developers/api-reference/charges#search-charges) | :heavy_check_mark: |
|
118
|
-
| Charges | GET /charges
|
119
|
-
| Customers | POST /customers | Creates a new customer | [:link:](https://pinpayments.com/developers/api-reference/customers#post-customers) | :heavy_check_mark: |
|
120
|
-
| Customers | GET /customers | Returns a paginated list of all customers | [:link:](https://pinpayments.com/developers/api-reference/customers#get-customers) | :heavy_check_mark: |
|
121
|
-
| Customers | GET /customers
|
122
|
-
| Customers | PUT /customers
|
123
|
-
| Customers | DELETE /customers
|
124
|
-
| Customers | GET /customers
|
125
|
-
| Customers | GET /customers
|
126
|
-
| Customers | POST /customers
|
127
|
-
| Customers | DELETE /customers
|
128
|
-
| Customers | GET /customers
|
129
|
-
| Events | GET /events | Returns a paginated list of all events | [:link:](https://pinpayments.com/developers/api-reference/events#get-events) | :x: |
|
130
|
-
| Events | GET /events
|
131
|
-
| Plans | POST /plans | Creates a new plan | [:link:](https://pinpayments.com/developers/api-reference/plans#post-plans) | :heavy_check_mark: |
|
132
|
-
| Plans | GET /plans | Returns a paginated list of all plans | [:link:](https://pinpayments.com/developers/api-reference/plans#get-plans) | :heavy_check_mark: |
|
133
|
-
| Plans | GET /plans
|
134
|
-
| Plans | PUT /plans
|
135
|
-
| Plans | DELETE /plans
|
136
|
-
| Plans | POST /plans
|
137
|
-
| Plans | GET /plans
|
138
|
-
| Subscriptions | POST /subscriptions | Activate a new subscription and returns its details | [:link:](https://pinpayments.com/developers/api-reference/subscriptions#post-subscriptions) | :heavy_check_mark: |
|
139
|
-
| Subscriptions | GET /subscriptions | Returns a paginated list of all subscriptions | [:link:](https://pinpayments.com/developers/api-reference/subscriptions#get-subscriptions) | :heavy_check_mark: |
|
140
|
-
| Subscriptions | GET /subscriptions
|
141
|
-
| Subscriptions | PUT /subscriptions
|
142
|
-
| Subscriptions | DELETE /subscriptions
|
143
|
-
| Subscriptions | PUT /subscriptions
|
144
|
-
| Subscriptions | GET /subscriptions
|
145
|
-
| Recipients | POST /recipients | Creates a new recipient | [:link:](https://pinpayments.com/developers/api-reference/recipients#post-recipients) | :x: |
|
146
|
-
| Recipients | GET /recipients | Returns a paginated list of all recipients | [:link:](https://pinpayments.com/developers/api-reference/recipients#get-recipients) | :x: |
|
147
|
-
| Recipients | GET /recipients
|
148
|
-
| Recipients | PUT /recipients
|
149
|
-
| Recipients | GET /recipients
|
150
|
-
| Refunds | GET /refunds | Returns a paginated list of all refunds | [:link:](https://pinpayments.com/developers/api-reference/refunds#get-refunds) | :
|
151
|
-
| Refunds | GET /refunds
|
152
|
-
| Refunds | POST /charges
|
153
|
-
| Refunds | GET /charges
|
154
|
-
| Transfers | POST /transfers | Creates a new transfer | [:link:](https://pinpayments.com/developers/api-reference/transfers#post-transfers) | :x: |
|
155
|
-
| Transfers | GET /transfers | Returns a paginated list of all transfers | [:link:](https://pinpayments.com/developers/api-reference/transfers#get-transfers) | :x: |
|
156
|
-
| Transfers | GET /transfers/search | Returns a paginated list of transfers matching the search criteria | [:link:](https://pinpayments.com/developers/api-reference/transfers#search-transfers) | :x: |
|
157
|
-
| Transfers | GET /transfers
|
158
|
-
| Transfers | GET /transfers
|
159
|
-
| Webhook Endpoints | POST /webhook_endpoints | Creates a new webhook endpoint | [:link:](https://pinpayments.com/developers/api-reference/webhook-endpoints#post-webhook_endpoints) | :x: |
|
160
|
-
| Webhook Endpoints | GET /webhook_endpoints | Returns a paginated list of all webhook endpoints | [:link:](https://pinpayments.com/developers/api-reference/webhook-endpoints#get-webhook_endpoints) | :x: |
|
161
|
-
| Webhook Endpoints | GET /webhook_endpoints
|
162
|
-
| Webhook Endpoints | DELETE /webhook_endpoints
|
163
|
-
| Webhooks | GET /webhooks | Returns a paginated list of all webhooks | [:link:](https://pinpayments.com/developers/api-reference/webhooks#get-webhooks) | :x: |
|
164
|
-
| Webhooks | GET /webhooks
|
165
|
-
| Webhooks | PUT /webhooks
|
144
|
+
| Balance | `GET /balance` | Returns the current balance of your Pin Payments account | [:link:](https://pinpayments.com/developers/api-reference/balance) | :x: |
|
145
|
+
| Bank Accounts | `POST /bank_accounts` | Creates a bank account token | [:link:](https://pinpayments.com/developers/api-reference/bank-accounts) | :x: |
|
146
|
+
| Cards | `POST /cards` | Securely stores a card's details | [:link:](https://pinpayments.com/developers/api-reference/cards) | :x: |
|
147
|
+
| Charges | `POST /charges` | Creates a new charge | [:link:](https://pinpayments.com/developers/api-reference/charges#post-charges) | :heavy_check_mark: |
|
148
|
+
| Charges | `PUT /charges/#{charge-token}/capture` | Captures a previously authorised charge | [:link:](https://pinpayments.com/developers/api-reference/charges#put-charges) | :x: |
|
149
|
+
| Charges | `GET /charges` | Returns a paginated list of all charges | [:link:](https://pinpayments.com/developers/api-reference/charges#get-charges) | :heavy_check_mark: |
|
150
|
+
| Charges | `GET /charges/search` | Returns a paginated list of charges matching the search criteria | [:link:](https://pinpayments.com/developers/api-reference/charges#search-charges) | :heavy_check_mark: |
|
151
|
+
| Charges | `GET /charges/#{charge-token}` | Returns the details of a charge | [:link:](https://pinpayments.com/developers/api-reference/charges#get-charge) | :heavy_check_mark: |
|
152
|
+
| Customers | `POST /customers` | Creates a new customer | [:link:](https://pinpayments.com/developers/api-reference/customers#post-customers) | :heavy_check_mark: |
|
153
|
+
| Customers | `GET /customers` | Returns a paginated list of all customers | [:link:](https://pinpayments.com/developers/api-reference/customers#get-customers) | :heavy_check_mark: |
|
154
|
+
| Customers | `GET /customers/#{customer-token}` | Returns the details of a customer | [:link:](https://pinpayments.com/developers/api-reference/customers#get-customer) | :heavy_check_mark: |
|
155
|
+
| Customers | `PUT /customers/#{customer-token}` | Updates the details of a customer | [:link:](https://pinpayments.com/developers/api-reference/customers#put-customer) | :heavy_check_mark: |
|
156
|
+
| Customers | `DELETE /customers/#{customer-token}` | Deletes a customer and all of its cards | [:link:](https://pinpayments.com/developers/api-reference/customers#delete-customer) | :x: |
|
157
|
+
| Customers | `GET /customers/#{customer-token}/charges` | Returns a paginated list of a customer's charges | [:link:](https://pinpayments.com/developers/api-reference/customers#get-customers-charges) | :heavy_check_mark: |
|
158
|
+
| Customers | `GET /customers/#{customer-token}/cards` | Returns a paginated list of a customer's cards | [:link:](https://pinpayments.com/developers/api-reference/customers#get-customers-cards) | :x: |
|
159
|
+
| Customers | `POST /customers/#{customer-token}/cards` | Creates an additional card for the specified customer | [:link:](https://pinpayments.com/developers/api-reference/customers#post-customers-cards) | :x: |
|
160
|
+
| Customers | `DELETE /customers/#{customer-token}/cards/#{card-token}` | Deletes a customer's non-primary card | [:link:](https://pinpayments.com/developers/api-reference/customers#delete-customers-card) | :x: |
|
161
|
+
| Customers | `GET /customers/#{customer-token}/subscriptions` | Retrieves the specified customer's subscriptions | [:link:](https://pinpayments.com/developers/api-reference/customers#customers-subscriptions) | :x: |
|
162
|
+
| Events | `GET /events` | Returns a paginated list of all events | [:link:](https://pinpayments.com/developers/api-reference/events#get-events) | :x: |
|
163
|
+
| Events | `GET /events/#{event-token}` | Returns the details of the specified event | [:link:](https://pinpayments.com/developers/api-reference/events#get-event) | :x: |
|
164
|
+
| Plans | `POST /plans` | Creates a new plan | [:link:](https://pinpayments.com/developers/api-reference/plans#post-plans) | :heavy_check_mark: |
|
165
|
+
| Plans | `GET /plans` | Returns a paginated list of all plans | [:link:](https://pinpayments.com/developers/api-reference/plans#get-plans) | :heavy_check_mark: |
|
166
|
+
| Plans | `GET /plans/#{plan-token}` | Returns the details of a specified plan | [:link:](https://pinpayments.com/developers/api-reference/plans#get-plan) | :heavy_check_mark: |
|
167
|
+
| Plans | `PUT /plans/#{plan-token}` | Update the specified plan | [:link:](https://pinpayments.com/developers/api-reference/plans#put-plan) | :heavy_check_mark: |
|
168
|
+
| Plans | `DELETE /plans/#{plan-token}` | Deletes a plan and all of its subscriptions | [:link:](https://pinpayments.com/developers/api-reference/plans#delete-plan) | :x: |
|
169
|
+
| Plans | `POST /plans/#{plan-token}/subscriptions` | Creates a new subscription to the specified plan | [:link:](https://pinpayments.com/developers/api-reference/plans#create-plan-subscription) | :x: |
|
170
|
+
| Plans | `GET /plans/#{plan-token}/subscriptions` | Returns a paginated list of subscriptions for a plan | [:link:](https://pinpayments.com/developers/api-reference/plans#get-plan-subscriptions) | :x: |
|
171
|
+
| Subscriptions | `POST /subscriptions` | Activate a new subscription and returns its details | [:link:](https://pinpayments.com/developers/api-reference/subscriptions#post-subscriptions) | :heavy_check_mark: |
|
172
|
+
| Subscriptions | `GET /subscriptions` | Returns a paginated list of all subscriptions | [:link:](https://pinpayments.com/developers/api-reference/subscriptions#get-subscriptions) | :heavy_check_mark: |
|
173
|
+
| Subscriptions | `GET /subscriptions/#{sub-token}` | Returns the details of the subscription identified by subscription token | [:link:](https://pinpayments.com/developers/api-reference/subscriptions#get-subscription) | :heavy_check_mark: |
|
174
|
+
| Subscriptions | `PUT /subscriptions/#{sub-token}` | Updates the card associated with a subscription identified by subscription token | [:link:](https://pinpayments.com/developers/api-reference/subscriptions#update-subscription) | :heavy_check_mark: |
|
175
|
+
| Subscriptions | `DELETE /subscriptions/#{sub-token}` | Cancels the subscription identified by subscription token | [:link:](https://pinpayments.com/developers/api-reference/subscriptions#delete-subscription) | :x: |
|
176
|
+
| Subscriptions | `PUT /subscriptions/#{sub-token}/reactivate` | Reactivates the subscription identified by subscription token | [:link:](https://pinpayments.com/developers/api-reference/subscriptions#reactivate-subscription) | :x: |
|
177
|
+
| Subscriptions | `GET /subscriptions/#{sub-token}/ledger` | Fetch the ledger entries relating to a subscription identified by subscription token | [:link:](https://pinpayments.com/developers/api-reference/subscriptions#ledger-subscription) | :heavy_check_mark: |
|
178
|
+
| Recipients | `POST /recipients` | Creates a new recipient | [:link:](https://pinpayments.com/developers/api-reference/recipients#post-recipients) | :x: |
|
179
|
+
| Recipients | `GET /recipients` | Returns a paginated list of all recipients | [:link:](https://pinpayments.com/developers/api-reference/recipients#get-recipients) | :x: |
|
180
|
+
| Recipients | `GET /recipients/#{recipient-token}` | Returns the details of a recipient | [:link:](https://pinpayments.com/developers/api-reference/recipients#get-recipient) | :x: |
|
181
|
+
| Recipients | `PUT /recipients/#{recipient-token}` | Updates the details of a recipient | [:link:](https://pinpayments.com/developers/api-reference/recipients#put-recipient) | :x: |
|
182
|
+
| Recipients | `GET /recipients/#{recipient-token}/transfers` | Returns a paginated list of a recipient's transfers | [:link:](https://pinpayments.com/developers/api-reference/recipients#get-recipients-transfers) | :x: |
|
183
|
+
| Refunds | `GET /refunds` | Returns a paginated list of all refunds | [:link:](https://pinpayments.com/developers/api-reference/refunds#get-refunds) | :heavy_check_mark: |
|
184
|
+
| Refunds | `GET /refunds/#{refund-token}` | Returns the details of the specified refund | [:link:](https://pinpayments.com/developers/api-reference/refunds#get-refund) | :heavy_check_mark: |
|
185
|
+
| Refunds | `POST /charges/#{charge-token}/refunds` | Creates a new refund and returns its details | [:link:](https://pinpayments.com/developers/api-reference/refunds#post-refunds) | :heavy_check_mark: |
|
186
|
+
| Refunds | `GET /charges/#{charge-token}/refunds` | Returns a list of all refunds for the specified charge | [:link:](https://pinpayments.com/developers/api-reference/refunds#get-token-refunds) | :heavy_check_mark: |
|
187
|
+
| Transfers | `POST /transfers` | Creates a new transfer | [:link:](https://pinpayments.com/developers/api-reference/transfers#post-transfers) | :x: |
|
188
|
+
| Transfers | `GET /transfers` | Returns a paginated list of all transfers | [:link:](https://pinpayments.com/developers/api-reference/transfers#get-transfers) | :x: |
|
189
|
+
| Transfers | `GET /transfers/search` | Returns a paginated list of transfers matching the search criteria | [:link:](https://pinpayments.com/developers/api-reference/transfers#search-transfers) | :x: |
|
190
|
+
| Transfers | `GET /transfers/#{transfer-token}` | Returns the details of the specified transfer | [:link:](https://pinpayments.com/developers/api-reference/transfers#get-transfer) | :x: |
|
191
|
+
| Transfers | `GET /transfers/#{transfer-token}/line_items` | Returns a paginated list of line items associated with the specified transfer | [:link:](https://pinpayments.com/developers/api-reference/transfers#get-transfer-line-items) | :x: |
|
192
|
+
| Webhook Endpoints | `POST /webhook_endpoints` | Creates a new webhook endpoint | [:link:](https://pinpayments.com/developers/api-reference/webhook-endpoints#post-webhook_endpoints) | :x: |
|
193
|
+
| Webhook Endpoints | `GET /webhook_endpoints` | Returns a paginated list of all webhook endpoints | [:link:](https://pinpayments.com/developers/api-reference/webhook-endpoints#get-webhook_endpoints) | :x: |
|
194
|
+
| Webhook Endpoints | `GET /webhook_endpoints/#{webhook-endpoint-token}` | Returns the details of the specified webhook endpoint | [:link:](https://pinpayments.com/developers/api-reference/webhook-endpoints#get-webhook_endpoints-token) | :x: |
|
195
|
+
| Webhook Endpoints | `DELETE /webhook_endpoints/#{webhook-endpoint-token}` | Deletes a webhook endpoint and all of its webhook requests | [:link:](https://pinpayments.com/developers/api-reference/webhook-endpoints#delete-webhook_endpoints) | :x: |
|
196
|
+
| Webhooks | `GET /webhooks` | Returns a paginated list of all webhooks | [:link:](https://pinpayments.com/developers/api-reference/webhooks#get-webhooks) | :x: |
|
197
|
+
| Webhooks | `GET /webhooks/#{webhook-token}` | Returns the details of a webhook | [:link:](https://pinpayments.com/developers/api-reference/webhooks#get-webhook) | :x: |
|
198
|
+
| Webhooks | `PUT /webhooks/#{webhook-token}/replay` | Replays a webhook | [:link:](https://pinpayments.com/developers/api-reference/webhooks#put-webhook-replay) | :x: |
|
166
199
|
|
167
200
|
## Development
|
168
201
|
|
data/lib/pr/pin.rb
CHANGED
@@ -57,10 +57,18 @@ module PR
|
|
57
57
|
Repositories::Customers.new(environments[identifier])
|
58
58
|
end
|
59
59
|
|
60
|
+
def ledger(identifier = :default)
|
61
|
+
Repositories::Ledger.new(environments[identifier])
|
62
|
+
end
|
63
|
+
|
60
64
|
def plans(identifier = :default)
|
61
65
|
Repositories::Plans.new(environments[identifier])
|
62
66
|
end
|
63
67
|
|
68
|
+
def refunds(identifier = :default)
|
69
|
+
Repositories::Refunds.new(environments[identifier])
|
70
|
+
end
|
71
|
+
|
64
72
|
def subscriptions(identifier = :default)
|
65
73
|
Repositories::Subscriptions.new(environments[identifier])
|
66
74
|
end
|
@@ -4,6 +4,7 @@ module PR
|
|
4
4
|
module Commands
|
5
5
|
class Create < ROM::HTTP::Commands::Create
|
6
6
|
adapter :pr_pin
|
7
|
+
restrictable true
|
7
8
|
|
8
9
|
def execute(*args, &block)
|
9
10
|
relation.new(super.map(&:to_h)).to_a
|
@@ -12,6 +13,7 @@ module PR
|
|
12
13
|
|
13
14
|
class Update < ROM::HTTP::Commands::Update
|
14
15
|
adapter :pr_pin
|
16
|
+
restrictable true
|
15
17
|
|
16
18
|
def execute(*args, &block)
|
17
19
|
relation.new(super.map(&:to_h)).to_a
|
@@ -20,6 +22,7 @@ module PR
|
|
20
22
|
|
21
23
|
class Delete < ROM::HTTP::Commands::Delete
|
22
24
|
adapter :pr_pin
|
25
|
+
restrictable true
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
@@ -5,6 +5,11 @@ module PR
|
|
5
5
|
schema(:customers) do
|
6
6
|
attribute :token, Types::Strict::String
|
7
7
|
attribute :email, Types::Strict::String
|
8
|
+
attribute :first_name, Types::Strict::String.optional
|
9
|
+
attribute :last_name, Types::Strict::String.optional
|
10
|
+
attribute :phone_number, Types::Strict::String.optional
|
11
|
+
attribute :company, Types::Strict::String.optional
|
12
|
+
attribute :notes, Types::Strict::String.optional
|
8
13
|
attribute :created_at, Types::JSON::DateTime
|
9
14
|
attribute :card, Types::JSON::Hash
|
10
15
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module PR
|
2
|
+
module Pin
|
3
|
+
module Relations
|
4
|
+
class Ledger < ROM::Relation[:pr_pin]
|
5
|
+
schema(:ledger) do
|
6
|
+
attribute :type, Types::Strict::String
|
7
|
+
attribute :annotation, Types::Strict::String
|
8
|
+
attribute :amount, Types::Strict::Integer
|
9
|
+
attribute :currency, Types::Strict::String
|
10
|
+
attribute :created_at, Types::JSON::DateTime
|
11
|
+
end
|
12
|
+
|
13
|
+
def for_subscription(subscription_token)
|
14
|
+
with_base_path("/subscriptions/#{subscription_token}/ledger")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module PR
|
2
|
+
module Pin
|
3
|
+
module Relations
|
4
|
+
class Refunds < ROM::Relation[:pr_pin]
|
5
|
+
schema(:refunds) do
|
6
|
+
attribute :token, Types::Strict::String
|
7
|
+
attribute :success, Types::Bool.optional
|
8
|
+
attribute :amount, Types::Strict::Integer
|
9
|
+
attribute :currency, Types::Strict::String
|
10
|
+
attribute :charge, Types::Strict::String
|
11
|
+
attribute :error_message, Types::Strict::String.optional
|
12
|
+
attribute :status_message, Types::Strict::String
|
13
|
+
attribute :created_at, Types::JSON::DateTime
|
14
|
+
end
|
15
|
+
|
16
|
+
def for_charge(charge_token)
|
17
|
+
with_base_path("/charges/#{charge_token}/refunds")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -4,8 +4,8 @@ module PR
|
|
4
4
|
class Subscriptions < ROM::Relation[:pr_pin]
|
5
5
|
schema(:subscriptions) do
|
6
6
|
attribute :state, Types::Strict::String
|
7
|
-
attribute :next_billing_date, Types::JSON::DateTime
|
8
|
-
attribute :active_interval_started_at, Types::JSON::DateTime
|
7
|
+
attribute :next_billing_date, Types::JSON::DateTime.optional
|
8
|
+
attribute :active_interval_started_at, Types::JSON::DateTime.optional
|
9
9
|
attribute :active_interval_finishes_at, Types::JSON::DateTime.optional
|
10
10
|
attribute :cancelled_at, Types::JSON::DateTime.optional
|
11
11
|
attribute :created_at, Types::JSON::DateTime
|
data/lib/pr/pin/repositories.rb
CHANGED
@@ -3,8 +3,9 @@ require 'pr/pin/api/error'
|
|
3
3
|
require 'pr/pin/api/result'
|
4
4
|
require 'pr/pin/api/paginated_result'
|
5
5
|
require 'pr/pin/struct'
|
6
|
-
require 'pr/pin/repositories/concerns/common'
|
7
6
|
require 'pr/pin/repositories/charges'
|
8
7
|
require 'pr/pin/repositories/customers'
|
8
|
+
require 'pr/pin/repositories/ledger'
|
9
9
|
require 'pr/pin/repositories/plans'
|
10
|
+
require 'pr/pin/repositories/refunds'
|
10
11
|
require 'pr/pin/repositories/subscriptions'
|
@@ -2,7 +2,28 @@ module PR
|
|
2
2
|
module Pin
|
3
3
|
module Repositories
|
4
4
|
class Charges < ROM::Repository[:charges]
|
5
|
-
|
5
|
+
struct_namespace PR::Pin::Struct
|
6
|
+
|
7
|
+
def create(*args)
|
8
|
+
API::Result.wrap(root) do
|
9
|
+
root.command(:create).call(*args)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def find(token)
|
14
|
+
relation = root.with_path(token)
|
15
|
+
|
16
|
+
API::Result.wrap(relation) { relation.one }
|
17
|
+
end
|
18
|
+
|
19
|
+
def list(page: 1, per_page: nil)
|
20
|
+
relation = root.with_params(
|
21
|
+
page: page,
|
22
|
+
per_page: per_page
|
23
|
+
)
|
24
|
+
|
25
|
+
API::PaginatedResult.wrap(relation) { relation.paginate }
|
26
|
+
end
|
6
27
|
|
7
28
|
def search(**params)
|
8
29
|
relation = root.append_path('search').with_params(params)
|
@@ -11,6 +32,15 @@ module PR
|
|
11
32
|
relation.paginate
|
12
33
|
end
|
13
34
|
end
|
35
|
+
|
36
|
+
def for_customer(customer_token, page: 1, per_page: nil)
|
37
|
+
relation = root.for_customer(customer_token).with_params(
|
38
|
+
page: page,
|
39
|
+
per_page: per_page
|
40
|
+
)
|
41
|
+
|
42
|
+
API::PaginatedResult.wrap(relation) { relation.paginate }
|
43
|
+
end
|
14
44
|
end
|
15
45
|
end
|
16
46
|
end
|
@@ -2,7 +2,34 @@ module PR
|
|
2
2
|
module Pin
|
3
3
|
module Repositories
|
4
4
|
class Customers < ROM::Repository[:customers]
|
5
|
-
|
5
|
+
struct_namespace PR::Pin::Struct
|
6
|
+
|
7
|
+
def create(*args)
|
8
|
+
API::Result.wrap(root) do
|
9
|
+
root.command(:create).call(*args)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def update(token, *args)
|
14
|
+
API::Result.wrap(root) do
|
15
|
+
root.append_path(token).command(:update).call(*args)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def find(token)
|
20
|
+
relation = root.with_path(token)
|
21
|
+
|
22
|
+
API::Result.wrap(relation) { relation.one }
|
23
|
+
end
|
24
|
+
|
25
|
+
def list(page: 1, per_page: nil)
|
26
|
+
relation = root.with_params(
|
27
|
+
page: page,
|
28
|
+
per_page: per_page
|
29
|
+
)
|
30
|
+
|
31
|
+
API::PaginatedResult.wrap(relation) { relation.paginate }
|
32
|
+
end
|
6
33
|
end
|
7
34
|
end
|
8
35
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module PR
|
2
|
+
module Pin
|
3
|
+
module Repositories
|
4
|
+
class Ledger < ROM::Repository[:ledger]
|
5
|
+
struct_namespace PR::Pin::Struct
|
6
|
+
|
7
|
+
def for_subscription(subscription_token, page: 1, per_page: nil)
|
8
|
+
relation = root.for_subscription(subscription_token).with_params(
|
9
|
+
page: page,
|
10
|
+
per_page: per_page
|
11
|
+
)
|
12
|
+
|
13
|
+
API::PaginatedResult.wrap(relation) { relation.paginate }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -2,7 +2,34 @@ module PR
|
|
2
2
|
module Pin
|
3
3
|
module Repositories
|
4
4
|
class Plans < ROM::Repository[:plans]
|
5
|
-
|
5
|
+
struct_namespace PR::Pin::Struct
|
6
|
+
|
7
|
+
def create(*args)
|
8
|
+
API::Result.wrap(root) do
|
9
|
+
root.command(:create).call(*args)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def update(token, *args)
|
14
|
+
API::Result.wrap(root) do
|
15
|
+
root.append_path(token).command(:update).call(*args)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def find(token)
|
20
|
+
relation = root.with_path(token)
|
21
|
+
|
22
|
+
API::Result.wrap(relation) { relation.one }
|
23
|
+
end
|
24
|
+
|
25
|
+
def list(page: 1, per_page: nil)
|
26
|
+
relation = root.with_params(
|
27
|
+
page: page,
|
28
|
+
per_page: per_page
|
29
|
+
)
|
30
|
+
|
31
|
+
API::PaginatedResult.wrap(relation) { relation.paginate }
|
32
|
+
end
|
6
33
|
end
|
7
34
|
end
|
8
35
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module PR
|
2
|
+
module Pin
|
3
|
+
module Repositories
|
4
|
+
class Refunds < ROM::Repository[:refunds]
|
5
|
+
struct_namespace PR::Pin::Struct
|
6
|
+
|
7
|
+
def list(page: 1, per_page: nil)
|
8
|
+
relation = root.with_params(
|
9
|
+
page: page,
|
10
|
+
per_page: per_page
|
11
|
+
)
|
12
|
+
|
13
|
+
API::PaginatedResult.wrap(relation) { relation.paginate }
|
14
|
+
end
|
15
|
+
|
16
|
+
def find(token)
|
17
|
+
relation = root.with_path(token)
|
18
|
+
|
19
|
+
API::Result.wrap(relation) { relation.one }
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_for_charge(charge_token, *args)
|
23
|
+
relation = root.for_charge(charge_token)
|
24
|
+
|
25
|
+
API::Result.wrap(relation) do
|
26
|
+
relation.command(:create).call(*args)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def for_charge(charge_token, page: 1, per_page: nil)
|
31
|
+
relation = root.for_charge(charge_token).with_params(
|
32
|
+
page: page,
|
33
|
+
per_page: per_page
|
34
|
+
)
|
35
|
+
|
36
|
+
API::PaginatedResult.wrap(relation) { relation.paginate }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -2,13 +2,34 @@ module PR
|
|
2
2
|
module Pin
|
3
3
|
module Repositories
|
4
4
|
class Subscriptions < ROM::Repository[:subscriptions]
|
5
|
-
|
5
|
+
struct_namespace PR::Pin::Struct
|
6
6
|
|
7
|
-
def
|
7
|
+
def create(*args)
|
8
|
+
API::Result.wrap(root) do
|
9
|
+
root.command(:create).call(*args)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def update(token, *args)
|
8
14
|
API::Result.wrap(root) do
|
9
|
-
root.append_path(token).
|
15
|
+
root.append_path(token).command(:update).call(*args)
|
10
16
|
end
|
11
17
|
end
|
18
|
+
|
19
|
+
def find(token)
|
20
|
+
relation = root.with_path(token)
|
21
|
+
|
22
|
+
API::Result.wrap(relation) { relation.one }
|
23
|
+
end
|
24
|
+
|
25
|
+
def list(page: 1, per_page: nil)
|
26
|
+
relation = root.with_params(
|
27
|
+
page: page,
|
28
|
+
per_page: per_page
|
29
|
+
)
|
30
|
+
|
31
|
+
API::PaginatedResult.wrap(relation) { relation.paginate }
|
32
|
+
end
|
12
33
|
end
|
13
34
|
end
|
14
35
|
end
|
data/lib/pr/pin/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pr-pin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AMHOL
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,30 +28,30 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: webmock
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,28 +140,28 @@ dependencies:
|
|
140
140
|
name: rom
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 5.
|
145
|
+
version: 5.0.0
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- -
|
150
|
+
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 5.
|
152
|
+
version: 5.0.0
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: rom-http
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- -
|
157
|
+
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: 0.8.0
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- -
|
164
|
+
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: 0.8.0
|
167
167
|
description: Pin Payments API wrapper inplemented using rom-rb HTTP adapter.
|
@@ -192,13 +192,16 @@ files:
|
|
192
192
|
- lib/pr/pin/inflector.rb
|
193
193
|
- lib/pr/pin/relations/charges.rb
|
194
194
|
- lib/pr/pin/relations/customers.rb
|
195
|
+
- lib/pr/pin/relations/ledger.rb
|
195
196
|
- lib/pr/pin/relations/plans.rb
|
197
|
+
- lib/pr/pin/relations/refunds.rb
|
196
198
|
- lib/pr/pin/relations/subscriptions.rb
|
197
199
|
- lib/pr/pin/repositories.rb
|
198
200
|
- lib/pr/pin/repositories/charges.rb
|
199
|
-
- lib/pr/pin/repositories/concerns/common.rb
|
200
201
|
- lib/pr/pin/repositories/customers.rb
|
202
|
+
- lib/pr/pin/repositories/ledger.rb
|
201
203
|
- lib/pr/pin/repositories/plans.rb
|
204
|
+
- lib/pr/pin/repositories/refunds.rb
|
202
205
|
- lib/pr/pin/repositories/subscriptions.rb
|
203
206
|
- lib/pr/pin/struct.rb
|
204
207
|
- lib/pr/pin/types.rb
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module PR
|
2
|
-
module Pin
|
3
|
-
module Repositories
|
4
|
-
module Concerns
|
5
|
-
module Common
|
6
|
-
def self.included(mod)
|
7
|
-
mod.struct_namespace(PR::Pin::Struct)
|
8
|
-
end
|
9
|
-
|
10
|
-
def create(*args)
|
11
|
-
API::Result.wrap(root) do
|
12
|
-
root.command(:create).call(*args)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def list(page: 1, per_page: nil)
|
17
|
-
relation = root.with_params(
|
18
|
-
page: page,
|
19
|
-
per_page: per_page
|
20
|
-
)
|
21
|
-
|
22
|
-
API::PaginatedResult.wrap(relation) { relation.paginate }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|