Class: KB::Referral

Inherits:
BaseModel show all
Includes:
Queryable
Defined in:
lib/kb/models/referral.rb

Constant Summary collapse

STRING_FIELDS =
%i[key referral_key referred_key type].freeze
DATE_FIELDS =
%i[joined_at].freeze
FIELDS =
[*STRING_FIELDS, *DATE_FIELDS].freeze

Instance Attribute Summary

Attributes inherited from BaseModel

#persisted

Class Method Summary collapse

Methods inherited from BaseModel

#==, define_attribute_methods, define_attributes, #initialize, #persist!, #persisted?

Methods included from Inspectionable

#inspect

Constructor Details

This class inherits a constructor from KB::BaseModel

Class Method Details

.create(pet_parent_key, attributes) ⇒ Object



22
23
24
25
26
27
# File 'lib/kb/models/referral.rb', line 22

def self.create(pet_parent_key, attributes)
  response = kb_client.request("#{pet_parent_key}/referrals", filters: attributes, method: :post)
  attributes_from_response(response)
rescue Faraday::Error => e
  raise KB::Error.from_faraday(e)
end