Class: Workarea::Emarsys::Gateway

Inherits:
Object
  • Object
show all
Defined in:
app/lib/workarea/emarsys/gateway.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(secret_key, user_name, options = {}) ⇒ Gateway

Returns a new instance of Gateway.



6
7
8
9
10
# File 'app/lib/workarea/emarsys/gateway.rb', line 6

def initialize(secret_key, user_name, options = {})
  @secret_key = secret_key
  @user_name = user_name
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'app/lib/workarea/emarsys/gateway.rb', line 4

def options
  @options
end

#secret_keyObject (readonly)

Returns the value of attribute secret_key.



4
5
6
# File 'app/lib/workarea/emarsys/gateway.rb', line 4

def secret_key
  @secret_key
end

#user_nameObject (readonly)

Returns the value of attribute user_name.



4
5
6
# File 'app/lib/workarea/emarsys/gateway.rb', line 4

def user_name
  @user_name
end

Instance Method Details

#create_contact(attrs) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/lib/workarea/emarsys/gateway.rb', line 12

def create_contact(attrs)
  base_uri = "/api/v2/contact/"
  params = { create_if_not_exists: 1 }
  query_values = "?" + params.to_query

  path = base_uri + query_values

  response = connection.put do |req|
    req.url path
    req.params = params
    req.body = attrs.to_json
  end
  Response.new(response)
end