Class: Abenla::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/abenla-ruby/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key = nil, secret = nil, brandName = nil, serviceTypeId = nil) ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
11
12
# File 'lib/abenla-ruby/client.rb', line 6

def initialize(key=nil, secret=nil, brandName=nil, serviceTypeId=nil)
  @key = key
  @secret = secret
  @brandName = brandName
  @serviceTypeId = serviceTypeId
  @api_host = 'api.abenla.com/Service.asmx'
end

Instance Attribute Details

#brandNameObject

Returns the value of attribute brandName.



4
5
6
# File 'lib/abenla-ruby/client.rb', line 4

def brandName
  @brandName
end

#keyObject

Returns the value of attribute key.



4
5
6
# File 'lib/abenla-ruby/client.rb', line 4

def key
  @key
end

#secretObject

Returns the value of attribute secret.



4
5
6
# File 'lib/abenla-ruby/client.rb', line 4

def secret
  @secret
end

#serviceTypeIdObject

Returns the value of attribute serviceTypeId.



4
5
6
# File 'lib/abenla-ruby/client.rb', line 4

def serviceTypeId
  @serviceTypeId
end

Instance Method Details

#message(content) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/abenla-ruby/client.rb', line 14

def message(content)
  params = {
    loginName: @key,
    brandName: @brandName,
    serviceTypeId: @serviceTypeId
  }
  sign = Signature.digest(@key, @secret, [@brandName, @serviceTypeId])
  get(@api_host, '/SendSmsOTP', params.merge!(content: content.to_json, sign: sign))
end