patreonrb 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -2
- data/lib/patreon/object.rb +6 -1
- data/lib/patreon/objects/member.rb +15 -2
- data/lib/patreon/resources/members.rb +3 -12
- data/lib/patreon/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c7b782dd247bad388fd4f4eeeb185efbe3ae5ffdc810fb26e80d09fa0683e39
|
4
|
+
data.tar.gz: '0587ad1a40a7d5e53f7489d4e19ad505f89c34f3c92ae0c0f9809f1a88e91d36'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be1f01f3f6665c3a58510957879b3b61349aaf9ef6d5a28f450c80005fc44cf3a51366195c26a2b35d656e8e7f0e11b6d3a7aa96ceb52e271946599ec5529d4f
|
7
|
+
data.tar.gz: 93438c39c2bb5205c921f663ddf5baa9ba53e160c8e3ab7c0c65343e77ddb7b3bc4acdc9bd88ce65f9903c439c531d75218786e579d9aa20bce8126cd070cbae
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,8 +4,9 @@
|
|
4
4
|
|
5
5
|
PatreonRB is a Ruby library for interacting with the Patreon V2 API.
|
6
6
|
|
7
|
-
This API isn't great so this library tries to add
|
8
|
-
make implementing the Patreon API in
|
7
|
+
This API isn't great so this library tries to add useful fields, such as `user_id` and
|
8
|
+
`campaign_id` on `Patreon::Member`'s, to make implementing the Patreon API in
|
9
|
+
your application much easier.
|
9
10
|
|
10
11
|
## Installation
|
11
12
|
|
data/lib/patreon/object.rb
CHANGED
@@ -8,7 +8,12 @@ module Patreon
|
|
8
8
|
|
9
9
|
def to_ostruct(obj)
|
10
10
|
if obj.is_a?(Hash)
|
11
|
-
if obj["
|
11
|
+
if obj["data"]
|
12
|
+
# For when data is sent to the object, for instance if included is also added
|
13
|
+
if obj["data"]["attributes"]
|
14
|
+
OpenStruct.new(obj["data"]["attributes"].map { |key, val| [key, to_ostruct(val)] }.to_h)
|
15
|
+
end
|
16
|
+
elsif obj["attributes"]
|
12
17
|
# Merge the attributes
|
13
18
|
OpenStruct.new(obj["attributes"].map { |key, val| [key, to_ostruct(val)] }.to_h)
|
14
19
|
else
|
@@ -6,7 +6,13 @@ module Patreon
|
|
6
6
|
def initialize(options = {})
|
7
7
|
super options
|
8
8
|
|
9
|
-
|
9
|
+
if options["data"] && options["data"]["id"]
|
10
|
+
self.id = options["data"]["id"]
|
11
|
+
end
|
12
|
+
|
13
|
+
if options["id"]
|
14
|
+
self.id = options["id"]
|
15
|
+
end
|
10
16
|
|
11
17
|
if options["relationships"] && options["relationships"]["currently_entitled_tiers"]
|
12
18
|
self.currently_entitled_tiers = options["relationships"]["currently_entitled_tiers"]["data"]
|
@@ -28,7 +34,14 @@ module Patreon
|
|
28
34
|
end
|
29
35
|
end
|
30
36
|
|
31
|
-
|
37
|
+
if options["included"]
|
38
|
+
case options["included"][0]["type"]
|
39
|
+
when "tier"
|
40
|
+
self.tier_id = options["included"][0]["id"]
|
41
|
+
self.tier = options["included"][0]["attributes"]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
32
45
|
end
|
33
46
|
|
34
47
|
end
|
@@ -1,18 +1,9 @@
|
|
1
1
|
module Patreon
|
2
2
|
class MembersResource < Resource
|
3
3
|
|
4
|
-
def retrieve(member_id:,
|
5
|
-
|
6
|
-
response
|
7
|
-
response.body
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
def address(member_id:, fields: Address::DEFAULT_FIELDS)
|
12
|
-
|
13
|
-
response = get_request("members/#{member_id}?include=address&fields[address]=#{fields}")#.body#.dig("data")[0]
|
14
|
-
response.body
|
15
|
-
|
4
|
+
def retrieve(member_id:, member_fields: Member::DEFAULT_FIELDS, tier_fields: Tier::DEFAULT_FIELDS)
|
5
|
+
response = get_request("members/#{member_id}?include=currently_entitled_tiers&fields[member]=#{member_fields}&fields[tier]=#{tier_fields}")
|
6
|
+
Member.new response.body
|
16
7
|
end
|
17
8
|
|
18
9
|
end
|
data/lib/patreon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: patreonrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dean Perry
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|