Class: Semaphore::Client

Inherits:
Object
  • Object
show all
Includes:
HTTP
Defined in:
lib/semaphore/client.rb

Constant Summary collapse

CONFIG_KEYS =
%i[
  api_version
  api_key
  sender_name
  uri_base
  request_timeout
].freeze

Instance Method Summary collapse

Methods included from HTTP

#get_request, #post_request

Constructor Details

#initialize(config = {}) ⇒ Client

Returns a new instance of Client.



15
16
17
18
19
# File 'lib/semaphore/client.rb', line 15

def initialize(config = {})
  CONFIG_KEYS.each do |key|
    instance_variable_set("@#{key}", config[key] || Semaphore.configuration.send(key))
  end
end

Instance Method Details

#account(parameters: {}) ⇒ Object



37
38
39
# File 'lib/semaphore/client.rb', line 37

def (parameters: {})
  get_request(path: '/account', parameters:)
end

#account_sendernames(parameters: {}) ⇒ Object



45
46
47
# File 'lib/semaphore/client.rb', line 45

def (parameters: {})
  get_request(path: '/account/sendernames', parameters:)
end

#account_transactions(parameters: {}) ⇒ Object



41
42
43
# File 'lib/semaphore/client.rb', line 41

def (parameters: {})
  get_request(path: '/account/transactions', parameters:)
end

#account_users(parameters: {}) ⇒ Object



49
50
51
# File 'lib/semaphore/client.rb', line 49

def (parameters: {})
  get_request(path: '/account/users', parameters:)
end

#get_message(id, parameters: {}) ⇒ Object



33
34
35
# File 'lib/semaphore/client.rb', line 33

def get_message(id, parameters: {})
  get_request(path: "/messages/#{id}", parameters:)
end

#messages(parameters: {}) ⇒ Object



21
22
23
# File 'lib/semaphore/client.rb', line 21

def messages(parameters: {})
  post_request(path: '/messages', parameters:)
end

#otp(parameters: {}) ⇒ Object



29
30
31
# File 'lib/semaphore/client.rb', line 29

def otp(parameters: {})
  post_request(path: '/otp', parameters:)
end

#priority(parameters: {}) ⇒ Object



25
26
27
# File 'lib/semaphore/client.rb', line 25

def priority(parameters: {})
  post_request(path: '/priority', parameters:)
end