paddle 2.0.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 752f7683042e6de26cf820e4e1223ac99b697100fd65f7680b2808fe5d0e1f44
4
- data.tar.gz: c34ef3933969ef4a62277d68f42040883e886226e1b092a687075b5c03db33e0
3
+ metadata.gz: c3b202300a613f8c4d1af151903c225f725c29e0457746d9bab2cf8c95d19d56
4
+ data.tar.gz: 0ae818794c9d212e744c91a23892c9ffbb378bc333fc659fd51f75f8c2537aec
5
5
  SHA512:
6
- metadata.gz: 378eecb14a3a505c1c6e5e63cb08679cbc1f36487086e5d0b27cb37a61b9807aee53cb8d68e199a6bd950e11b539036750646544848cd98ef9bc946d1f43261b
7
- data.tar.gz: d214b18631249d7a8056c2ab82d9a414a3022982e93c4a4dbf2a7d370f99e7a3beeddbde95fd17e511891569839ed7111bbab307f7e0a6d8718916221e5da1b5
6
+ metadata.gz: 8e153e5b7116826cba567a00d73c9a3dbf86996f1d4fedf25d005a759d70e7f8e1e7458d45b7946006c82e350da63db57a6af4b86eb23a629a5597102f4f8ee7
7
+ data.tar.gz: 98156c3bc98bf3c15152a7457076514b9938aec353992fd97faa1673821a8b3886685b8c638d410e96ee44bb2a6d7668c4ea13660bec7fcc4076c2dabb0afc9a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paddle (2.0.0)
4
+ paddle (2.1.1)
5
5
  faraday (~> 2.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -7,7 +7,7 @@ A Ruby library for the Paddle APIs, both Classic and Billing.
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem "paddle", "~> 2.0"
10
+ gem "paddle", "~> 2.1"
11
11
  ```
12
12
 
13
13
  ## Billing API
@@ -27,6 +27,9 @@ Paddle.configure do |config|
27
27
  # Or use :production for the Production API
28
28
  config.environment = :sandbox
29
29
  config.api_key = ENV["PADDLE_API_KEY"]
30
+
31
+ # Set the API version. Defaults to 1
32
+ config.version = 1
30
33
  end
31
34
  ```
32
35
 
@@ -183,6 +186,10 @@ Paddle::Transaction.create(items: [ { price_id: "pri_abc123", quantity: 1 } ])
183
186
  # Retrieve a transaction
184
187
  Paddle::Transaction.retrieve(id: "txn_abc123")
185
188
 
189
+ # Retrieve a transaction with extra information
190
+ # extra can be either "address", "adjustment", "adjustments_totals", "business", "customer", "discount"
191
+ Paddle::Transaction.retrieve(id: "txn_abc123", extra: "customer")
192
+
186
193
  # Update a transaction
187
194
  # https://developer.paddle.com/api-reference/transaction/update-transaction
188
195
  Paddle::Transaction.update(id: "txn_abc123", items: [ { price_id: "pri_abc123", quantity: 2 } ])
@@ -211,6 +218,10 @@ Paddle::Subscription.list(status: "canceled")
211
218
  # Retrieve a subscription
212
219
  Paddle::Subscription.retrieve(id: "sub_abc123")
213
220
 
221
+ # Retrieve a subscription with extra information
222
+ # extra can be either "next_transaction" or "recurring_transaction_details"
223
+ Paddle::Subscription.retrieve(id: "sub_abc123", extra: "next_transaction")
224
+
214
225
  # Preview an update to a subscription
215
226
  # https://developer.paddle.com/api-reference/subscriptions/preview-subscription
216
227
  Paddle::Subscription.preview(id: "sub_abc123", items: [ { price_id: "pri_123abc", quantity: 2 } ])
data/lib/paddle/client.rb CHANGED
@@ -8,7 +8,8 @@ module Paddle
8
8
  conn.request :authorization, :Bearer, Paddle.config.api_key
9
9
 
10
10
  conn.headers = {
11
- "User-Agent" => "paddle/v#{VERSION} (github.com/deanpcmad/paddle)"
11
+ "User-Agent" => "paddle/v#{VERSION} (github.com/deanpcmad/paddle)",
12
+ "Paddle-Version" => Paddle.config.version.to_s
12
13
  }
13
14
 
14
15
  conn.request :json
@@ -5,10 +5,12 @@ module Paddle
5
5
 
6
6
  attr_reader :environment
7
7
 
8
+ attr_accessor :version
8
9
  attr_accessor :api_key
9
10
 
10
11
  def initialize
11
12
  @environment ||= :production
13
+ @version ||= 1
12
14
  end
13
15
 
14
16
  def environment=(env)
@@ -9,7 +9,7 @@ module Paddle
9
9
  end
10
10
 
11
11
  def create(email:, **params)
12
- attrs = {email: email}
12
+ attrs = {email: email.gsub(/\s+/, "")}
13
13
  response = Client.post_request("customers", body: attrs.merge(params))
14
14
  Customer.new(response.body["data"])
15
15
  end
@@ -8,14 +8,15 @@ module Paddle
8
8
  Collection.from_response(response, type: Subscription)
9
9
  end
10
10
 
11
- def retrieve(id:)
12
- response = Client.get_request("subscriptions/#{id}")
11
+ def retrieve(id:, extra: nil)
12
+ params = extra ? {include: extra} : {}
13
+ response = Client.get_request("subscriptions/#{id}", params: params)
13
14
  Subscription.new(response.body["data"])
14
15
  end
15
16
 
16
17
  def get_transaction(id:)
17
18
  response = Client.get_request("subscriptions/#{id}/update-payment-method-transaction")
18
- Subscription.new(response.body["data"])
19
+ Transaction.new(response.body["data"])
19
20
  end
20
21
 
21
22
  def preview(id:, **params)
@@ -14,8 +14,9 @@ module Paddle
14
14
  Transaction.new(response.body["data"])
15
15
  end
16
16
 
17
- def retrieve(id:)
18
- response = Client.get_request("transactions/#{id}")
17
+ def retrieve(id:, extra: nil)
18
+ params = extra ? {include: extra} : {}
19
+ response = Client.get_request("transactions/#{id}", params: params)
19
20
  Transaction.new(response.body["data"])
20
21
  end
21
22
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paddle
4
- VERSION = "2.0.0"
4
+ VERSION = "2.1.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paddle
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dean Perry
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-30 00:00:00.000000000 Z
11
+ date: 2023-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
- description:
27
+ description:
28
28
  email:
29
29
  - dean@deanpcmad.com
30
30
  executables: []
@@ -92,7 +92,7 @@ licenses: []
92
92
  metadata:
93
93
  homepage_uri: https://github.com/deanpcmad/paddle
94
94
  source_code_uri: https://github.com/deanpcmad/paddle
95
- post_install_message:
95
+ post_install_message:
96
96
  rdoc_options: []
97
97
  require_paths:
98
98
  - lib
@@ -107,8 +107,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  requirements: []
110
- rubygems_version: 3.4.18
111
- signing_key:
110
+ rubygems_version: 3.4.10
111
+ signing_key:
112
112
  specification_version: 4
113
113
  summary: Ruby library for the Paddle Billing & Classic APIs
114
114
  test_files: []