Class: Customers

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/aboardly/events.rb,
lib/aboardly/customers.rb

Instance Method Summary collapse

Constructor Details

#initialize(auth, base_url) ⇒ Customers

Returns a new instance of Customers.


4
5
6
7
# File 'lib/aboardly/events.rb', line 4

def initialize(auth, base_url)
  @auth = auth
  @base_url = base_url
end

Instance Method Details

#create(customer_id, event_name, *properties) ⇒ Object


9
10
11
12
13
14
15
# File 'lib/aboardly/events.rb', line 9

def create(customer_id, event_name, *properties)
  if (properties.empty?)
    properties = [{}]
  end
  options = {basic_auth: @auth, body: properties[0].to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json'}}
  self.class.post("#{@base_url}/customers/#{customer_id}/events/#{event_name}", options)
end

#upsert(customer_id, data = {}) ⇒ Object


9
10
11
12
# File 'lib/aboardly/customers.rb', line 9

def upsert(customer_id, data = {})
  options = {body: data, basic_auth: @auth}
  self.class.put("#{@base_url}/customers/#{customer_id}", options)
end