Module: Sendcloud
- Defined in:
- lib/sendcloud.rb,
lib/sendcloud/mail.rb,
lib/sendcloud/stats.rb,
lib/sendcloud/bounces.rb,
lib/sendcloud/version.rb,
lib/sendcloud/template.rb,
lib/sendcloud/mail_list.rb,
lib/sendcloud/unsubscribes.rb
Defined Under Namespace
Modules: Bounces, Mail, MailList, Stats, Template, Unsubscribes Classes: Error
Constant Summary collapse
- API_BASE =
'https://sendcloud.sohu.com/webapi'
- VERSION =
'0.2.0'
Class Attribute Summary collapse
-
.api_key ⇒ Object
Returns the value of attribute api_key.
-
.api_user ⇒ Object
Returns the value of attribute api_user.
-
.format ⇒ Object
Returns the value of attribute format.
Class Method Summary collapse
- .get(path, params) ⇒ Object
- .post(path, params) ⇒ Object
- .request(path, params, &block) ⇒ Object
- .setup {|_self| ... } ⇒ Object
Class Attribute Details
.api_key ⇒ Object
Returns the value of attribute api_key.
21 22 23 |
# File 'lib/sendcloud.rb', line 21 def api_key @api_key end |
.api_user ⇒ Object
Returns the value of attribute api_user.
21 22 23 |
# File 'lib/sendcloud.rb', line 21 def api_user @api_user end |
.format ⇒ Object
Returns the value of attribute format.
21 22 23 |
# File 'lib/sendcloud.rb', line 21 def format @format end |
Class Method Details
.get(path, params) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/sendcloud.rb', line 24 def self.get(path, params) request(path, params) do |url, | RestClient.get(url, {:params => }) end end |
.post(path, params) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/sendcloud.rb', line 31 def self.post(path, params) request(path, params) do |url, | RestClient.post(url, ) end end |
.request(path, params, &block) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/sendcloud.rb', line 39 def self.request(path, params, &block) params = { :api_user => Sendcloud.api_user, :api_key => Sendcloud.api_key, }.merge(params) format = params.delete(:format) || 'json' url = "#{API_BASE}/#{path}.#{format}" begin return JSON.parse(yield(url, params)) rescue JSON::ParserError raise Sendcloud::Error.new('sendcloud response invalid') end end |
.setup {|_self| ... } ⇒ Object
16 17 18 |
# File 'lib/sendcloud.rb', line 16 def self.setup yield self end |