Class: SensSms::Client
- Inherits:
-
Object
- Object
- SensSms::Client
- Includes:
- Configuration, SensSms::Configuration::Validate
- Defined in:
- lib/sens_sms/client.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#request_time ⇒ Object
readonly
Returns the value of attribute request_time.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Class Method Summary collapse
Instance Method Summary collapse
- #deliver(type:, from_number:, to_numbers:, subject: nil, message:) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
Methods included from SensSms::Configuration::Validate
#validate_configure, #validate_configure_defined?, #validate_configure_exist?
Methods included from Configuration
#access_key, #secret_key, #service_id
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
5 6 7 |
# File 'lib/sens_sms/client.rb', line 5 def initialize raise 'Configure is not valid.' unless validate_configure end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
3 4 5 |
# File 'lib/sens_sms/client.rb', line 3 def errors @errors end |
#request_time ⇒ Object (readonly)
Returns the value of attribute request_time.
3 4 5 |
# File 'lib/sens_sms/client.rb', line 3 def request_time @request_time end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
3 4 5 |
# File 'lib/sens_sms/client.rb', line 3 def response @response end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
3 4 5 |
# File 'lib/sens_sms/client.rb', line 3 def status @status end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
3 4 5 |
# File 'lib/sens_sms/client.rb', line 3 def @timestamp end |
Class Method Details
.configuration ⇒ Object
33 34 35 |
# File 'lib/sens_sms/client.rb', line 33 def self.configuration @configuration ||= SensSms::Configure.new end |
.configure {|configuration| ... } ⇒ Object
26 27 28 29 30 31 |
# File 'lib/sens_sms/client.rb', line 26 def self.configure yield configuration @@access_key = @configuration.access_key @@service_id = @configuration.service_id @@secret_key = @configuration.secret_key end |
Instance Method Details
#deliver(type:, from_number:, to_numbers:, subject: nil, message:) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sens_sms/client.rb', line 9 def deliver(type:, from_number:, to_numbers:, subject: nil, message:) raise "Invalid message type: #{type}" unless %i[sms lms].include? type.to_sym @timestamp = @response = HTTP.headers(ncloud_sens_api_header) .post(ncloud_sens_api_url, json: { type: type.to_sym, contentType: :COMM, countryCode: '82', from: from_number, subject: subject, content: , messages: (to_numbers) }) @status = response.status parse_response end |