Sha256: 45f25931b0d28bca089f694ee18d2cf497b21b997db3fd26938d9e0a56069ce1
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
module Tracksale class Campaign attr_accessor :name, :code, :score def schedule_dispatch(body) Tracksale::Campaign.client.post('campaign/'+self.code.to_s+'/dispatch',body) end def self.schedule_dispatch(code,body) client.post('campaign/'+code.to_s+'/dispatch',body) end def self.find_by_name(name) campaign_found_by_name = raw_all.keep_if { |c| c['name'] == name }.first return nil if campaign_found_by_name.nil? create_from_response(campaign_found_by_name) end def self.all raw_all.map { |campaign| create_from_response(campaign) } end def self.create_from_response(raw_reponse) new.tap do |campaign| campaign.name = raw_reponse['name'] campaign.code = raw_reponse['code'] campaign.score = { detractors: raw_reponse['detractors'], passives: raw_reponse['passives'], promoters: raw_reponse['promoters'] } end end def self.raw_all client.get('campaign') end def self.client Tracksale::Client.new end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tracksale-0.0.2 | lib/tracksale/campaign.rb |