lemonsqueezy 0.2.2 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env.example +2 -1
- data/Gemfile +2 -1
- data/Gemfile.lock +13 -9
- data/README.md +194 -68
- data/bin/console +3 -1
- data/lib/lemon_squeezy/client.rb +57 -63
- data/lib/lemon_squeezy/configuration.rb +12 -0
- data/lib/lemon_squeezy/models/checkout.rb +46 -0
- data/lib/lemon_squeezy/models/customer.rb +52 -0
- data/lib/lemon_squeezy/models/discount.rb +47 -0
- data/lib/lemon_squeezy/models/discount_redemption.rb +19 -0
- data/lib/lemon_squeezy/models/file.rb +19 -0
- data/lib/lemon_squeezy/models/license.rb +24 -0
- data/lib/lemon_squeezy/models/license_key.rb +32 -0
- data/lib/lemon_squeezy/models/license_key_instance.rb +19 -0
- data/lib/lemon_squeezy/models/order.rb +24 -0
- data/lib/lemon_squeezy/models/price.rb +19 -0
- data/lib/lemon_squeezy/models/product.rb +19 -0
- data/lib/lemon_squeezy/models/store.rb +19 -0
- data/lib/lemon_squeezy/models/subscription.rb +101 -0
- data/lib/lemon_squeezy/models/subscription_invoice.rb +19 -0
- data/lib/lemon_squeezy/models/subscription_item.rb +38 -0
- data/lib/lemon_squeezy/models/subscription_usage.rb +4 -0
- data/lib/lemon_squeezy/models/user.rb +14 -0
- data/lib/lemon_squeezy/models/variant.rb +19 -0
- data/lib/lemon_squeezy/models/webhook.rb +58 -0
- data/lib/lemon_squeezy/object.rb +15 -1
- data/lib/lemon_squeezy/version.rb +1 -1
- data/lib/lemon_squeezy.rb +34 -29
- metadata +23 -29
- data/lib/lemon_squeezy/objects/checkout.rb +0 -12
- data/lib/lemon_squeezy/objects/customer.rb +0 -12
- data/lib/lemon_squeezy/objects/discount.rb +0 -12
- data/lib/lemon_squeezy/objects/file.rb +0 -12
- data/lib/lemon_squeezy/objects/license_key.rb +0 -12
- data/lib/lemon_squeezy/objects/license_key_instance.rb +0 -12
- data/lib/lemon_squeezy/objects/order.rb +0 -12
- data/lib/lemon_squeezy/objects/order_item.rb +0 -12
- data/lib/lemon_squeezy/objects/product.rb +0 -12
- data/lib/lemon_squeezy/objects/store.rb +0 -12
- data/lib/lemon_squeezy/objects/subscription.rb +0 -12
- data/lib/lemon_squeezy/objects/subscription_invoice.rb +0 -12
- data/lib/lemon_squeezy/objects/variant.rb +0 -12
- data/lib/lemon_squeezy/resource.rb +0 -60
- data/lib/lemon_squeezy/resources/checkouts.rb +0 -42
- data/lib/lemon_squeezy/resources/customers.rb +0 -15
- data/lib/lemon_squeezy/resources/discounts.rb +0 -15
- data/lib/lemon_squeezy/resources/files.rb +0 -15
- data/lib/lemon_squeezy/resources/license_key_instances.rb +0 -15
- data/lib/lemon_squeezy/resources/license_keys.rb +0 -15
- data/lib/lemon_squeezy/resources/orders.rb +0 -20
- data/lib/lemon_squeezy/resources/products.rb +0 -15
- data/lib/lemon_squeezy/resources/stores.rb +0 -15
- data/lib/lemon_squeezy/resources/subscription_invoices.rb +0 -15
- data/lib/lemon_squeezy/resources/subscriptions.rb +0 -92
- data/lib/lemon_squeezy/resources/variants.rb +0 -15
@@ -1,92 +0,0 @@
|
|
1
|
-
module LemonSqueezy
|
2
|
-
class SubscriptionsResource < Resource
|
3
|
-
|
4
|
-
def list(**params)
|
5
|
-
response = get_request("subscriptions", params: params)
|
6
|
-
Collection.from_response(response, type: Subscription)
|
7
|
-
end
|
8
|
-
|
9
|
-
def get(id:)
|
10
|
-
response = get_request("subscriptions/#{id}")
|
11
|
-
Subscription.new(response.body["data"]) if response.success?
|
12
|
-
end
|
13
|
-
|
14
|
-
# Kind: void or free
|
15
|
-
def pause(id:, kind:, resumes_at: nil)
|
16
|
-
body = {
|
17
|
-
data: {
|
18
|
-
type: "subscriptions",
|
19
|
-
id: id.to_s,
|
20
|
-
attributes: {
|
21
|
-
pause: {mode: kind, resumes_at: resumes_at}
|
22
|
-
}
|
23
|
-
}
|
24
|
-
}
|
25
|
-
|
26
|
-
response = patch_request("subscriptions/#{id}", body: body.to_json)
|
27
|
-
Subscription.new(response.body["data"]) if response.success?
|
28
|
-
end
|
29
|
-
|
30
|
-
def unpause(id:)
|
31
|
-
body = {
|
32
|
-
data: {
|
33
|
-
type: "subscriptions",
|
34
|
-
id: id.to_s,
|
35
|
-
attributes: {
|
36
|
-
pause: nil
|
37
|
-
}
|
38
|
-
}
|
39
|
-
}
|
40
|
-
|
41
|
-
response = patch_request("subscriptions/#{id}", body: body.to_json)
|
42
|
-
Subscription.new(response.body["data"]) if response.success?
|
43
|
-
end
|
44
|
-
|
45
|
-
def cancel(id:)
|
46
|
-
body = {
|
47
|
-
data: {
|
48
|
-
type: "subscriptions",
|
49
|
-
id: id.to_s,
|
50
|
-
attributes: {
|
51
|
-
cancelled: true
|
52
|
-
}
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
response = patch_request("subscriptions/#{id}", body: body.to_json)
|
57
|
-
Subscription.new(response.body["data"]) if response.success?
|
58
|
-
end
|
59
|
-
|
60
|
-
def uncancel(id:)
|
61
|
-
body = {
|
62
|
-
data: {
|
63
|
-
type: "subscriptions",
|
64
|
-
id: id.to_s,
|
65
|
-
attributes: {
|
66
|
-
cancelled: false
|
67
|
-
}
|
68
|
-
}
|
69
|
-
}
|
70
|
-
|
71
|
-
response = patch_request("subscriptions/#{id}", body: body.to_json)
|
72
|
-
Subscription.new(response.body["data"]) if response.success?
|
73
|
-
end
|
74
|
-
|
75
|
-
def change_plan(id:, plan_id:, variant_id:)
|
76
|
-
body = {
|
77
|
-
data: {
|
78
|
-
type: "subscriptions",
|
79
|
-
id: id.to_s,
|
80
|
-
attributes: {
|
81
|
-
product_id: plan_id,
|
82
|
-
variant_id: variant_id
|
83
|
-
}
|
84
|
-
}
|
85
|
-
}
|
86
|
-
|
87
|
-
response = patch_request("subscriptions/#{id}", body: body.to_json)
|
88
|
-
Subscription.new(response.body["data"]) if response.success?
|
89
|
-
end
|
90
|
-
|
91
|
-
end
|
92
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module LemonSqueezy
|
2
|
-
class VariantsResource < Resource
|
3
|
-
|
4
|
-
def list(**params)
|
5
|
-
response = get_request("variants", params: params)
|
6
|
-
Collection.from_response(response, type: Variant)
|
7
|
-
end
|
8
|
-
|
9
|
-
def get(id:)
|
10
|
-
response = get_request("variants/#{id}")
|
11
|
-
Variant.new(response.body["data"]) if response.success?
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|