Class: UboostClient::Points
- Inherits:
-
Object
- Object
- UboostClient::Points
- Defined in:
- lib/uboost-client/uboost_client.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #add_points_to_account(id, points, options = nil) ⇒ Object
-
#initialize(client) ⇒ Points
constructor
A new instance of Points.
- #points_transactions_for_account(id_or_options) ⇒ Object
Constructor Details
#initialize(client) ⇒ Points
Returns a new instance of Points.
123 124 125 126 |
# File 'lib/uboost-client/uboost_client.rb', line 123 def initialize(client) @client = client @url = '/api/points_transactions' end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
121 122 123 |
# File 'lib/uboost-client/uboost_client.rb', line 121 def client @client end |
#url ⇒ Object
Returns the value of attribute url.
121 122 123 |
# File 'lib/uboost-client/uboost_client.rb', line 121 def url @url end |
Instance Method Details
#add_points_to_account(id, points, options = nil) ⇒ Object
137 138 139 140 141 142 143 144 145 146 |
# File 'lib/uboost-client/uboost_client.rb', line 137 def add_points_to_account(id, points, = nil) data = {:points_transaction => {:account_id => id, :points_change => points}} data[:points_transaction].merge!() if response = client.connection.post do |req| req.url @url req.headers['Content-Type'] = 'application/json' req.body = JSON.generate(data) end OpenStruct.new(JSON.parse(response.body)) end |
#points_transactions_for_account(id_or_options) ⇒ Object
128 129 130 131 132 133 134 135 |
# File 'lib/uboost-client/uboost_client.rb', line 128 def points_transactions_for_account() = = {:account_id => } if !.is_a? Hash response = client.connection.get do |req| req.url @url, end OpenStruct.new(JSON.parse(response.body)) end |