paddle 2.7.1 → 2.9
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +58 -50
- data/README.md +125 -1
- data/lib/paddle/collection.rb +2 -0
- data/lib/paddle/error_generator.rb +32 -4
- data/lib/paddle/models/client_token.rb +26 -0
- data/lib/paddle/models/customer.rb +5 -0
- data/lib/paddle/models/customer_auth_token.rb +4 -0
- data/lib/paddle/models/discount_group.rb +34 -0
- data/lib/paddle/models/payment_method.rb +19 -0
- data/lib/paddle/version.rb +1 -1
- data/lib/paddle.rb +4 -0
- data/mise.toml +2 -0
- data/paddle.gemspec +1 -0
- metadata +22 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cc578ecefeacc14fa58ae9fc433429c3180d5c5bc6015493bc66afc50172cccd
|
|
4
|
+
data.tar.gz: 03d85b6ee1f8fedb0c5b56028dfb741d32155471bfda087b7cf61bd2872f60ef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4ecdcde91d5d11a03c7f5e1506f923b3cfd738bbc70113436891768e2cdbdc194694a67e9e452256b6d8be5918b0eed315ce27ab9e5a7a5920312023f3ed3acc
|
|
7
|
+
data.tar.gz: 851daa7f4a126c94891cf136b80761f7a98745cd3a21455cadb8af1e7f782f3972a8e0123585320052d6335bd25598706e212e1224aaabd93c18c100f195c16b
|
data/Gemfile.lock
CHANGED
|
@@ -1,89 +1,97 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
paddle (2.
|
|
4
|
+
paddle (2.9)
|
|
5
|
+
cgi
|
|
5
6
|
faraday (~> 2.11)
|
|
6
7
|
ostruct (~> 0.6.0)
|
|
7
8
|
|
|
8
9
|
GEM
|
|
9
10
|
remote: https://rubygems.org/
|
|
10
11
|
specs:
|
|
11
|
-
activesupport (
|
|
12
|
+
activesupport (8.1.1)
|
|
12
13
|
base64
|
|
13
14
|
bigdecimal
|
|
14
15
|
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
15
16
|
connection_pool (>= 2.2.5)
|
|
16
17
|
drb
|
|
17
18
|
i18n (>= 1.6, < 2)
|
|
19
|
+
json
|
|
18
20
|
logger (>= 1.4.2)
|
|
19
21
|
minitest (>= 5.1)
|
|
20
22
|
securerandom (>= 0.3)
|
|
21
23
|
tzinfo (~> 2.0, >= 2.0.5)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
uri (>= 0.13.1)
|
|
25
|
+
ast (2.4.3)
|
|
26
|
+
base64 (0.3.0)
|
|
27
|
+
bigdecimal (3.3.1)
|
|
28
|
+
cgi (0.5.1)
|
|
29
|
+
concurrent-ruby (1.3.5)
|
|
30
|
+
connection_pool (3.0.2)
|
|
31
|
+
dotenv (3.2.0)
|
|
32
|
+
drb (2.2.3)
|
|
33
|
+
faraday (2.14.0)
|
|
30
34
|
faraday-net_http (>= 2.0, < 3.5)
|
|
31
35
|
json
|
|
32
36
|
logger
|
|
33
|
-
faraday-net_http (3.4.
|
|
34
|
-
net-http (
|
|
35
|
-
i18n (1.14.
|
|
37
|
+
faraday-net_http (3.4.2)
|
|
38
|
+
net-http (~> 0.5)
|
|
39
|
+
i18n (1.14.7)
|
|
36
40
|
concurrent-ruby (~> 1.0)
|
|
37
|
-
json (2.
|
|
38
|
-
language_server-protocol (3.17.0.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
json (2.18.0)
|
|
42
|
+
language_server-protocol (3.17.0.5)
|
|
43
|
+
lint_roller (1.1.0)
|
|
44
|
+
logger (1.7.0)
|
|
45
|
+
minitest (5.27.0)
|
|
46
|
+
net-http (0.8.0)
|
|
47
|
+
uri (>= 0.11.1)
|
|
48
|
+
ostruct (0.6.3)
|
|
49
|
+
parallel (1.27.0)
|
|
50
|
+
parser (3.3.10.0)
|
|
46
51
|
ast (~> 2.4.1)
|
|
47
52
|
racc
|
|
53
|
+
prism (1.6.0)
|
|
48
54
|
racc (1.8.1)
|
|
49
|
-
rack (3.
|
|
55
|
+
rack (3.2.4)
|
|
50
56
|
rainbow (3.1.1)
|
|
51
|
-
rake (13.
|
|
52
|
-
regexp_parser (2.
|
|
53
|
-
rubocop (1.
|
|
57
|
+
rake (13.3.1)
|
|
58
|
+
regexp_parser (2.11.3)
|
|
59
|
+
rubocop (1.82.1)
|
|
54
60
|
json (~> 2.3)
|
|
55
|
-
language_server-protocol (
|
|
61
|
+
language_server-protocol (~> 3.17.0.2)
|
|
62
|
+
lint_roller (~> 1.1.0)
|
|
56
63
|
parallel (~> 1.10)
|
|
57
64
|
parser (>= 3.3.0.2)
|
|
58
65
|
rainbow (>= 2.2.2, < 4.0)
|
|
59
|
-
regexp_parser (>= 2.
|
|
60
|
-
rubocop-ast (>= 1.
|
|
66
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
67
|
+
rubocop-ast (>= 1.48.0, < 2.0)
|
|
61
68
|
ruby-progressbar (~> 1.7)
|
|
62
|
-
unicode-display_width (>= 2.4.0, <
|
|
63
|
-
rubocop-ast (1.
|
|
64
|
-
parser (>= 3.3.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
rubocop (>= 1.
|
|
70
|
-
|
|
71
|
-
rubocop-rails (2.26.0)
|
|
69
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
70
|
+
rubocop-ast (1.48.0)
|
|
71
|
+
parser (>= 3.3.7.2)
|
|
72
|
+
prism (~> 1.4)
|
|
73
|
+
rubocop-performance (1.26.1)
|
|
74
|
+
lint_roller (~> 1.1)
|
|
75
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
76
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
77
|
+
rubocop-rails (2.34.2)
|
|
72
78
|
activesupport (>= 4.2.0)
|
|
79
|
+
lint_roller (~> 1.1)
|
|
73
80
|
rack (>= 1.1)
|
|
74
|
-
rubocop (>= 1.
|
|
75
|
-
rubocop-ast (>= 1.
|
|
76
|
-
rubocop-rails-omakase (1.
|
|
77
|
-
rubocop
|
|
78
|
-
rubocop-
|
|
79
|
-
rubocop-
|
|
80
|
-
rubocop-rails
|
|
81
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
82
|
+
rubocop-ast (>= 1.44.0, < 2.0)
|
|
83
|
+
rubocop-rails-omakase (1.1.0)
|
|
84
|
+
rubocop (>= 1.72)
|
|
85
|
+
rubocop-performance (>= 1.24)
|
|
86
|
+
rubocop-rails (>= 2.30)
|
|
81
87
|
ruby-progressbar (1.13.0)
|
|
82
|
-
securerandom (0.
|
|
88
|
+
securerandom (0.4.1)
|
|
83
89
|
tzinfo (2.0.6)
|
|
84
90
|
concurrent-ruby (~> 1.0)
|
|
85
|
-
unicode-display_width (2.
|
|
86
|
-
|
|
91
|
+
unicode-display_width (3.2.0)
|
|
92
|
+
unicode-emoji (~> 4.1)
|
|
93
|
+
unicode-emoji (4.2.0)
|
|
94
|
+
uri (1.1.1)
|
|
87
95
|
vcr (6.3.1)
|
|
88
96
|
base64
|
|
89
97
|
|
|
@@ -99,4 +107,4 @@ DEPENDENCIES
|
|
|
99
107
|
vcr
|
|
100
108
|
|
|
101
109
|
BUNDLED WITH
|
|
102
|
-
|
|
110
|
+
4.0.3
|
data/README.md
CHANGED
|
@@ -7,7 +7,7 @@ The easiest and most complete Ruby library for the Paddle APIs, both Classic and
|
|
|
7
7
|
Add this line to your application's Gemfile:
|
|
8
8
|
|
|
9
9
|
```ruby
|
|
10
|
-
gem "paddle", "~> 2.
|
|
10
|
+
gem "paddle", "~> 2.8"
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Billing API
|
|
@@ -77,6 +77,57 @@ Paddle::Product.list(per_page: 10, after: "abc123")
|
|
|
77
77
|
>
|
|
78
78
|
> The Paddle API doesn't take `nil` values for optional parameters. If you want to remove a value, you'll need to pass `"null"` instead.
|
|
79
79
|
|
|
80
|
+
### Error Handling
|
|
81
|
+
|
|
82
|
+
When API requests fail, the gem provides detailed error information to help you debug issues. Errors are raised as exceptions with comprehensive details including field-level validation errors.
|
|
83
|
+
|
|
84
|
+
#### Error Structure
|
|
85
|
+
|
|
86
|
+
All errors inherit from `Paddle::ErrorGenerator` and include:
|
|
87
|
+
- HTTP status code
|
|
88
|
+
- Error code from Paddle
|
|
89
|
+
- Detailed error message
|
|
90
|
+
- Field-specific validation errors (when applicable)
|
|
91
|
+
- Documentation URL for more information
|
|
92
|
+
- Request ID for support
|
|
93
|
+
|
|
94
|
+
#### Available Error Classes
|
|
95
|
+
|
|
96
|
+
- `Paddle::Errors::BadRequestError` (400) - Invalid request parameters
|
|
97
|
+
- `Paddle::Errors::AuthenticationMissingError` (401) - Missing or invalid API credentials
|
|
98
|
+
- `Paddle::Errors::ForbiddenError` (403) - Insufficient permissions
|
|
99
|
+
- `Paddle::Errors::EntityNotFoundError` (404) - Resource not found
|
|
100
|
+
- `Paddle::Errors::ConflictError` (409) - Request conflicts with existing data
|
|
101
|
+
- `Paddle::Errors::TooManyRequestsError` (429) - Rate limit exceeded
|
|
102
|
+
- `Paddle::Errors::InternalError` (500) - Server error
|
|
103
|
+
- `Paddle::Errors::ServiceUnavailableError` (503) - Service unavailable
|
|
104
|
+
|
|
105
|
+
#### Error Example
|
|
106
|
+
|
|
107
|
+
When creating a Price with invalid parameters, you'll receive a detailed error:
|
|
108
|
+
|
|
109
|
+
```ruby
|
|
110
|
+
begin
|
|
111
|
+
Paddle::Price.create(product_id: "pro_123", trial_period: { frequency: "monthly" })
|
|
112
|
+
rescue Paddle::Errors::BadRequestError => e
|
|
113
|
+
puts e.message
|
|
114
|
+
# => Error 400: Invalid request. 'bad_request'
|
|
115
|
+
# Field errors:
|
|
116
|
+
# - trial_period.frequency: Invalid type. Expected: integer, given: string
|
|
117
|
+
# - trial_period: Must validate one and only one schema (oneOf)
|
|
118
|
+
# Documentation: https://developer.paddle.com/v1/errors/shared/bad_request
|
|
119
|
+
# Request ID: e385967f-4298-4240-a971-f988209b32ca
|
|
120
|
+
|
|
121
|
+
# Access error details programmatically
|
|
122
|
+
e.http_status_code #=> 400
|
|
123
|
+
e.paddle_error_code #=> "bad_request"
|
|
124
|
+
e.paddle_error_message #=> "Invalid request."
|
|
125
|
+
e.paddle_errors #=> [{"field"=>"trial_period.frequency", "message"=>"Invalid type. Expected: integer, given: string"}, ...]
|
|
126
|
+
e.documentation_url #=> "https://developer.paddle.com/v1/errors/shared/bad_request"
|
|
127
|
+
e.request_id #=> "e385967f-4298-4240-a971-f988209b32ca"
|
|
128
|
+
end
|
|
129
|
+
```
|
|
130
|
+
|
|
80
131
|
### Updating records
|
|
81
132
|
|
|
82
133
|
For API endpoints that support it, you can use the `update` method to update a record, like so:
|
|
@@ -170,6 +221,37 @@ discount.update(description: "An updated description")
|
|
|
170
221
|
Paddle::Discount.update(id: "dsc_abc123", description: "An updated description")
|
|
171
222
|
```
|
|
172
223
|
|
|
224
|
+
### Discount Groups
|
|
225
|
+
|
|
226
|
+
```ruby
|
|
227
|
+
# List all discount groups
|
|
228
|
+
# https://developer.paddle.com/api-reference/discount-groups/list-discount-groups
|
|
229
|
+
Paddle::DiscountGroup.list
|
|
230
|
+
Paddle::DiscountGroup.list(status: "active")
|
|
231
|
+
|
|
232
|
+
# Create a discount group
|
|
233
|
+
# https://developer.paddle.com/api-reference/discount-groups/create-discount-group
|
|
234
|
+
Paddle::DiscountGroup.create(name: "Black Friday Promotion")
|
|
235
|
+
|
|
236
|
+
# Retrieve a discount group
|
|
237
|
+
# https://developer.paddle.com/api-reference/discount-groups/get-discount-group
|
|
238
|
+
discount_group = Paddle::DiscountGroup.retrieve(id: "dsg_abc123")
|
|
239
|
+
|
|
240
|
+
# Update a discount group
|
|
241
|
+
# https://developer.paddle.com/api-reference/discount-groups/update-discount-group
|
|
242
|
+
discount_group.update(name: "Updated name")
|
|
243
|
+
# or
|
|
244
|
+
Paddle::DiscountGroup.update(id: "dsg_abc123", name: "Updated name")
|
|
245
|
+
|
|
246
|
+
# Create a discount in a discount group
|
|
247
|
+
discount_group.create_discount(description: "$10 off", type: "flat", amount: "1000", currency_code: "USD")
|
|
248
|
+
# or
|
|
249
|
+
Paddle::Discount.create(discount_group_id: discount_group.id, description: "$10 off", type: "flat", amount: "1000", currency_code: "USD")
|
|
250
|
+
|
|
251
|
+
# List discounts in a discount group
|
|
252
|
+
discounts = discount_group.discounts
|
|
253
|
+
```
|
|
254
|
+
|
|
173
255
|
### Customers
|
|
174
256
|
|
|
175
257
|
```ruby
|
|
@@ -196,6 +278,11 @@ Paddle::Customer.update(id: "ctm_abc123", status: "archived")
|
|
|
196
278
|
# Retrieve credit balance for a customer
|
|
197
279
|
# https://developer.paddle.com/api-reference/customers/list-credit-balances
|
|
198
280
|
Paddle::Customer.credit(id: "ctm_abc123")
|
|
281
|
+
|
|
282
|
+
# Generate an authentication token for a customer
|
|
283
|
+
# https://developer.paddle.com/api-reference/customers/generate-customer-authentication-token
|
|
284
|
+
Paddle::Customer.auth_token id: "ctm_abc123"
|
|
285
|
+
#=> #<Paddle::CustomerAuthToken customer_auth_token="pca_abc123", expires_at="2025-12-10T16:21:21.554Z">
|
|
199
286
|
```
|
|
200
287
|
|
|
201
288
|
### Addresses
|
|
@@ -376,6 +463,22 @@ Paddle::Adjustment.create(
|
|
|
376
463
|
Paddle::Adjustment.credit_note(id: "adj_abc123", disposition: "inline")
|
|
377
464
|
```
|
|
378
465
|
|
|
466
|
+
### Payment Methods
|
|
467
|
+
|
|
468
|
+
```ruby
|
|
469
|
+
# List all payment methods for a customer
|
|
470
|
+
# https://developer.paddle.com/api-reference/payment-methods/list-payment-methods
|
|
471
|
+
Paddle::PaymentMethod.list customer: "ctm_abc123"
|
|
472
|
+
|
|
473
|
+
# Retrieve a single payment method for a customer
|
|
474
|
+
# https://developer.paddle.com/api-reference/payment-methods/get-payment-method
|
|
475
|
+
Paddle::PaymentMethod.retrieve customer: "ctm_abc123", id: "paymtd_abc123"
|
|
476
|
+
|
|
477
|
+
# Delete a payment method for a customer
|
|
478
|
+
# https://developer.paddle.com/api-reference/payment-methods/delete-payment-method
|
|
479
|
+
Paddle::PaymentMethod.delete customer: "ctm_abc123", id: "paymtd_abc123"
|
|
480
|
+
```
|
|
481
|
+
|
|
379
482
|
### Event Types
|
|
380
483
|
|
|
381
484
|
```ruby
|
|
@@ -524,6 +627,27 @@ Paddle::SimulationRun.events(simulation_id: "ntfsim_abc123", run_id: "ntfsimrun_
|
|
|
524
627
|
Paddle::SimulationRunEvent.replay(simulation_id: "ntfsim_abc123", run_id: "ntfsimrun_abc123", id: "ntfsimevt_abc123")
|
|
525
628
|
```
|
|
526
629
|
|
|
630
|
+
### Client Tokens
|
|
631
|
+
|
|
632
|
+
```ruby
|
|
633
|
+
# List all Client Tokens
|
|
634
|
+
# https://developer.paddle.com/api-reference/client-tokens/list-client-tokens
|
|
635
|
+
Paddle::ClientToken.list
|
|
636
|
+
|
|
637
|
+
# Create a Client Token
|
|
638
|
+
# https://developer.paddle.com/api-reference/client-tokens/create-client-token
|
|
639
|
+
Paddle::ClientToken.create name: "My Token"
|
|
640
|
+
|
|
641
|
+
# Get a Client Token
|
|
642
|
+
# https://developer.paddle.com/api-reference/client-tokens/get-client-token
|
|
643
|
+
Paddle::ClientToken.retrieve id: "ctkn_abc123"
|
|
644
|
+
|
|
645
|
+
# Update a Client Token
|
|
646
|
+
# https://developer.paddle.com/api-reference/client-tokens/update-client-token
|
|
647
|
+
Paddle::ClientToken.update id: "ctkn_abc123", status: "revoked"
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
|
|
527
651
|
## Classic API
|
|
528
652
|
|
|
529
653
|
For accessing the Paddle Classic API
|
data/lib/paddle/collection.rb
CHANGED
|
@@ -3,6 +3,9 @@ module Paddle
|
|
|
3
3
|
attr_reader :http_status_code
|
|
4
4
|
attr_reader :paddle_error_code
|
|
5
5
|
attr_reader :paddle_error_message
|
|
6
|
+
attr_reader :paddle_errors
|
|
7
|
+
attr_reader :documentation_url
|
|
8
|
+
attr_reader :request_id
|
|
6
9
|
|
|
7
10
|
def initialize(response_body, http_status_code)
|
|
8
11
|
@response_body = response_body
|
|
@@ -16,6 +19,9 @@ module Paddle
|
|
|
16
19
|
def set_paddle_error_values
|
|
17
20
|
@paddle_error_code = @response_body.dig("error", "code")
|
|
18
21
|
@paddle_error_message = @response_body.dig("error", "detail")
|
|
22
|
+
@paddle_errors = @response_body.dig("error", "errors") || []
|
|
23
|
+
@documentation_url = @response_body.dig("error", "documentation_url")
|
|
24
|
+
@request_id = @response_body.dig("meta", "request_id")
|
|
19
25
|
end
|
|
20
26
|
|
|
21
27
|
def error_message
|
|
@@ -25,10 +31,31 @@ module Paddle
|
|
|
25
31
|
end
|
|
26
32
|
|
|
27
33
|
def build_message
|
|
28
|
-
if paddle_error_code.nil?
|
|
29
|
-
|
|
34
|
+
base_message = if paddle_error_code.nil?
|
|
35
|
+
"Error #{@http_status_code}: #{error_message}"
|
|
36
|
+
else
|
|
37
|
+
"Error #{@http_status_code}: #{error_message} '#{paddle_error_code}'"
|
|
30
38
|
end
|
|
31
|
-
|
|
39
|
+
|
|
40
|
+
# Add detailed field errors if present
|
|
41
|
+
if @paddle_errors && !@paddle_errors.empty?
|
|
42
|
+
field_errors = @paddle_errors.map do |err|
|
|
43
|
+
" - #{err['field']}: #{err['message']}"
|
|
44
|
+
end.join("\n")
|
|
45
|
+
base_message += "\nField errors:\n#{field_errors}"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Add documentation URL if present
|
|
49
|
+
if @documentation_url
|
|
50
|
+
base_message += "\nDocumentation: #{@documentation_url}"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Add request ID if present (useful for support)
|
|
54
|
+
if @request_id
|
|
55
|
+
base_message += "\nRequest ID: #{@request_id}"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
base_message
|
|
32
59
|
end
|
|
33
60
|
end
|
|
34
61
|
|
|
@@ -37,7 +64,8 @@ module Paddle
|
|
|
37
64
|
private
|
|
38
65
|
|
|
39
66
|
def error_message
|
|
40
|
-
|
|
67
|
+
# Use the detailed Paddle error message if available, otherwise fall back to generic message
|
|
68
|
+
@paddle_error_message || "Your request was malformed."
|
|
41
69
|
end
|
|
42
70
|
end
|
|
43
71
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Paddle
|
|
2
|
+
class ClientToken < Object
|
|
3
|
+
class << self
|
|
4
|
+
def list(**params)
|
|
5
|
+
response = Client.get_request("client-tokens", params: params)
|
|
6
|
+
Collection.from_response(response, type: ClientToken)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def create(name:, **params)
|
|
10
|
+
attrs = { name: name }
|
|
11
|
+
response = Client.post_request("client-tokens", body: attrs.merge(params))
|
|
12
|
+
ClientToken.new(response.body["data"])
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def retrieve(id:)
|
|
16
|
+
response = Client.get_request("client-tokens/#{id}")
|
|
17
|
+
ClientToken.new(response.body["data"])
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def update(id:, **params)
|
|
21
|
+
response = Client.patch_request("client-tokens/#{id}", body: params)
|
|
22
|
+
ClientToken.new(response.body["data"])
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -26,6 +26,11 @@ module Paddle
|
|
|
26
26
|
response = Client.get_request("customers/#{id}/credit-balances")
|
|
27
27
|
CreditBalance.new(response.body["data"][0])
|
|
28
28
|
end
|
|
29
|
+
|
|
30
|
+
def auth_token(id:)
|
|
31
|
+
response = Client.post_request("customers/#{id}/auth-token", body: "")
|
|
32
|
+
CustomerAuthToken.new(response.body["data"])
|
|
33
|
+
end
|
|
29
34
|
end
|
|
30
35
|
end
|
|
31
36
|
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module Paddle
|
|
2
|
+
class DiscountGroup < Object
|
|
3
|
+
class << self
|
|
4
|
+
def list(**params)
|
|
5
|
+
response = Client.get_request("discount-groups", params: params)
|
|
6
|
+
Collection.from_response(response, type: DiscountGroup)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def create(name:, **params)
|
|
10
|
+
attrs = { name: name }
|
|
11
|
+
response = Client.post_request("discount-groups", body: attrs.merge(params))
|
|
12
|
+
DiscountGroup.new(response.body["data"])
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def retrieve(id:)
|
|
16
|
+
response = Client.get_request("discount-groups/#{id}")
|
|
17
|
+
DiscountGroup.new(response.body["data"])
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def update(id:, **params)
|
|
21
|
+
response = Client.patch_request("discount-groups/#{id}", body: params)
|
|
22
|
+
DiscountGroup.new(response.body["data"])
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def create_discount(**params)
|
|
27
|
+
Discount.create(discount_group_id: id, **params)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def discounts(**params)
|
|
31
|
+
Discount.list(discount_group_id: id, **params)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Paddle
|
|
2
|
+
class PaymentMethod < Object
|
|
3
|
+
class << self
|
|
4
|
+
def list(customer:, **params)
|
|
5
|
+
response = Client.get_request("customers/#{customer}/payment-methods", params: params)
|
|
6
|
+
Collection.from_response(response, type: PaymentMethod)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def retrieve(customer:, id:)
|
|
10
|
+
response = Client.get_request("customers/#{customer}/payment-methods/#{id}")
|
|
11
|
+
PaymentMethod.new(response.body["data"])
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def delete(customer:, id:)
|
|
15
|
+
Client.delete_request("customers/#{customer}/payment-methods/#{id}")
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/paddle/version.rb
CHANGED
data/lib/paddle.rb
CHANGED
|
@@ -32,6 +32,7 @@ module Paddle
|
|
|
32
32
|
autoload :Price, "paddle/models/price"
|
|
33
33
|
autoload :PricingPreview, "paddle/models/pricing_preview"
|
|
34
34
|
autoload :Discount, "paddle/models/discount"
|
|
35
|
+
autoload :DiscountGroup, "paddle/models/discount_group"
|
|
35
36
|
autoload :Customer, "paddle/models/customer"
|
|
36
37
|
autoload :Address, "paddle/models/address"
|
|
37
38
|
autoload :Business, "paddle/models/business"
|
|
@@ -48,9 +49,12 @@ module Paddle
|
|
|
48
49
|
autoload :SimulationRun, "paddle/models/simulation_run"
|
|
49
50
|
autoload :SimulationRunEvent, "paddle/models/simulation_run_event"
|
|
50
51
|
autoload :PortalSession, "paddle/models/portal_session"
|
|
52
|
+
autoload :PaymentMethod, "paddle/models/payment_method"
|
|
53
|
+
autoload :ClientToken, "paddle/models/client_token"
|
|
51
54
|
|
|
52
55
|
autoload :NotificationLog, "paddle/models/notification_log"
|
|
53
56
|
autoload :CreditBalance, "paddle/models/credit_balance"
|
|
57
|
+
autoload :CustomerAuthToken, "paddle/models/customer_auth_token"
|
|
54
58
|
|
|
55
59
|
# Load Classic APIs
|
|
56
60
|
module Classic
|
data/mise.toml
ADDED
data/paddle.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: paddle
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: '2.9'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dean Perry
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: faraday
|
|
@@ -38,7 +37,20 @@ dependencies:
|
|
|
38
37
|
- - "~>"
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
39
|
version: 0.6.0
|
|
41
|
-
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: cgi
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
42
54
|
email:
|
|
43
55
|
- dean@deanpcmad.com
|
|
44
56
|
executables: []
|
|
@@ -89,14 +101,18 @@ files:
|
|
|
89
101
|
- lib/paddle/models/address.rb
|
|
90
102
|
- lib/paddle/models/adjustment.rb
|
|
91
103
|
- lib/paddle/models/business.rb
|
|
104
|
+
- lib/paddle/models/client_token.rb
|
|
92
105
|
- lib/paddle/models/credit_balance.rb
|
|
93
106
|
- lib/paddle/models/customer.rb
|
|
107
|
+
- lib/paddle/models/customer_auth_token.rb
|
|
94
108
|
- lib/paddle/models/discount.rb
|
|
109
|
+
- lib/paddle/models/discount_group.rb
|
|
95
110
|
- lib/paddle/models/event.rb
|
|
96
111
|
- lib/paddle/models/event_type.rb
|
|
97
112
|
- lib/paddle/models/notification.rb
|
|
98
113
|
- lib/paddle/models/notification_log.rb
|
|
99
114
|
- lib/paddle/models/notification_setting.rb
|
|
115
|
+
- lib/paddle/models/payment_method.rb
|
|
100
116
|
- lib/paddle/models/portal_session.rb
|
|
101
117
|
- lib/paddle/models/price.rb
|
|
102
118
|
- lib/paddle/models/pricing_preview.rb
|
|
@@ -110,13 +126,13 @@ files:
|
|
|
110
126
|
- lib/paddle/models/transaction.rb
|
|
111
127
|
- lib/paddle/object.rb
|
|
112
128
|
- lib/paddle/version.rb
|
|
129
|
+
- mise.toml
|
|
113
130
|
- paddle.gemspec
|
|
114
131
|
homepage: https://github.com/deanpcmad/paddle
|
|
115
132
|
licenses: []
|
|
116
133
|
metadata:
|
|
117
134
|
homepage_uri: https://github.com/deanpcmad/paddle
|
|
118
135
|
source_code_uri: https://github.com/deanpcmad/paddle
|
|
119
|
-
post_install_message:
|
|
120
136
|
rdoc_options: []
|
|
121
137
|
require_paths:
|
|
122
138
|
- lib
|
|
@@ -131,8 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
131
147
|
- !ruby/object:Gem::Version
|
|
132
148
|
version: '0'
|
|
133
149
|
requirements: []
|
|
134
|
-
rubygems_version:
|
|
135
|
-
signing_key:
|
|
150
|
+
rubygems_version: 4.0.3
|
|
136
151
|
specification_version: 4
|
|
137
152
|
summary: Ruby library for the Paddle Billing & Classic APIs
|
|
138
153
|
test_files: []
|