Class: MessageQuickly::Api::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/message_quickly/api/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ Client

Returns a new instance of Client.

Yields:

  • (_self)

Yield Parameters:



9
10
11
12
# File 'lib/message_quickly/api/client.rb', line 9

def initialize(options = {})
  options.each { |key, value| instance_variable_set("@#{key}", value) }
  yield self if block_given?
end

Instance Attribute Details

#app_idObject

Returns the value of attribute app_id.



7
8
9
# File 'lib/message_quickly/api/client.rb', line 7

def app_id
  @app_id
end

#page_access_tokenObject

Returns the value of attribute page_access_token.



7
8
9
# File 'lib/message_quickly/api/client.rb', line 7

def page_access_token
  @page_access_token
end

#page_idObject

Returns the value of attribute page_id.



7
8
9
# File 'lib/message_quickly/api/client.rb', line 7

def page_id
  @page_id
end

Instance Method Details

#delete(request_string, params = {}) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/message_quickly/api/client.rb', line 34

def delete(request_string, params = {})
  params[:access_token] = page_access_token
  response = connection.delete(request_string) do |request|
    request.headers['Content-Type'] = 'application/json'
    request.body = JSON.generate(params)
  end
  parse_json(response)
end

#get(request_string, params = {}) ⇒ Object



14
15
16
17
18
# File 'lib/message_quickly/api/client.rb', line 14

def get(request_string, params = {})
  params[:access_token] = page_access_token
  response = connection.get(request_string, params)
  parse_json(response)
end

#post(request_string, params = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/message_quickly/api/client.rb', line 20

def post(request_string, params = {})
  params[:access_token] = page_access_token
  response = connection.post(request_string) do |request|
    if params[:filedata].present?
      request.headers['Content-Type'] = 'multipart/form-data'
      request.body = params
    else
      request.headers['Content-Type'] = 'application/json'
      request.body = JSON.generate(params)
    end
  end
  parse_json(response)
end