Class: CognitiveFaculty::Offer

Inherits:
Object
  • Object
show all
Includes:
Her::Model
Defined in:
lib/cognitive_faculty/models/offer.rb

Overview

Model for an Offer

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contentObject

Returns the value of attribute content.



7
8
9
# File 'lib/cognitive_faculty/models/offer.rb', line 7

def content
  @content
end

#descriptionObject

Returns the value of attribute description.



7
8
9
# File 'lib/cognitive_faculty/models/offer.rb', line 7

def description
  @description
end

Instance Method Details

#claim(opts = {}) ⇒ Object

her < 1.0 can’t parse codes properly because they under a root element has_many :codes



19
20
21
22
23
# File 'lib/cognitive_faculty/models/offer.rb', line 19

def claim(opts = {})
  self.class.put_raw("/api/offers/#{id}/codes/claim", opts) do |parsed_data|
    parsed_data[:data][:code]
  end
end

#codes(opts = {}) ⇒ Object



25
26
27
28
29
# File 'lib/cognitive_faculty/models/offer.rb', line 25

def codes(opts = {})
  self.class.get_raw("/api/offers/#{id}/codes", opts) do |parsed_data|
    parsed_data[:data][:codes].map { |c| Code.new(c) }
  end
end