Class: Mogreet::Client
- Inherits:
-
Object
- Object
- Mogreet::Client
- Defined in:
- lib/mogreet/client.rb
Instance Attribute Summary collapse
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#http_response ⇒ Object
Returns the value of attribute http_response.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #get_request(path, query_params = {}) ⇒ Object
-
#initialize(client_id, token) ⇒ Client
constructor
A new instance of Client.
- #inspect ⇒ Object
- #keyword ⇒ Object
- #list ⇒ Object
- #media ⇒ Object
- #post_request(path, query_params = {}) ⇒ Object
- #system ⇒ Object
- #transaction ⇒ Object
- #user ⇒ Object
Constructor Details
#initialize(client_id, token) ⇒ Client
Returns a new instance of Client.
10 11 12 13 |
# File 'lib/mogreet/client.rb', line 10 def initialize(client_id, token) @client_id = client_id @token = token end |
Instance Attribute Details
#client_id ⇒ Object
Returns the value of attribute client_id.
8 9 10 |
# File 'lib/mogreet/client.rb', line 8 def client_id @client_id end |
#http_response ⇒ Object
Returns the value of attribute http_response.
8 9 10 |
# File 'lib/mogreet/client.rb', line 8 def http_response @http_response end |
#token ⇒ Object
Returns the value of attribute token.
8 9 10 |
# File 'lib/mogreet/client.rb', line 8 def token @token end |
Instance Method Details
#get_request(path, query_params = {}) ⇒ Object
15 16 17 18 19 |
# File 'lib/mogreet/client.rb', line 15 def get_request(path, query_params = {}) params = default_api_args.merge(query_params) @http_response = RestClient.get("https://api.mogreet.com#{path}", {:params => params}) Response.new(JSON.parse(@http_response.body)).response end |
#inspect ⇒ Object
51 52 53 |
# File 'lib/mogreet/client.rb', line 51 def inspect %(<Mogreet::Client @client_id="#{@client_id}", @token="#{@token}">) end |
#keyword ⇒ Object
43 44 45 |
# File 'lib/mogreet/client.rb', line 43 def keyword @keyword ||= Keyword.new(self) end |
#list ⇒ Object
27 28 29 |
# File 'lib/mogreet/client.rb', line 27 def list @list ||= List.new(self) end |
#media ⇒ Object
35 36 37 |
# File 'lib/mogreet/client.rb', line 35 def media @media ||= Media.new(self) end |
#post_request(path, query_params = {}) ⇒ Object
21 22 23 24 25 |
# File 'lib/mogreet/client.rb', line 21 def post_request(path, query_params = {}) params = default_api_args.merge(query_params) @http_response = RestClient.post("https://api.mogreet.com#{path}", params) Response.new(JSON.parse(@http_response.body)).response end |
#system ⇒ Object
39 40 41 |
# File 'lib/mogreet/client.rb', line 39 def system @system ||= System.new(self) end |
#transaction ⇒ Object
47 48 49 |
# File 'lib/mogreet/client.rb', line 47 def transaction @transaction ||= Transaction.new(self) end |