Class: Weimark::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/weimark/client.rb

Constant Summary collapse

WEIMARK_URL =
'https://secure.weimark.com/api/post'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



11
12
13
14
15
16
# File 'lib/weimark/client.rb', line 11

def initialize(options = {})
  @url = options[:url] || WEIMARK_URL
  @email = options[:email] || ENV['WEIMARK_EMAIL']
  @password = options[:password] || ENV['WEIMARK_PASSWORD']
  @agents_email = options[:agents_email] || ENV['AGENTS_EMAIL']
end

Instance Attribute Details

#agents_emailObject (readonly)

Returns the value of attribute agents_email.



9
10
11
# File 'lib/weimark/client.rb', line 9

def agents_email
  @agents_email
end

#emailObject (readonly)

Returns the value of attribute email.



9
10
11
# File 'lib/weimark/client.rb', line 9

def email
  @email
end

#passwordObject (readonly)

Returns the value of attribute password.



9
10
11
# File 'lib/weimark/client.rb', line 9

def password
  @password
end

#urlObject (readonly)

Returns the value of attribute url.



9
10
11
# File 'lib/weimark/client.rb', line 9

def url
  @url
end

Instance Method Details

#get(application_id) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/weimark/client.rb', line 18

def get(application_id)
  request(
    http_method: :post,
    endpoint: url,
    body: {
      request: xml_request(
        action: "GetApplication",
        agents_email: agents_email,
        body: {
          applicationid: application_id
        }
      )
    }
  )
end

#post(application_attributes = {}) ⇒ Object

Sample application_attributes: ‘JONATHAN’, lname: ‘CONSUMER’, dob: ‘01/05/1987’, gender: ‘male’, ssn: ‘485774859’, streetnumber: ‘236’, streetname: ‘BIRCH’, streettype: ‘S’, city: ‘BURBANK’, country: ‘USA’, suite: ‘1TEST’, zip: ‘91502’



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/weimark/client.rb', line 36

def post(application_attributes = {})
  request(
    http_method: :post,
    endpoint: url,
    body: {
      request: xml_request(
        action: "NewApplication",
        agents_email: agents_email,
        body: {
          applicant: application_attributes
        }
      )
    }
  )
end