Module: MotionYak::Base
- Defined in:
- lib/motion_yak/base.rb
Class Method Summary collapse
- .api_url(url) ⇒ Object
- .base_url ⇒ Object
- .config(api_key) ⇒ Object
- .key ⇒ Object
- .new_address(address, &b) ⇒ Object
- .new_domain(domain, &b) ⇒ Object
- .send_email(options, &b) ⇒ Object
Class Method Details
.api_url(url) ⇒ Object
15 16 17 |
# File 'lib/motion_yak/base.rb', line 15 def self.api_url(url) [self.base_url, MotionYak::Config.api_key, 'json', url].join('/') end |
.base_url ⇒ Object
11 12 13 |
# File 'lib/motion_yak/base.rb', line 11 def self.base_url 'https://api.emailyak.com/v1' end |
.config(api_key) ⇒ Object
3 4 5 |
# File 'lib/motion_yak/base.rb', line 3 def self.config(api_key) MotionYak::Config.api_key = api_key end |
.key ⇒ Object
7 8 9 |
# File 'lib/motion_yak/base.rb', line 7 def self.key MotionYak::Config.api_key end |
.new_address(address, &b) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/motion_yak/base.rb', line 26 def self.new_address(address, &b) params = {'Address' => address, 'CallbackURL' => MotionYak::Config.callback, 'PushEmail' => MotionYak::Config.push_params} MotionYak::Request.post self.api_url('register/address/'), params do |json| b.call(json) end end |
.new_domain(domain, &b) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/motion_yak/base.rb', line 19 def self.new_domain(domain, &b) params = {'Domain' => domain, 'CallbackURL' => MotionYak::Config.callback, 'PushEmail' => MotionYak::Config.push_params} MotionYak::Request.post self.api_url('register/domain/'), params do |json| b.call(json) end end |
.send_email(options, &b) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/motion_yak/base.rb', line 33 def self.send_email(, &b) params = {} params['FromAddress'] = [:from] if [:from] params['FromName'] = [:from_name] if [:from_name] params['SenderAddress'] = [:sender_address] if [:sender_address] params['ToAddress'] = [:to] if [:to] params['ReplyToAddress'] = [:reply_address] if [:reply_address] params['CcAddress'] = [:cc] if [:cc] params['BccAddress'] = [:bcc] if [:bcc] params['Subject'] = [:subject] if [:subject] params['HtmlBody'] = [:html] if [:html] params['TextBody'] = [:text] if [:text] params['Headers'] = [:headers] if [:headers] params['Attachments'] = [:attachments] if [:attachments] MotionYak::Request.post self.api_url('send/email/'), params do |json| b.call(json) end end |