Class: LYBC::Client
- Inherits:
-
Object
- Object
- LYBC::Client
- Defined in:
- lib/LYBC/client.rb
Instance Attribute Summary collapse
-
#session_id ⇒ Object
Returns the value of attribute session_id.
Instance Method Summary collapse
- #cashSelectedCoupons ⇒ Object
- #getAssociation ⇒ Object
- #getSelectedCoupons ⇒ Object
-
#initialize(session_id) ⇒ Client
constructor
A new instance of Client.
- #registerSession(associationID = "") ⇒ Object
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_id ⇒ Object
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
#cashSelectedCoupons ⇒ Object
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 |
#getAssociation ⇒ Object
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 |
#getSelectedCoupons ⇒ Object
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 |