Class: MingleAPI::Card
- Defined in:
- lib/mingle/mingle-api.rb
Instance Method Summary collapse
- #card_type ⇒ Object
- #create ⇒ Object
- #created_on ⇒ Object
- #description ⇒ Object
-
#element_path(options = nil) ⇒ Object
begin monkey patches.
- #encode(options = {}) ⇒ Object
- #id ⇒ Object
- #modified_on ⇒ Object
- #name ⇒ Object
-
#number ⇒ Object
end monkey patches.
- #properties ⇒ Object
- #update ⇒ Object
Methods inherited from Base
Instance Method Details
#card_type ⇒ Object
199 200 201 |
# File 'lib/mingle/mingle-api.rb', line 199 def card_type @attributes['card_type'] end |
#create ⇒ Object
166 167 168 169 170 171 |
# File 'lib/mingle/mingle-api.rb', line 166 def create connection.post(collection_path + '?' + encode, nil, self.class.headers).tap do |response| self.number = id_from_response(response) load_attributes_from_response(response) end end |
#created_on ⇒ Object
187 188 189 |
# File 'lib/mingle/mingle-api.rb', line 187 def created_on @attributes['created_on'] end |
#description ⇒ Object
195 196 197 |
# File 'lib/mingle/mingle-api.rb', line 195 def description @attributes['description'] end |
#element_path(options = nil) ⇒ Object
begin monkey patches
132 133 134 |
# File 'lib/mingle/mingle-api.rb', line 132 def element_path( = nil) self.class.element_path(self.number, ) end |
#encode(options = {}) ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/mingle/mingle-api.rb', line 136 def encode(={}) val = [] attributes.each_pair do |key, value| unless value.nil? case key when 'card_type' if value.is_a? Hash name = value[:name] else name = value.name end val << "card[card_type_name]=#{URI.escape name}" when 'properties' value.each {|property| val << "card[properties][][name]=#{URI.escape property[0]} &card[properties][][value]=#{URI.escape property[1]}"} rescue NoMethodError else val << "card[#{URI.escape key.to_s}]=#{URI.escape value.to_s}" rescue nil end end end val.join('&') end |
#id ⇒ Object
179 180 181 |
# File 'lib/mingle/mingle-api.rb', line 179 def id @attributes['id'] end |
#modified_on ⇒ Object
191 192 193 |
# File 'lib/mingle/mingle-api.rb', line 191 def modified_on @attributes['modified_on'] end |
#name ⇒ Object
183 184 185 |
# File 'lib/mingle/mingle-api.rb', line 183 def name @attributes['name'] end |
#number ⇒ Object
end monkey patches
175 176 177 |
# File 'lib/mingle/mingle-api.rb', line 175 def number @attributes['number'] end |
#properties ⇒ Object
203 204 205 |
# File 'lib/mingle/mingle-api.rb', line 203 def properties @attributes['properties'] end |
#update ⇒ Object
160 161 162 163 164 |
# File 'lib/mingle/mingle-api.rb', line 160 def update connection.put(element_path() + '?' + encode, nil, self.class.headers).tap do |response| load_attributes_from_response(response) end end |