Class: LYBC::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session_id) ⇒ Client

Returns a new instance of Client.



32
33
34
35
# File 'lib/LYBC/client.rb', line 32

def initialize(session_id)
  @session_id = session_id
  @conn = Faraday.new()
end

Instance Attribute Details

#session_idObject

Returns the value of attribute session_id.



30
31
32
# File 'lib/LYBC/client.rb', line 30

def session_id
  @session_id
end

Instance Method Details

#cashSelectedCouponsObject



73
74
75
76
77
78
79
80
81
82
# File 'lib/LYBC/client.rb', line 73

def cashSelectedCoupons
  body = {
      'sessionID' => @session_id,
      'action' => 'cashSelectedCoupons',
      'data' => {}
  }

  response = @conn.post("#{LYBC.api_url}", body.to_json, 'Content-Type' => 'application/json')
  JSON.parse(response.body)
end

#getAssociationObject



51
52
53
54
55
56
57
58
59
60
# File 'lib/LYBC/client.rb', line 51

def getAssociation
  body = {
      'sessionID' => @session_id,
      'action' => 'getAssociation',
      'data' => {}
  }

  response = @conn.post("#{LYBC.api_endpoint}", body.to_json, 'Content-Type' => 'application/json')
  JSON.parse(response.body)
end

#getSelectedCouponsObject



62
63
64
65
66
67
68
69
70
71
# File 'lib/LYBC/client.rb', line 62

def getSelectedCoupons
  body = {
      'sessionID' => @session_id,
      'action' => 'getSelectedCoupons',
      'data' => {}
  }

  response = @conn.post("#{LYBC.api_url}", body.to_json, 'Content-Type' => 'application/json')
  JSON.parse(response.body)
end

#registerSession(associationID = "") ⇒ Object



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

def registerSession(associationID = "")
    body = {
      'sessionID' => @session_id.to_s,
      'action' => 'registerSession',
      'data' => {
        'associationID' => associationID.to_s,
        'expirationDate' => "2017-2-24"
      }
    }

    response = @conn.post(LYBC.api_endpoint, body.to_json, 'Content-Type' => 'application/json')
    JSON.parse(response.body)
end