Sha256: b1aba68a63618882660b210319038f36a654f29f760259cba62ffaff5e72b08a
Contents?: true
Size: 1.42 KB
Versions: 3
Compression:
Stored size: 1.42 KB
Contents
require 'emaildirect' require 'json' module EmailDirect # Represents an order and associated functionality class Order class << self def all(options = {}) response = EmailDirect.get '/Orders', :query => options Hashie::Mash.new(response) end def create(email, options = {}) options.merge! :EmailAddress => email response = EmailDirect.post '/Orders', :body => options.to_json Hashie::Mash.new(response) end def import(orders) options = { :Orders => Array(orders) } response = EmailDirect.post '/Orders/Import', :body => options.to_json Hashie::Mash.new(response) end end attr_reader :order_number def initialize(order_number) @order_number = order_number end def details response = get Hashie::Mash.new(response) end def update(email, options) options.merge! :EmailAddress => email response = EmailDirect.put uri_for, :body => options.to_json Hashie::Mash.new(response) end def delete response = EmailDirect.delete uri_for, {} end private def post(action, options) EmailDirect.post uri_for(action), options end def get(action = nil, options = {}) EmailDirect.get uri_for(action), options end def uri_for(action = nil) action = "/#{action}" if action "/Orders/#{order_number}#{action}" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
emaildirect-2.0.0 | lib/emaildirect/order.rb |
emaildirect-1.3.4 | lib/emaildirect/order.rb |
emaildirect-1.3.3 | lib/emaildirect/order.rb |