Class: MessageQuickly::Api::Client
- Inherits:
-
Object
- Object
- MessageQuickly::Api::Client
- Defined in:
- lib/message_quickly/api/client.rb
Instance Attribute Summary collapse
-
#app_id ⇒ Object
Returns the value of attribute app_id.
-
#page_access_token ⇒ Object
Returns the value of attribute page_access_token.
-
#page_id ⇒ Object
Returns the value of attribute page_id.
Instance Method Summary collapse
- #delete(request_string, params = {}) ⇒ Object
- #get(request_string, params = {}) ⇒ Object
-
#initialize(options = {}) {|_self| ... } ⇒ Client
constructor
A new instance of Client.
- #post(request_string, params = {}) ⇒ Object
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Client
Returns a new instance of Client.
9 10 11 12 |
# File 'lib/message_quickly/api/client.rb', line 9 def initialize( = {}) .each { |key, value| instance_variable_set("@#{key}", value) } yield self if block_given? end |
Instance Attribute Details
#app_id ⇒ Object
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_token ⇒ Object
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_id ⇒ Object
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 |