Class: BMC::SMS::Strategies::Sendinblue
- Inherits:
-
Object
- Object
- BMC::SMS::Strategies::Sendinblue
- Defined in:
- app/sms/bmc/sms/strategies/sendinblue.rb
Constant Summary collapse
- URL =
"https://api.sendinblue.com/v3/transactionalSMS/sms"
- DeliveryError =
Class.new(BMC::SMS::DeliveryError)
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Instance Method Summary collapse
- #call(data) ⇒ Object
-
#initialize(api_key: ENV["SENDINBLUE_API_KEY"]) ⇒ Sendinblue
constructor
A new instance of Sendinblue.
Constructor Details
#initialize(api_key: ENV["SENDINBLUE_API_KEY"]) ⇒ Sendinblue
Returns a new instance of Sendinblue.
8 9 10 |
# File 'app/sms/bmc/sms/strategies/sendinblue.rb', line 8 def initialize(api_key: ENV["SENDINBLUE_API_KEY"]) @api_key = api_key end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
6 7 8 |
# File 'app/sms/bmc/sms/strategies/sendinblue.rb', line 6 def api_key @api_key end |
Instance Method Details
#call(data) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'app/sms/bmc/sms/strategies/sendinblue.rb', line 12 def call(data) response = HTTP.request(:post, URL, headers: request_headers, json: request_body(data)) unless response.code.to_s.start_with?("2") raise DeliveryError, "Invalid response: #{response.code} / #{response.body}" end true end |