Class: Immobilienscout::API::Attachment
- Inherits:
-
Object
- Object
- Immobilienscout::API::Attachment
- Defined in:
- lib/immobilienscout/api/attachment.rb
Class Method Summary collapse
- .add(is24_id, binary_file, metadata) ⇒ Object
- .destroy(is24_id, attachment_id) ⇒ Object
- .put_order(is24_id, params) ⇒ Object
- .retrieve_all(is24_id) ⇒ Object
Class Method Details
.add(is24_id, binary_file, metadata) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/immobilienscout/api/attachment.rb', line 7 def add(is24_id, binary_file, ) raise ArgumentError unless is24_id.present? && binary_file.present? && .present? url = add_url(is24_id) = () params = { attachment: binary_file, metadata: } parsed_response = Immobilienscout::Request.new(url, params).post_with_multipart unless parsed_response.success? raise Immobilienscout::Errors::InvalidRequest, parsed_response..map(&:messages) end parsed_response end |
.destroy(is24_id, attachment_id) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/immobilienscout/api/attachment.rb', line 43 def destroy(is24_id, ) raise ArgumentError unless is24_id.present? raise ArgumentError unless .present? url = destroy_url(is24_id, ) parsed_response = Immobilienscout::Request.new(url).delete Immobilienscout::RequestErrorHandler.handle(parsed_response) unless parsed_response.success? parsed_response end |
.put_order(is24_id, params) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/immobilienscout/api/attachment.rb', line 22 def put_order(is24_id, params) raise ArgumentError unless params.present? parsed_response = Immobilienscout::Request.new(put_order_url(is24_id), params).put unless parsed_response.success? raise Immobilienscout::Errors::InvalidRequest, parsed_response..map(&:messages) end parsed_response end |
.retrieve_all(is24_id) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/immobilienscout/api/attachment.rb', line 33 def retrieve_all(is24_id) raise ArgumentError unless is24_id.present? url = retrieve_all_url(is24_id) parsed_response = Immobilienscout::Request.new(url).get Immobilienscout::RequestErrorHandler.handle(parsed_response) unless parsed_response.success? parsed_response end |