Class: Sms77::Base
- Inherits:
-
Object
- Object
- Sms77::Base
- Defined in:
- lib/sms77/base.rb
Direct Known Subclasses
Constant Summary collapse
- BASE_PATH =
'/api/'- CONN =
Faraday.new("https://gateway.sms77.io#{BASE_PATH}")
- HTTP_GET =
CONN.method(:get).freeze
- HTTP_POST =
CONN.method(:post).freeze
- HTTP_METHODS =
[HTTP_GET, HTTP_POST].freeze
- BUILDER =
CONN.builder
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#sent_with ⇒ Object
readonly
Returns the value of attribute sent_with.
Instance Method Summary collapse
-
#initialize(api_key, sent_with = 'ruby') ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(api_key, sent_with = 'ruby') ⇒ Base
Returns a new instance of Base.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sms77/base.rb', line 18 def initialize(api_key, sent_with = 'ruby') raise 'missing api_key in config' if api_key.to_s.empty? raise 'missing sent_with in config' if sent_with.to_s.empty? @api_key = api_key @sent_with = sent_with HTTP_METHODS.each do |method| define_singleton_method(method.name) { |*args| request(method, *args) } end end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
30 31 32 |
# File 'lib/sms77/base.rb', line 30 def api_key @api_key end |
#sent_with ⇒ Object (readonly)
Returns the value of attribute sent_with.
30 31 32 |
# File 'lib/sms77/base.rb', line 30 def sent_with @sent_with end |