Class: Yahag::App

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/yahag/app.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_idObject (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_secretObject (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_tokenObject (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

first_name: options, last_name: options, message: options, role: options, tags: options



37
38
39
40
41
42
# File 'lib/yahag/app.rb', line 37

def add_user(email = nil, options = {})
  body = { email: email }.merge(options)
                         .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_usersObject



21
22
23
# File 'lib/yahag/app.rb', line 21

def list_users
  get("/apps/#{@app_id}/app_users")[:app_users]
end