lib/tracksale/campaign.rb in tracksale-0.0.4 vs lib/tracksale/campaign.rb in tracksale-0.0.5
- old
+ new
@@ -19,9 +19,15 @@
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.find_by_code(code)
+ campaign_found_by_code = client.get('campaign/' + code.to_s).first
+ return nil if campaign_found_by_code.nil?
+ create_from_response(campaign_found_by_code)
+ end
+
def self.all
raw_all.map { |campaign| create_from_response(campaign) }
end
def self.create_from_response(raw_reponse)