Class: Voucherify::Service::Distributions
- Inherits:
-
Object
- Object
- Voucherify::Service::Distributions
- Defined in:
- lib/voucherify/service/distributions.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #create_export(export) ⇒ Object
- #create_publication(params) ⇒ Object
- #delete_export(id) ⇒ Object
- #get_export(id) ⇒ Object
-
#initialize(client) ⇒ Distributions
constructor
A new instance of Distributions.
- #list_publications(params = {}) ⇒ Object
- #publish(params) ⇒ Object
Constructor Details
#initialize(client) ⇒ Distributions
Returns a new instance of Distributions.
8 9 10 |
# File 'lib/voucherify/service/distributions.rb', line 8 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/voucherify/service/distributions.rb', line 6 def client @client end |
Instance Method Details
#create_export(export) ⇒ Object
23 24 25 |
# File 'lib/voucherify/service/distributions.rb', line 23 def create_export(export) @client.post('/exports', export) end |
#create_publication(params) ⇒ Object
39 40 41 |
# File 'lib/voucherify/service/distributions.rb', line 39 def create_publication(params) @client.post('/publications', params.to_json) end |
#delete_export(id) ⇒ Object
31 32 33 |
# File 'lib/voucherify/service/distributions.rb', line 31 def delete_export(id) @client.delete("/exports/#{ERB::Util.url_encode(id)}") end |
#get_export(id) ⇒ Object
27 28 29 |
# File 'lib/voucherify/service/distributions.rb', line 27 def get_export(id) @client.get("/exports/#{ERB::Util.url_encode(id)}") end |
#list_publications(params = {}) ⇒ Object
35 36 37 |
# File 'lib/voucherify/service/distributions.rb', line 35 def list_publications(params = {}) @client.get('/publications', params) end |
#publish(params) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/voucherify/service/distributions.rb', line 12 def publish(params) payload = {} if params.is_a? String payload = {:campaign => params} elsif params.is_a? Hash payload = params end @client.post('/vouchers/publish', payload.to_json) end |