paddlerb 0.1.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +19 -61
- data/.env.example +0 -2
- data/Gemfile +0 -11
- data/Gemfile.lock +0 -29
- data/README.md +0 -35
- data/Rakefile +0 -12
- data/bin/console +0 -20
- data/bin/setup +0 -8
- data/lib/paddle/client.rb +0 -73
- data/lib/paddle/collection.rb +0 -27
- data/lib/paddle/error.rb +0 -4
- data/lib/paddle/object.rb +0 -19
- data/lib/paddle/objects/charge.rb +0 -4
- data/lib/paddle/objects/coupon.rb +0 -4
- data/lib/paddle/objects/license.rb +0 -4
- data/lib/paddle/objects/modifier.rb +0 -4
- data/lib/paddle/objects/pay_link.rb +0 -4
- data/lib/paddle/objects/payment.rb +0 -4
- data/lib/paddle/objects/payment_refund.rb +0 -4
- data/lib/paddle/objects/plan.rb +0 -4
- data/lib/paddle/objects/product.rb +0 -4
- data/lib/paddle/objects/transaction.rb +0 -4
- data/lib/paddle/objects/user.rb +0 -4
- data/lib/paddle/objects/webhook.rb +0 -4
- data/lib/paddle/resource.rb +0 -61
- data/lib/paddle/resources/charges.rb +0 -11
- data/lib/paddle/resources/coupons.rb +0 -31
- data/lib/paddle/resources/licenses.rb +0 -13
- data/lib/paddle/resources/modifiers.rb +0 -24
- data/lib/paddle/resources/pay_links.rb +0 -11
- data/lib/paddle/resources/payments.rb +0 -22
- data/lib/paddle/resources/plans.rb +0 -19
- data/lib/paddle/resources/products.rb +0 -10
- data/lib/paddle/resources/transactions.rb +0 -10
- data/lib/paddle/resources/users.rb +0 -40
- data/lib/paddle/resources/webhooks.rb +0 -10
- data/lib/paddle/version.rb +0 -5
- data/lib/paddle.rb +0 -40
- data/lib/paddlerb.rb +0 -1
- data/paddlerb.gemspec +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb2c0cebfe61f83c3d637e8577caf53929604be9bd2f7d2916bd172f5bb364cd
|
4
|
+
data.tar.gz: 22172014c50a6957824e987bacb591a96a43a8f200ef996ef09f80cac260b2f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98163ed55f5b910576fab519fd89c9454fed186652a5ec0c27c6e8caebd3bfa9b37048725222ab437e5b2f4e9592915936c4cebc3a48380bc6e9bf4c7e2499fd
|
7
|
+
data.tar.gz: 641c71b69045522896ce64ff4d34de480f83de83f5710ed1670254a0f3cee9eb06623120e0afeefeea27dd43da5e29fa1dfd01674d3b64bd7ae26147f777877e
|
metadata
CHANGED
@@ -1,81 +1,39 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paddlerb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dean Perry
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: paddle
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
description:
|
28
|
-
email:
|
29
|
-
- dean@deanpcmad.com
|
26
|
+
version: '0'
|
27
|
+
description: PaddleRB has renamed to Paddle
|
28
|
+
email: dean@deanpcmad.com
|
30
29
|
executables: []
|
31
30
|
extensions: []
|
32
31
|
extra_rdoc_files: []
|
33
|
-
files:
|
34
|
-
|
35
|
-
- Gemfile
|
36
|
-
- Gemfile.lock
|
37
|
-
- README.md
|
38
|
-
- Rakefile
|
39
|
-
- bin/console
|
40
|
-
- bin/setup
|
41
|
-
- lib/paddle.rb
|
42
|
-
- lib/paddle/client.rb
|
43
|
-
- lib/paddle/collection.rb
|
44
|
-
- lib/paddle/error.rb
|
45
|
-
- lib/paddle/object.rb
|
46
|
-
- lib/paddle/objects/charge.rb
|
47
|
-
- lib/paddle/objects/coupon.rb
|
48
|
-
- lib/paddle/objects/license.rb
|
49
|
-
- lib/paddle/objects/modifier.rb
|
50
|
-
- lib/paddle/objects/pay_link.rb
|
51
|
-
- lib/paddle/objects/payment.rb
|
52
|
-
- lib/paddle/objects/payment_refund.rb
|
53
|
-
- lib/paddle/objects/plan.rb
|
54
|
-
- lib/paddle/objects/product.rb
|
55
|
-
- lib/paddle/objects/transaction.rb
|
56
|
-
- lib/paddle/objects/user.rb
|
57
|
-
- lib/paddle/objects/webhook.rb
|
58
|
-
- lib/paddle/resource.rb
|
59
|
-
- lib/paddle/resources/charges.rb
|
60
|
-
- lib/paddle/resources/coupons.rb
|
61
|
-
- lib/paddle/resources/licenses.rb
|
62
|
-
- lib/paddle/resources/modifiers.rb
|
63
|
-
- lib/paddle/resources/pay_links.rb
|
64
|
-
- lib/paddle/resources/payments.rb
|
65
|
-
- lib/paddle/resources/plans.rb
|
66
|
-
- lib/paddle/resources/products.rb
|
67
|
-
- lib/paddle/resources/transactions.rb
|
68
|
-
- lib/paddle/resources/users.rb
|
69
|
-
- lib/paddle/resources/webhooks.rb
|
70
|
-
- lib/paddle/version.rb
|
71
|
-
- lib/paddlerb.rb
|
72
|
-
- paddlerb.gemspec
|
73
|
-
homepage: https://github.com/deanpcmad/paddlerb
|
32
|
+
files: []
|
33
|
+
homepage: https://deanpcmad.com
|
74
34
|
licenses: []
|
75
|
-
metadata:
|
76
|
-
|
77
|
-
source_code_uri: https://github.com/deanpcmad/paddlerb
|
78
|
-
post_install_message:
|
35
|
+
metadata: {}
|
36
|
+
post_install_message:
|
79
37
|
rdoc_options: []
|
80
38
|
require_paths:
|
81
39
|
- lib
|
@@ -83,15 +41,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
41
|
requirements:
|
84
42
|
- - ">="
|
85
43
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
44
|
+
version: '0'
|
87
45
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
46
|
requirements:
|
89
47
|
- - ">="
|
90
48
|
- !ruby/object:Gem::Version
|
91
49
|
version: '0'
|
92
50
|
requirements: []
|
93
|
-
rubygems_version: 3.
|
94
|
-
signing_key:
|
51
|
+
rubygems_version: 3.4.18
|
52
|
+
signing_key:
|
95
53
|
specification_version: 4
|
96
|
-
summary:
|
54
|
+
summary: PaddleRB has renamed to Paddle
|
97
55
|
test_files: []
|
data/.env.example
DELETED
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
paddlerb (0.1.4)
|
5
|
-
faraday (~> 2.0)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
dotenv (2.7.6)
|
11
|
-
faraday (2.2.0)
|
12
|
-
faraday-net_http (~> 2.0)
|
13
|
-
ruby2_keywords (>= 0.0.4)
|
14
|
-
faraday-net_http (2.0.2)
|
15
|
-
minitest (5.15.0)
|
16
|
-
rake (13.0.6)
|
17
|
-
ruby2_keywords (0.0.5)
|
18
|
-
|
19
|
-
PLATFORMS
|
20
|
-
x86_64-linux
|
21
|
-
|
22
|
-
DEPENDENCIES
|
23
|
-
dotenv
|
24
|
-
minitest (~> 5.0)
|
25
|
-
paddlerb!
|
26
|
-
rake (~> 13.0)
|
27
|
-
|
28
|
-
BUNDLED WITH
|
29
|
-
2.3.6
|
data/README.md
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# Paddle
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/paddle`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem "paddlerb"
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle install
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install paddle
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/paddle.
|
data/Rakefile
DELETED
data/bin/console
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "bundler/setup"
|
5
|
-
require "paddle"
|
6
|
-
|
7
|
-
# Load environment variables from .env file
|
8
|
-
require 'dotenv/load'
|
9
|
-
|
10
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
11
|
-
# with your gem easier. You can also use a different console, if you like.
|
12
|
-
|
13
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
14
|
-
# require "pry"
|
15
|
-
# Pry.start
|
16
|
-
|
17
|
-
@client = Paddle::Client.new(vendor_id: ENV["PADDLE_VENDOR_ID"], vendor_auth_code: ENV["PADDLE_VENDOR_AUTH_CODE"], sandbox: true)
|
18
|
-
|
19
|
-
require "irb"
|
20
|
-
IRB.start(__FILE__)
|
data/bin/setup
DELETED
data/lib/paddle/client.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
module Paddle
|
2
|
-
class Client
|
3
|
-
BASE_URL = "https://vendors.paddle.com/api"
|
4
|
-
SANDBOX_BASE_URL = "https://sandbox-vendors.paddle.com/api"
|
5
|
-
|
6
|
-
attr_reader :vendor_id, :vendor_auth_code, :sandbox, :adapter
|
7
|
-
|
8
|
-
def initialize(vendor_id:, vendor_auth_code:, sandbox: false, adapter: Faraday.default_adapter, stubs: nil)
|
9
|
-
@vendor_id = vendor_id
|
10
|
-
@vendor_auth_code = vendor_auth_code
|
11
|
-
@sandbox = sandbox
|
12
|
-
@adapter = adapter
|
13
|
-
|
14
|
-
# Test stubs for requests
|
15
|
-
@stubs = stubs
|
16
|
-
end
|
17
|
-
|
18
|
-
def plans
|
19
|
-
PlansResource.new(self)
|
20
|
-
end
|
21
|
-
|
22
|
-
def coupons
|
23
|
-
CouponsResource.new(self)
|
24
|
-
end
|
25
|
-
|
26
|
-
def products
|
27
|
-
ProductsResource.new(self)
|
28
|
-
end
|
29
|
-
|
30
|
-
def licenses
|
31
|
-
LicensesResource.new(self)
|
32
|
-
end
|
33
|
-
|
34
|
-
def pay_links
|
35
|
-
PayLinksResource.new(self)
|
36
|
-
end
|
37
|
-
|
38
|
-
def transactions
|
39
|
-
TransactionsResource.new(self)
|
40
|
-
end
|
41
|
-
|
42
|
-
def payments
|
43
|
-
PaymentsResource.new(self)
|
44
|
-
end
|
45
|
-
|
46
|
-
def users
|
47
|
-
UsersResource.new(self)
|
48
|
-
end
|
49
|
-
|
50
|
-
def webhooks
|
51
|
-
WebhooksResource.new(self)
|
52
|
-
end
|
53
|
-
|
54
|
-
def modifiers
|
55
|
-
ModifiersResource.new(self)
|
56
|
-
end
|
57
|
-
|
58
|
-
def charges
|
59
|
-
ChargesResource.new(self)
|
60
|
-
end
|
61
|
-
|
62
|
-
def connection
|
63
|
-
url = (sandbox == true ? SANDBOX_BASE_URL : BASE_URL)
|
64
|
-
@connection ||= Faraday.new(url) do |conn|
|
65
|
-
conn.request :json
|
66
|
-
|
67
|
-
conn.response :json, content_type: "application/json"
|
68
|
-
|
69
|
-
conn.adapter adapter, @stubs
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
data/lib/paddle/collection.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
module Paddle
|
2
|
-
class Collection
|
3
|
-
attr_reader :data, :total
|
4
|
-
|
5
|
-
def self.from_response(response, type:, key: nil)
|
6
|
-
body = response.body
|
7
|
-
|
8
|
-
if key.is_a?(String)
|
9
|
-
data = body["response"][key].map { |attrs| type.new(attrs) }
|
10
|
-
total = body["response"]["total"]
|
11
|
-
else
|
12
|
-
data = body["response"].map { |attrs| type.new(attrs) }
|
13
|
-
total = body["response"].count
|
14
|
-
end
|
15
|
-
|
16
|
-
new(
|
17
|
-
data: data,
|
18
|
-
total: total
|
19
|
-
)
|
20
|
-
end
|
21
|
-
|
22
|
-
def initialize(data:, total:)
|
23
|
-
@data = data
|
24
|
-
@total = total
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/paddle/error.rb
DELETED
data/lib/paddle/object.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require "ostruct"
|
2
|
-
|
3
|
-
module Paddle
|
4
|
-
class Object < OpenStruct
|
5
|
-
def initialize(attributes)
|
6
|
-
super to_ostruct(attributes)
|
7
|
-
end
|
8
|
-
|
9
|
-
def to_ostruct(obj)
|
10
|
-
if obj.is_a?(Hash)
|
11
|
-
OpenStruct.new(obj.map { |key, val| [key, to_ostruct(val)] }.to_h)
|
12
|
-
elsif obj.is_a?(Array)
|
13
|
-
obj.map { |o| to_ostruct(o) }
|
14
|
-
else # Assumed to be a primitive value
|
15
|
-
obj
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/lib/paddle/objects/plan.rb
DELETED
data/lib/paddle/objects/user.rb
DELETED
data/lib/paddle/resource.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
module Paddle
|
2
|
-
class Resource
|
3
|
-
attr_reader :client
|
4
|
-
|
5
|
-
def initialize(client)
|
6
|
-
@client = client
|
7
|
-
end
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
# def get_request(url, params: {}, headers: {})
|
12
|
-
# handle_response client.connection.get(url, params, headers)
|
13
|
-
# end
|
14
|
-
|
15
|
-
def post_request(url, body: {}, headers: {})
|
16
|
-
attrs = {vendor_id: client.vendor_id, vendor_auth_code: client.vendor_auth_code}
|
17
|
-
handle_response client.connection.post(url, attrs.merge(body), headers)
|
18
|
-
end
|
19
|
-
|
20
|
-
# def patch_request(url, body:, headers: {})
|
21
|
-
# handle_response client.connection.patch(url, body, headers)
|
22
|
-
# end
|
23
|
-
|
24
|
-
# def put_request(url, body:, headers: {})
|
25
|
-
# handle_response client.connection.put(url, body, headers)
|
26
|
-
# end
|
27
|
-
|
28
|
-
# def delete_request(url, params: {}, headers: {})
|
29
|
-
# handle_response client.connection.delete(url, params, headers)
|
30
|
-
# end
|
31
|
-
|
32
|
-
def handle_response(response)
|
33
|
-
case response.status
|
34
|
-
when 400
|
35
|
-
raise Error, "Error 400: Your request was malformed. '#{response.body["message"]}'"
|
36
|
-
when 401
|
37
|
-
raise Error, "Error 401: You did not supply valid authentication credentials. '#{response.body["error"]}'"
|
38
|
-
when 403
|
39
|
-
raise Error, "Error 403: You are not allowed to perform that action. '#{response.body["error"]}'"
|
40
|
-
when 404
|
41
|
-
raise Error, "Error 404: No results were found for your request. '#{response.body["error"]}'"
|
42
|
-
when 409
|
43
|
-
raise Error, "Error 409: Your request was a conflict. '#{response.body["message"]}'"
|
44
|
-
when 429
|
45
|
-
raise Error, "Error 429: Your request exceeded the API rate limit. '#{response.body["error"]}'"
|
46
|
-
when 500
|
47
|
-
raise Error, "Error 500: We were unable to perform the request due to server-side problems. '#{response.body["error"]}'"
|
48
|
-
when 503
|
49
|
-
raise Error, "Error 503: You have been rate limited for sending more than 20 requests per second. '#{response.body["error"]}'"
|
50
|
-
when 501
|
51
|
-
raise Error, "Error 501: This resource has not been implemented. '#{response.body["error"]}'"
|
52
|
-
end
|
53
|
-
|
54
|
-
if response.body && response.body["error"]
|
55
|
-
raise Error, "Error #{response.body["error"]["code"]} - #{response.body["error"]["message"]}"
|
56
|
-
end
|
57
|
-
|
58
|
-
response
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
module Paddle
|
2
|
-
class ChargesResource < Resource
|
3
|
-
|
4
|
-
def create(subscription_id:, amount:, charge_name:)
|
5
|
-
attrs = {amount: amount, charge_name: charge_name}
|
6
|
-
response = post_request("2.0/subscription/#{subscription_id}/charge", body: attrs)
|
7
|
-
Charge.new(response.body["response"])
|
8
|
-
end
|
9
|
-
|
10
|
-
end
|
11
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Paddle
|
2
|
-
class CouponsResource < Resource
|
3
|
-
|
4
|
-
def list(product_id:)
|
5
|
-
response = post_request("2.0/product/list_coupons", body: {product_id: product_id})
|
6
|
-
Collection.from_response(response, type: Coupon)
|
7
|
-
end
|
8
|
-
|
9
|
-
def create(coupon_type:, discount_type:, discount_amount:, **params)
|
10
|
-
attrs = {coupon_type: coupon_type, discount_type: discount_type, discount_amount: discount_amount}
|
11
|
-
|
12
|
-
response = post_request("2.1/product/create_coupon", body: attrs.merge(params))
|
13
|
-
|
14
|
-
coupons = response.body["response"]["coupon_codes"]
|
15
|
-
|
16
|
-
coupons.map {|c| Paddle::Coupon.new(code: c)}
|
17
|
-
end
|
18
|
-
|
19
|
-
def delete(coupon_code:, product_id:)
|
20
|
-
attrs = {coupon_code: coupon_code, product_id: product_id}
|
21
|
-
response = post_request("2.0/product/delete_coupon", body: attrs)
|
22
|
-
return true if response.success?
|
23
|
-
end
|
24
|
-
|
25
|
-
def update(**params)
|
26
|
-
response = post_request("2.1/product/update_coupon", body: params)
|
27
|
-
return true if response.success?
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Paddle
|
2
|
-
class LicensesResource < Resource
|
3
|
-
|
4
|
-
def generate(product_id:, allowed_uses:, **params)
|
5
|
-
attrs = {product_id: product_id, allowed_uses: allowed_uses}
|
6
|
-
|
7
|
-
response = post_request("2.0/product/generate_license", body: attrs.merge(params))
|
8
|
-
|
9
|
-
License.new(response.body["response"]) if response.success?
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Paddle
|
2
|
-
class ModifiersResource < Resource
|
3
|
-
|
4
|
-
def list(**params)
|
5
|
-
response = post_request("2.0/subscription/modifiers", body: params)
|
6
|
-
Collection.from_response(response, type: Modifier)
|
7
|
-
end
|
8
|
-
|
9
|
-
def create(subscription_id:, modifier_amount:, **params)
|
10
|
-
attrs = {subscription_id: subscription_id, modifier_amount: modifier_amount}
|
11
|
-
create_response = post_request("2.0/subscription/modifiers/create", body: attrs.merge(params))
|
12
|
-
|
13
|
-
response = post_request("2.0/subscription/modifiers", body: {subscription_id: subscription_id} )
|
14
|
-
Collection.from_response(response, type: Modifier)
|
15
|
-
end
|
16
|
-
|
17
|
-
def delete(modifier_id:)
|
18
|
-
attrs = {modifier_id: modifier_id}
|
19
|
-
response = post_request("2.0/subscription/modifiers/delete", body: attrs)
|
20
|
-
return true if response.success?
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Paddle
|
2
|
-
class PaymentsResource < Resource
|
3
|
-
|
4
|
-
def list(**params)
|
5
|
-
response = post_request("2.0/subscription/payments", body: params)
|
6
|
-
Collection.from_response(response, type: Payment)
|
7
|
-
end
|
8
|
-
|
9
|
-
def reschedule(payment_id:, date:)
|
10
|
-
attrs = {payment_id: payment_id, date: date}
|
11
|
-
response = post_request("2.0/subscription/payments_reschedule", body: attrs)
|
12
|
-
return true if response.success?
|
13
|
-
end
|
14
|
-
|
15
|
-
def refund(order_id:, **params)
|
16
|
-
attrs = {order_id: order_id}
|
17
|
-
response = post_request("2.0/payment/refund", body: attrs.merge(params))
|
18
|
-
PaymentRefund.new(response.body["response"])
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Paddle
|
2
|
-
class PlansResource < Resource
|
3
|
-
|
4
|
-
def list
|
5
|
-
response = post_request("2.0/subscription/plans")
|
6
|
-
Collection.from_response(response, type: Plan)
|
7
|
-
end
|
8
|
-
|
9
|
-
def create(name:, type:, **params)
|
10
|
-
attrs = {plan_name: name, plan_type: type}
|
11
|
-
create_response = post_request("2.0/subscription/plans_create", body: attrs.merge(params))
|
12
|
-
|
13
|
-
# After creating the Plan, because it doesn't return the whole record, grab it from the API and return that
|
14
|
-
response = post_request("2.0/subscription/plans", body: {plan: create_response.body["response"]["product_id"]} )
|
15
|
-
Plan.new(response.body.dig("response")[0]) if response.success?
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module Paddle
|
2
|
-
class UsersResource < Resource
|
3
|
-
|
4
|
-
def list(**params)
|
5
|
-
response = post_request("2.0/subscription/users", body: params)
|
6
|
-
Collection.from_response(response, type: User)
|
7
|
-
end
|
8
|
-
|
9
|
-
def update(subscription_id:, **params)
|
10
|
-
attrs = {subscription_id: subscription_id}
|
11
|
-
response = post_request("2.0/subscription/users/update", body: attrs.merge(params))
|
12
|
-
User.new(response.body["response"]) if response.success?
|
13
|
-
end
|
14
|
-
|
15
|
-
def pause(subscription_id:, **params)
|
16
|
-
attrs = {subscription_id: subscription_id, pause: true}
|
17
|
-
response = post_request("2.0/subscription/users/update", body: attrs.merge(params))
|
18
|
-
User.new(response.body["response"]) if response.success?
|
19
|
-
end
|
20
|
-
|
21
|
-
def unpause(subscription_id:, **params)
|
22
|
-
attrs = {subscription_id: subscription_id, pause: false}
|
23
|
-
response = post_request("2.0/subscription/users/update", body: attrs.merge(params))
|
24
|
-
User.new(response.body["response"]) if response.success?
|
25
|
-
end
|
26
|
-
|
27
|
-
def update_postcode(subscription_id:, postcode:)
|
28
|
-
attrs = {subscription_id: subscription_id, postcode: postcode}
|
29
|
-
response = post_request("2.0/subscription/users/postcode", body: attrs)
|
30
|
-
return true if response.success?
|
31
|
-
end
|
32
|
-
|
33
|
-
def cancel(subscription_id:)
|
34
|
-
attrs = {subscription_id: subscription_id}
|
35
|
-
response = post_request("2.0/subscription/users_cancel", body: attrs)
|
36
|
-
return true if response.success?
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
data/lib/paddle/version.rb
DELETED
data/lib/paddle.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "faraday"
|
4
|
-
|
5
|
-
require_relative "paddle/version"
|
6
|
-
|
7
|
-
module Paddle
|
8
|
-
|
9
|
-
autoload :Client, "paddle/client"
|
10
|
-
autoload :Collection, "paddle/collection"
|
11
|
-
autoload :Error, "paddle/error"
|
12
|
-
autoload :Resource, "paddle/resource"
|
13
|
-
autoload :Object, "paddle/object"
|
14
|
-
|
15
|
-
autoload :PlansResource, "paddle/resources/plans"
|
16
|
-
autoload :CouponsResource, "paddle/resources/coupons"
|
17
|
-
autoload :ProductsResource, "paddle/resources/products"
|
18
|
-
autoload :LicensesResource, "paddle/resources/licenses"
|
19
|
-
autoload :PayLinksResource, "paddle/resources/pay_links"
|
20
|
-
autoload :TransactionsResource, "paddle/resources/transactions"
|
21
|
-
autoload :PaymentsResource, "paddle/resources/payments"
|
22
|
-
autoload :UsersResource, "paddle/resources/users"
|
23
|
-
autoload :WebhooksResource, "paddle/resources/webhooks"
|
24
|
-
autoload :ModifiersResource, "paddle/resources/modifiers"
|
25
|
-
autoload :ChargesResource, "paddle/resources/charges"
|
26
|
-
|
27
|
-
autoload :Plan, "paddle/objects/plan"
|
28
|
-
autoload :Coupon, "paddle/objects/coupon"
|
29
|
-
autoload :Product, "paddle/objects/product"
|
30
|
-
autoload :License, "paddle/objects/license"
|
31
|
-
autoload :PayLink, "paddle/objects/pay_link"
|
32
|
-
autoload :Transaction, "paddle/objects/transaction"
|
33
|
-
autoload :Payment, "paddle/objects/payment"
|
34
|
-
autoload :PaymentRefund, "paddle/objects/payment_refund"
|
35
|
-
autoload :User, "paddle/objects/user"
|
36
|
-
autoload :Webhook, "paddle/objects/webhook"
|
37
|
-
autoload :Modifier, "paddle/objects/modifier"
|
38
|
-
autoload :Charge, "paddle/objects/charge"
|
39
|
-
|
40
|
-
end
|
data/lib/paddlerb.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "paddle"
|
data/paddlerb.gemspec
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "lib/paddle/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "paddlerb"
|
7
|
-
spec.version = Paddle::VERSION
|
8
|
-
spec.authors = ["Dean Perry"]
|
9
|
-
spec.email = ["dean@deanpcmad.com"]
|
10
|
-
|
11
|
-
spec.summary = "Ruby library for interacting with the Paddle API"
|
12
|
-
# spec.description = "TODO: Write a longer description or delete this line."
|
13
|
-
spec.homepage = "https://github.com/deanpcmad/paddlerb"
|
14
|
-
spec.required_ruby_version = ">= 2.6.0"
|
15
|
-
|
16
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
-
spec.metadata["source_code_uri"] = "https://github.com/deanpcmad/paddlerb"
|
18
|
-
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
19
|
-
|
20
|
-
# Specify which files should be added to the gem when it is released.
|
21
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
23
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
24
|
-
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
25
|
-
end
|
26
|
-
end
|
27
|
-
spec.bindir = "exe"
|
28
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
29
|
-
spec.require_paths = ["lib"]
|
30
|
-
|
31
|
-
spec.add_dependency "faraday", "~> 2.0"
|
32
|
-
end
|