Class: LinkIO::ReferralData
- Inherits:
-
Object
- Object
- LinkIO::ReferralData
- Defined in:
- lib/linkio/referral_data.rb
Overview
A referral relationship between a referrer and a referee.
timestamp is epoch milliseconds, matching the Node.js backend.
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#referee_id ⇒ Object
readonly
Returns the value of attribute referee_id.
-
#referral_code ⇒ Object
readonly
Returns the value of attribute referral_code.
-
#referrer_id ⇒ Object
readonly
Returns the value of attribute referrer_id.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Class Method Summary collapse
-
.from_h(hash) ⇒ ReferralData
Build from a hash using either camelCase or snake_case keys.
Instance Method Summary collapse
-
#initialize(referrer_id:, referee_id:, referral_code:, timestamp:, metadata: nil) ⇒ ReferralData
constructor
A new instance of ReferralData.
- #to_h ⇒ Hash
Constructor Details
#initialize(referrer_id:, referee_id:, referral_code:, timestamp:, metadata: nil) ⇒ ReferralData
Returns a new instance of ReferralData.
14 15 16 17 18 19 20 |
# File 'lib/linkio/referral_data.rb', line 14 def initialize(referrer_id:, referee_id:, referral_code:, timestamp:, metadata: nil) @referrer_id = referrer_id @referee_id = referee_id @referral_code = referral_code @timestamp = @metadata = end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
7 8 9 |
# File 'lib/linkio/referral_data.rb', line 7 def @metadata end |
#referee_id ⇒ Object (readonly)
Returns the value of attribute referee_id.
7 8 9 |
# File 'lib/linkio/referral_data.rb', line 7 def referee_id @referee_id end |
#referral_code ⇒ Object (readonly)
Returns the value of attribute referral_code.
7 8 9 |
# File 'lib/linkio/referral_data.rb', line 7 def referral_code @referral_code end |
#referrer_id ⇒ Object (readonly)
Returns the value of attribute referrer_id.
7 8 9 |
# File 'lib/linkio/referral_data.rb', line 7 def referrer_id @referrer_id end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
7 8 9 |
# File 'lib/linkio/referral_data.rb', line 7 def @timestamp end |
Class Method Details
.from_h(hash) ⇒ ReferralData
Build from a hash using either camelCase or snake_case keys.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/linkio/referral_data.rb', line 37 def self.from_h(hash) h = hash.each_with_object({}) { |(k, v), acc| acc[k.to_s] = v } new( referrer_id: h["referrerId"] || h["referrer_id"], referee_id: h["refereeId"] || h["referee_id"], referral_code: h["referralCode"] || h["referral_code"], timestamp: h["timestamp"], metadata: h["metadata"] ) end |
Instance Method Details
#to_h ⇒ Hash
23 24 25 26 27 28 29 30 31 |
# File 'lib/linkio/referral_data.rb', line 23 def to_h { "referrerId" => referrer_id, "refereeId" => referee_id, "referralCode" => referral_code, "timestamp" => , "metadata" => } end |