Module: Immobilienscout24::Api::Contact

Included in:
Immobilienscout24::Api
Defined in:
lib/immobilienscout24/api/contact.rb

Overview

Methods for the Contact API

Per default the client will use the current user (‘me`). If you want to use an other user then you have to provide the id in the options hash.

Examples:

client.contact(663515214, user: immoscout_user_id)

See Also:

Instance Method Summary collapse

Instance Method Details

#contact(id, options = {}) ⇒ Hashie::Mash

Get a contact

Examples:

client.contact(663515214)

Parameters:

  • id (String, Integer)

    Contact id

  • options (Hash) (defaults to: {})

    Additional options

Returns:

  • (Hashie::Mash)

    Immobilienscout24 response

See Also:



35
36
37
# File 'lib/immobilienscout24/api/contact.rb', line 35

def contact(id, options = {})
  get contact_endpoint("/contact/#{id}", options)
end

#contact_endpoint(resource, options = {}) ⇒ String

Generates the contact endpoint

Parameters:

  • resource (String, Integer)

    In most cases the id of the contact

  • options (Hash) (defaults to: {})

    Additional options

Returns:

  • (String)

    The url to the contact resource



71
72
73
74
# File 'lib/immobilienscout24/api/contact.rb', line 71

def contact_endpoint(resource, options = {})
  options = {user: "me"}.merge(options)
  user_contact_endpoint(options.fetch(:user), resource, options)
end

#contacts(options = {}) ⇒ Hashie::Mash

Get a list of all contacts

Examples:

client.contacts

Parameters:

  • options (Hash) (defaults to: {})

    Additional options

Returns:

  • (Hashie::Mash)

    Immobilienscout24 response

See Also:



23
24
25
# File 'lib/immobilienscout24/api/contact.rb', line 23

def contacts(options = {})
  get contact_endpoint("/contact", options)
end

#create_contact(contact, options = {}) ⇒ Hashie::Mash

Create a contact

Examples:

client.create_contact(contact)

Parameters:

  • contact (Hash)

    The new contact

  • options (Hash) (defaults to: {})

    Additional options

Returns:

  • (Hashie::Mash)

    Immobilienscout24 response

See Also:



47
48
49
# File 'lib/immobilienscout24/api/contact.rb', line 47

def create_contact(contact, options = {})
  post contact_endpoint("/contact", options), contact
end

#update_contact(id, contact, options = {}) ⇒ Hashie::Mash

Update a contact

Examples:

client.update_contact(663515214, contact)

Parameters:

  • id (String, Integer)

    Contact id

  • contact (Hash)

    Data to update

  • options (Hash) (defaults to: {})

    Additional options

Returns:

  • (Hashie::Mash)

    Immobilienscout24 response

See Also:



60
61
62
# File 'lib/immobilienscout24/api/contact.rb', line 60

def update_contact(id, contact, options = {})
  put contact_endpoint("/contact/#{id}", options), contact
end

#user_contact_endpoint(user, resource, options = {}) ⇒ Object



76
77
78
# File 'lib/immobilienscout24/api/contact.rb', line 76

def user_contact_endpoint(user, resource, options = {})
  [user_endpoint("/user/#{user}"), resource].join
end