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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ab3e0e7e8c9030e9309ea077b189e5d2afcf8d26848d3b1fcae2611138c4e0e
4
- data.tar.gz: caf44ce1048305d57d3e379663a3b0ad85cf7f978de91d7a71d24b1e3d3762d3
3
+ metadata.gz: 0c7b782dd247bad388fd4f4eeeb185efbe3ae5ffdc810fb26e80d09fa0683e39
4
+ data.tar.gz: '0587ad1a40a7d5e53f7489d4e19ad505f89c34f3c92ae0c0f9809f1a88e91d36'
5
5
  SHA512:
6
- metadata.gz: ee4009bffbe0e79f9280d80b251ae9081643a7760b468221c6309c1f8a4bcce52bd0a5cd1dab268222c8e759f3a1acb46e073271366273121543f216e2fe5dc0
7
- data.tar.gz: 169e6902cb2fd4813cffd916f60414855ea2456a897a1fc903320db4dcc35b95fccc47a9d7369163673d263fc6adacdb65e84805583cfe50096169900829a44c
6
+ metadata.gz: be1f01f3f6665c3a58510957879b3b61349aaf9ef6d5a28f450c80005fc44cf3a51366195c26a2b35d656e8e7f0e11b6d3a7aa96ceb52e271946599ec5529d4f
7
+ data.tar.gz: 93438c39c2bb5205c921f663ddf5baa9ba53e160c8e3ab7c0c65343e77ddb7b3bc4acdc9bd88ce65f9903c439c531d75218786e579d9aa20bce8126cd070cbae
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- patreonrb (0.1.0)
4
+ patreonrb (0.1.1)
5
5
  faraday (~> 2.0)
6
6
 
7
7
  GEM
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 required fields, such as `user_id` on `Patreon::Member`'s, to
8
- make implementing the Patreon API in your application much easier.
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
 
@@ -8,7 +8,12 @@ module Patreon
8
8
 
9
9
  def to_ostruct(obj)
10
10
  if obj.is_a?(Hash)
11
- if obj["attributes"]
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
- self.id = options["id"] if options["id"]
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
- # self.included = options["included"]
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:, fields: Member::DEFAULT_FIELDS)
5
-
6
- response = get_request("members/#{member_id}?include=currently_entitled_tiers&fields[member]=#{fields}&fields[tier]=#{Tier::DEFAULT_FIELDS}")#.body#.dig("data")[0]
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
@@ -1,3 +1,3 @@
1
1
  module Patreon
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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-06 00:00:00.000000000 Z
11
+ date: 2022-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday