Class: Emarsys::DataObject
- Inherits:
-
Object
- Object
- Emarsys::DataObject
- Defined in:
- lib/emarsys/data_object.rb
Direct Known Subclasses
Condition, Contact, ContactList, Email, EmailCategory, EmailLaunchStatus, EmailStatusCode, Event, Export, Field, File, Folder, Form, Language, Segment, Source
Class Method Summary collapse
-
.delete(account, method_name, params) ⇒ Hash
Make a HTTP DELETE request.
-
.get(account, method_name, params) ⇒ Hash
Make a HTTP GET request.
-
.parameterize_params(params) ⇒ String
Custom Parameterizer for Emarsys.
-
.post(account, method_name, params) ⇒ Hash
Make a HTTP POST request.
-
.put(account, method_name, params) ⇒ Hash
Make a HTTP PUT request.
Instance Method Summary collapse
-
#request(account, http_verb, method_name, params) ⇒ Hash
Make a HTTP request.
Class Method Details
.delete(account, method_name, params) ⇒ Hash
Make a HTTP DELETE request
48 49 50 |
# File 'lib/emarsys/data_object.rb', line 48 def delete(account, method_name, params) self.new.request account, 'delete', method_name, params end |
.get(account, method_name, params) ⇒ Hash
Make a HTTP GET request
14 15 16 17 18 19 20 |
# File 'lib/emarsys/data_object.rb', line 14 def get(account, method_name, params) if params.empty? self.new.request account, 'get', method_name, params else self.new.request account, 'get', [method_name, parameterize_params(params)].join("/"), {} end end |
.parameterize_params(params) ⇒ String
Custom Parameterizer for Emarsys
56 57 58 |
# File 'lib/emarsys/data_object.rb', line 56 def parameterize_params(params) '?' + params.map{|k, v| "#{url_encode(k)}=#{url_encode(v)}"}.join('&') end |
.post(account, method_name, params) ⇒ Hash
Make a HTTP POST request
28 29 30 |
# File 'lib/emarsys/data_object.rb', line 28 def post(account, method_name, params) self.new.request account, 'post', method_name, params end |
.put(account, method_name, params) ⇒ Hash
Make a HTTP PUT request
38 39 40 |
# File 'lib/emarsys/data_object.rb', line 38 def put(account, method_name, params) self.new.request account, 'put', method_name, params end |
Instance Method Details
#request(account, http_verb, method_name, params) ⇒ Hash
Make a HTTP request
76 77 78 |
# File 'lib/emarsys/data_object.rb', line 76 def request(account, http_verb, method_name, params) response = Emarsys::Request.new(account, http_verb, method_name, params).send_request end |