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.
149 150 151 152 |
# File 'lib/uboost-client/uboost_client.rb', line 149 def initialize(client) @client = client @url = '/api/badges' end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
147 148 149 |
# File 'lib/uboost-client/uboost_client.rb', line 147 def client @client end |
#url ⇒ Object
Returns the value of attribute url.
147 148 149 |
# File 'lib/uboost-client/uboost_client.rb', line 147 def url @url end |
Instance Method Details
#award(account_id, badge_type_id, options = nil) ⇒ Object
154 155 156 157 158 159 160 161 162 163 |
# File 'lib/uboost-client/uboost_client.rb', line 154 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
165 166 167 168 169 170 171 172 173 174 |
# File 'lib/uboost-client/uboost_client.rb', line 165 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 |