peasy 0.1.0 → 0.2.0
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/README.md +18 -8
- data/lib/peasy/subscription.rb +20 -0
- data/lib/peasy/version.rb +1 -1
- data/peasy-0.1.0.gem +0 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b58794b72afbfa61ea1fcc6f12a294a5a1dcbbfd150c837bbb37b9fda6be0e4
|
4
|
+
data.tar.gz: ef94499dd0dc891bdb91fc984dc6c434c0ba02827438b8335d22cf6197f9e510
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b776ce0ee0f8827c4434bc12f31b4cd8d9b3e3e79431e0325c788af7e0c21bd7fbb98ee9e7bd717e4e78dcbd49a08de9ef78bd9a3f3949b0eb0872cc8f303a5
|
7
|
+
data.tar.gz: cc37ee5214382c6fcdf117090bfdd95bb228349c9c7edda6d3eb45f1e93c6ba76c65987e44db3d46bf3138b664d3606e053f9fb3618f9d133ee5991a078ead84
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Peasy
|
2
2
|
|
3
|
-
|
3
|
+
An Easy Peasy way to use LemonSqueezy.
|
4
4
|
|
5
|
-
|
5
|
+
This gem lets you use the LemonSqueezy API to manage subscriptions from your application.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -22,17 +22,27 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
This is super basic, and there are currently no tests. Probably don't use in production unless you know what the code does.
|
26
26
|
|
27
|
-
|
27
|
+
### Get Subscription
|
28
28
|
|
29
|
-
|
29
|
+
If you know the subscription ID from LemonSqueezy (likely you've saved it already to your application's database), you can query the API to get the response.
|
30
30
|
|
31
|
-
|
31
|
+
```
|
32
|
+
Peasy::Subscription.find(API_KEY, SUBSCRIPTION_ID)
|
33
|
+
```
|
34
|
+
|
35
|
+
### Cancel Subscription
|
36
|
+
|
37
|
+
As above, if you know the subscription ID from LemonSqueezy, you can instruct the API to cancel the relevant subscription.
|
38
|
+
|
39
|
+
```
|
40
|
+
Peasy::Subscription.cancel(API_KEY, SUBSCRIPTION_ID)
|
41
|
+
```
|
32
42
|
|
33
|
-
##
|
43
|
+
## To Do
|
34
44
|
|
35
|
-
|
45
|
+
There's a lot of endpoints left to map here, and there's also going to be some refactoring to do and tests to write
|
36
46
|
|
37
47
|
## License
|
38
48
|
|
data/lib/peasy/subscription.rb
CHANGED
@@ -14,7 +14,27 @@ module Peasy
|
|
14
14
|
request['Authorization'] = "Bearer #{key}"
|
15
15
|
|
16
16
|
response = http.request(request)
|
17
|
+
response = JSON.parse(response.body)
|
17
18
|
|
18
19
|
end
|
20
|
+
|
21
|
+
def self.cancel(key, id)
|
22
|
+
require 'net/http'
|
23
|
+
|
24
|
+
uri = URI.parse("https://api.lemonsqueezy.com/v1/subscriptions/#{id}")
|
25
|
+
|
26
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
27
|
+
http.use_ssl = true if uri.instance_of? URI::HTTPS
|
28
|
+
|
29
|
+
request = Net::HTTP::Patch.new(uri.request_uri)
|
30
|
+
request['Content-Type'] = 'application/vnd.api+json'
|
31
|
+
request['Accept'] = 'application/vnd.api+json'
|
32
|
+
request['Authorization'] = "Bearer #{key}"
|
33
|
+
request.body = {data: {type: "subscriptions", id: "#{id}", attributes: {cancelled: true}}}.to_json
|
34
|
+
|
35
|
+
response = http.request(request)
|
36
|
+
response = JSON.parse(response.body)
|
37
|
+
|
38
|
+
end
|
19
39
|
end
|
20
40
|
end
|
data/lib/peasy/version.rb
CHANGED
data/peasy-0.1.0.gem
ADDED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peasy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Farnworth
|
@@ -30,6 +30,7 @@ files:
|
|
30
30
|
- lib/peasy.rb
|
31
31
|
- lib/peasy/subscription.rb
|
32
32
|
- lib/peasy/version.rb
|
33
|
+
- peasy-0.1.0.gem
|
33
34
|
- peasy.gemspec
|
34
35
|
homepage: https://github.com/stevefarnworth/peasy
|
35
36
|
licenses:
|