Class: Gupshup::REST::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/gupshup-rb/rest/client.rb

Overview

A client for accessing the Gupshup API.

Constant Summary collapse

@@default_region =
'us1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(src_name = nil, api_key = nil) ⇒ Client

Initializes the Gupshup Client



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gupshup-rb/rest/client.rb', line 14

def initialize(src_name=nil, api_key=nil)
  @src_name = src_name
  @api_key = api_key
  @auth = [@src_name, @api_key]
  #$@logger = logger || Gupshup.logger
  @user_agent_extensions = user_agent_extensions || []

  # Domains
  @api = nil
  @content = nil
  @conversations = nil
  @events = nil
  @media = nil
  @messaging = nil
  @video = nil
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



10
11
12
# File 'lib/gupshup-rb/rest/client.rb', line 10

def api_key
  @api_key
end

#edgeObject

Returns the value of attribute edge.



10
11
12
# File 'lib/gupshup-rb/rest/client.rb', line 10

def edge
  @edge
end

#http_clientObject

Returns the value of attribute http_client.



10
11
12
# File 'lib/gupshup-rb/rest/client.rb', line 10

def http_client
  @http_client
end

#loggerObject

Returns the value of attribute logger.



10
11
12
# File 'lib/gupshup-rb/rest/client.rb', line 10

def logger
  @logger
end

#passwordObject

Returns the value of attribute password.



10
11
12
# File 'lib/gupshup-rb/rest/client.rb', line 10

def password
  @password
end

#regionObject

Returns the value of attribute region.



10
11
12
# File 'lib/gupshup-rb/rest/client.rb', line 10

def region
  @region
end

#src_nameObject

Returns the value of attribute src_name.



10
11
12
# File 'lib/gupshup-rb/rest/client.rb', line 10

def src_name
  @src_name
end

#user_agent_extensionsObject

Returns the value of attribute user_agent_extensions.



10
11
12
# File 'lib/gupshup-rb/rest/client.rb', line 10

def user_agent_extensions
  @user_agent_extensions
end

#usernameObject

Returns the value of attribute username.



10
11
12
# File 'lib/gupshup-rb/rest/client.rb', line 10

def username
  @username
end

Instance Method Details

#messages(to = nil, from = nil, body = nil, api_key = nil, src_name = nil) ⇒ Object



31
32
33
34
35
# File 'lib/gupshup-rb/rest/client.rb', line 31

def messages(to=nil, from=nil, body=nil, api_key=nil, src_name=nil)
  message_list = Gupshup::REST::Api::V1::MessageList.new('v1', src_name: src_name)

  message_list.create(to: to, from: from, body: body, media_url: '', content_type: 'text', api_key: api_key, src_name: src_name)
end

#to_sObject

Provide a user friendly representation



38
39
40
# File 'lib/gupshup-rb/rest/client.rb', line 38

def to_s
  "#<Gupshup::REST::Client #{@src_name}>"
end