Class: Immobilienscout::API::Attachment

Inherits:
Object
  • Object
show all
Defined in:
lib/immobilienscout/api/attachment.rb

Class Method Summary collapse

Class Method Details

.add(is24_id, binary_file, metadata) ⇒ Object

Raises:

  • (ArgumentError)


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.messages.map(&:messages)
  end

  parsed_response
end

.destroy(is24_id, attachment_id) ⇒ Object

Raises:

  • (ArgumentError)


43
44
45
46
47
48
49
50
51
52
# File 'lib/immobilienscout/api/attachment.rb', line 43

def destroy(is24_id, attachment_id)
  raise ArgumentError unless is24_id.present?
  raise ArgumentError unless attachment_id.present?

  url = destroy_url(is24_id, attachment_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

Raises:

  • (ArgumentError)


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.messages.map(&:messages)
  end

  parsed_response
end

.retrieve_all(is24_id) ⇒ Object

Raises:

  • (ArgumentError)


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