Class: Followanalytics::Attributes::Client
- Inherits:
-
Object
- Object
- Followanalytics::Attributes::Client
- Defined in:
- lib/followanalytics/attributes.rb
Constant Summary collapse
- MISSING_SOR =
'Missing System of Record identifier.'.freeze
- MISSING_API_KEY =
'Missing api key in configuration.'.freeze
- PREDEFINED_ATTRIBUTE_KEYS =
%w( first_name last_name email date_of_birth gender country city region profile_picture ).freeze
Instance Attribute Summary collapse
-
#sor_identifier ⇒ Object
Returns the value of attribute sor_identifier.
Instance Method Summary collapse
-
#add_set_value(value, key, customer_id) ⇒ Object
Add a value to an attribute of type set.
-
#initialize(sor_identifier) ⇒ Client
constructor
Initializes the Attributes client.
-
#remove_set_value(value, key, customer_id) ⇒ Object
Remove a value to an attribute of type set.
-
#set_value(value, key, customer_id) ⇒ Object
Set one value for a customer.
-
#unset_value(key, customer_id) ⇒ Object
Unset one value for a customer.
Constructor Details
#initialize(sor_identifier) ⇒ Client
Initializes the Attributes client.
23 24 25 26 |
# File 'lib/followanalytics/attributes.rb', line 23 def initialize(sor_identifier) raise Followanalytics::Error, MISSING_SOR if sor_identifier.nil? @sor_identifier = sor_identifier end |
Instance Attribute Details
#sor_identifier ⇒ Object
Returns the value of attribute sor_identifier.
7 8 9 |
# File 'lib/followanalytics/attributes.rb', line 7 def sor_identifier @sor_identifier end |
Instance Method Details
#add_set_value(value, key, customer_id) ⇒ Object
Add a value to an attribute of type set.
68 69 70 71 72 73 |
# File 'lib/followanalytics/attributes.rb', line 68 def add_set_value(value, key, customer_id) hash = attribute_hash(value, key, customer_id).tap do |hsh| hsh['action_type'] = 'ADD' end send_attributes(hash) end |
#remove_set_value(value, key, customer_id) ⇒ Object
Remove a value to an attribute of type set.
83 84 85 86 87 88 |
# File 'lib/followanalytics/attributes.rb', line 83 def remove_set_value(value, key, customer_id) hash = attribute_hash(value, key, customer_id).tap do |hsh| hsh['action_type'] = 'REMOVE' end send_attributes(hash) end |
#set_value(value, key, customer_id) ⇒ Object
Set one value for a customer.
43 44 45 46 |
# File 'lib/followanalytics/attributes.rb', line 43 def set_value(value, key, customer_id) hash = attribute_hash(value, key, customer_id) send_attributes(hash) end |
#unset_value(key, customer_id) ⇒ Object
Unset one value for a customer.
55 56 57 58 |
# File 'lib/followanalytics/attributes.rb', line 55 def unset_value(key, customer_id) hash = attribute_hash(nil, key, customer_id) send_attributes(hash) end |