Module: SendcloudClient

Defined in:
lib/sendcloud_client.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

API_BASE =
'https://api.sendcloud.net/apiv2'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyObject

Returns the value of attribute api_key.



13
14
15
# File 'lib/sendcloud_client.rb', line 13

def api_key
  @api_key
end

.api_userObject

Returns the value of attribute api_user.



13
14
15
# File 'lib/sendcloud_client.rb', line 13

def api_user
  @api_user
end

Class Method Details

.sendmail(options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/sendcloud_client.rb', line 16

def self.sendmail(options = {})
  return if options[:to].length == 0
  uri = "#{API_BASE}/mail/send"
  res = RestClient.post uri, apiUser: SendcloudClient.api_user,
     apiKey: SendcloudClient.api_key, to: options[:to], from: options[:from], fromName: options[:from],
     subject: options[:from], html: options[:from]

  JSON.parse(res) rescue nil
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



8
9
10
# File 'lib/sendcloud_client.rb', line 8

def self.setup
  yield self
end