Class: Patreon::Member
- Defined in:
- lib/patreon/objects/member.rb
Constant Summary collapse
- DEFAULT_FIELDS =
"campaign_lifetime_support_cents,currently_entitled_amount_cents,email,full_name,is_follower,last_charge_date,last_charge_status,lifetime_support_cents,next_charge_date,note,patron_status,pledge_cadence,pledge_relationship_start,will_pay_amount_cents"
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Member
constructor
A new instance of Member.
Methods inherited from Object
Constructor Details
#initialize(options = {}) ⇒ Member
Returns a new instance of Member.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/patreon/objects/member.rb', line 6 def initialize( = {}) super if ["data"] && ["data"]["id"] self.id = ["data"]["id"] end if ["id"] self.id = ["id"] end if ["relationships"] && ["relationships"]["currently_entitled_tiers"] self.currently_entitled_tiers = ["relationships"]["currently_entitled_tiers"]["data"] end if ["relationships"] self.relationships = ["relationships"].map {|r| { r[0] => r[1]['data']['id'] } } ["relationships"].each do |rel| rel_type = rel[1]["data"]["type"] rel_id = rel[1]["data"]["id"] case rel_type when "user" self.user_id = rel_id when "campaign" self.campaign_id = rel_id end end end if ["included"] case ["included"][0]["type"] when "tier" self.tier_id = ["included"][0]["id"] self.tier = ["included"][0]["attributes"] end end end |