Class: Mogreet::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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_idObject

Returns the value of attribute client_id.



8
9
10
# File 'lib/mogreet/client.rb', line 8

def client_id
  @client_id
end

#http_responseObject

Returns the value of attribute http_response.



8
9
10
# File 'lib/mogreet/client.rb', line 8

def http_response
  @http_response
end

#tokenObject

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

#inspectObject



51
52
53
# File 'lib/mogreet/client.rb', line 51

def inspect
  %(<Mogreet::Client @client_id="#{@client_id}", @token="#{@token}">)
end

#keywordObject



43
44
45
# File 'lib/mogreet/client.rb', line 43

def keyword
  @keyword ||= Keyword.new(self)
end

#listObject



27
28
29
# File 'lib/mogreet/client.rb', line 27

def list
  @list ||= List.new(self)
end

#mediaObject



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

#systemObject



39
40
41
# File 'lib/mogreet/client.rb', line 39

def system
  @system ||= System.new(self)
end

#transactionObject



47
48
49
# File 'lib/mogreet/client.rb', line 47

def transaction
  @transaction ||= Transaction.new(self)      
end

#userObject



31
32
33
# File 'lib/mogreet/client.rb', line 31

def user
  @user ||= User.new(self)
end