Class: Yahag::App
Instance Attribute Summary collapse
-
#app_id ⇒ Object
readonly
Returns the value of attribute app_id.
-
#app_secret ⇒ Object
readonly
Returns the value of attribute app_secret.
-
#app_token ⇒ Object
readonly
Returns the value of attribute app_token.
Instance Method Summary collapse
- #add_user(email = nil, options = {}) ⇒ Object
- #check_user(email = nil) ⇒ Object
- #delete_user(user_id = nil) ⇒ Object
-
#initialize(&block) ⇒ App
constructor
A new instance of App.
- #list_users ⇒ Object
Constructor Details
#initialize(&block) ⇒ App
Returns a new instance of App.
16 17 18 19 |
# File 'lib/yahag/app.rb', line 16 def initialize(&block) # super instance_eval(&block) if block_given? end |
Instance Attribute Details
#app_id ⇒ Object (readonly)
Returns the value of attribute app_id.
9 10 11 |
# File 'lib/yahag/app.rb', line 9 def app_id @app_id end |
#app_secret ⇒ Object (readonly)
Returns the value of attribute app_secret.
9 10 11 |
# File 'lib/yahag/app.rb', line 9 def app_secret @app_secret end |
#app_token ⇒ Object (readonly)
Returns the value of attribute app_token.
9 10 11 |
# File 'lib/yahag/app.rb', line 9 def app_token @app_token end |
Instance Method Details
#add_user(email = nil, options = {}) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/yahag/app.rb', line 37 def add_user(email = nil, = {}) body = { email: email }.merge() .delete_if { |_, v| v.nil? } post("/apps/#{@app_id}/app_users", body) end |
#check_user(email = nil) ⇒ Object
25 26 27 28 29 |
# File 'lib/yahag/app.rb', line 25 def check_user(email = nil) body = { email: email, secret: @app_secret } get("/apps/#{@app_id}/app_users/check", body).code != 404 end |
#delete_user(user_id = nil) ⇒ Object
44 45 46 |
# File 'lib/yahag/app.rb', line 44 def delete_user(user_id = nil) delete("/apps/#{@app_id}/app_users/#{user_id}").status == 200 end |
#list_users ⇒ Object
21 22 23 |
# File 'lib/yahag/app.rb', line 21 def list_users get("/apps/#{@app_id}/app_users")[:app_users] end |