Class: UboostClient::Badges
- Inherits:
-
Object
- Object
- UboostClient::Badges
- 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
- #award(account_id, badge_type_id, options = nil) ⇒ Object
-
#initialize(client) ⇒ Badges
constructor
A new instance of Badges.
- #unaward(account_id, badge_type_id, options = nil) ⇒ Object
Constructor Details
#initialize(client) ⇒ Badges
Returns a new instance of Badges.
154 155 156 157 |
# File 'lib/uboost-client/uboost_client.rb', line 154 def initialize(client) @client = client @url = '/api/badges' end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
152 153 154 |
# File 'lib/uboost-client/uboost_client.rb', line 152 def client @client end |
#url ⇒ Object
Returns the value of attribute url.
152 153 154 |
# File 'lib/uboost-client/uboost_client.rb', line 152 def url @url end |
Instance Method Details
#award(account_id, badge_type_id, options = nil) ⇒ Object
159 160 161 162 163 164 165 166 167 168 |
# File 'lib/uboost-client/uboost_client.rb', line 159 def award(account_id, badge_type_id, = nil) data = {:badge => {:account_id => account_id, :badge_type_id => badge_type_id}} data[:badge].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 |
#unaward(account_id, badge_type_id, options = nil) ⇒ Object
170 171 172 173 174 175 176 177 178 179 |
# File 'lib/uboost-client/uboost_client.rb', line 170 def unaward(account_id, badge_type_id, = nil) data = {:badge => {:account_id => account_id, :badge_type_id => badge_type_id}} data[:badge].merge!() if response = client.connection.delete do |req| req.url @url + "/unaward" req.headers['Content-Type'] = 'application/json' req.body = JSON.generate(data) end OpenStruct.new(JSON.parse(response.body)) end |