Class: Rentlinx::Client

Overview

This class and its included modules encapsulate all communication directly with the Rentlinx API.

It should not be interacted with, the objects provide all the functionality necessary to work with Rentlinx.

Instance Method Summary collapse

Methods included from WebsitesClientMethods

#get_websites

Methods included from LinkClientMethods

#get_links_for_property_id, #get_links_for_unit, #post_links, #unpost_link, #unpost_links_for

Methods included from AmenityClientMethods

#get_amenities_for_property_id, #get_amenities_for_unit, #post_amenities, #unpost_amenities_for, #unpost_amenity

Methods included from PhotoClientMethods

#get_photos_for_property_id, #post_photos, #unpost_photo, #unpost_photos_for

Methods included from PropertyClientMethods

#get_units_for_property_id

Constructor Details

#initializeClient

Returns a new instance of client. Avoid using.

Note that the method Rentlinx.client initializes and caches an instance of the Rentlinx client. This method should be used instead of this one when interacting directly with the client to avoid making multiple connections to Rentlinx.

Rentlinx must be configured before invoking this method.



38
39
40
41
42
43
44
45
# File 'lib/rentlinx/client.rb', line 38

def initialize
  raise Rentlinx::NotConfigured if Rentlinx.username.nil? ||
                                   Rentlinx.password.nil? ||
                                   Rentlinx.site_url.nil?

  @url_prefix = (Rentlinx.site_url + '/').freeze # Extra slashes are fine
  @api_token ||= authenticate(Rentlinx.username, Rentlinx.password)
end

Instance Method Details

#get(type, id) ⇒ Object

Pulls the attributes for an object from Rentlinx and instantiates it

Parameters:

  • type (Symbol)

    the type of object to be fetched

  • id (String)

    the rentlinx id of the object to be fetched



101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/rentlinx/client.rb', line 101

def get(type, id)
  case type
  when :company
    Company.new(process_get("companies/#{id}"))
  when :property
    Property.new(process_get("properties/#{id}"))
  when :unit
    Unit.new(process_get("units/#{id}"))
  else
    raise InvalidTypeParam, "Type not recognized: #{type}"
  end
end

#patch(object) ⇒ Object

Pushes an object’s attributes out to Rentlinx

Parameters:



50
51
52
53
54
55
56
57
58
# File 'lib/rentlinx/client.rb', line 50

def patch(object)
  case object
  when Rentlinx::Property
    raise Rentlinx::InvalidObject, object unless object.patch_valid?
    patch_property(object)
  else
    raise TypeError, "Type not permitted: #{object.class}"
  end
end

#post(object) ⇒ Object

Pushes an object’s attributes out to Rentlinx

Parameters:

Raises:



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/rentlinx/client.rb', line 63

def post(object)
  raise Rentlinx::InvalidObject, object if object.respond_to?(:valid?) && !object.valid?

  case object
  when Rentlinx::Company
    post_company(object)
  when Rentlinx::Property
    post_property(object)
  when Rentlinx::Unit
    post_unit(object)
  when Rentlinx::Lead
    post_lead(object)
  else
    raise TypeError, "Type not permitted: #{object.class}"
  end
end

#unpost(type, id) ⇒ Object

Unposts an object from Rentlinx

Parameters:

  • type (Symbol)

    the type of object to be unposted

  • id (String)

    the rentlinx id of the object to be unposted



84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/rentlinx/client.rb', line 84

def unpost(type, id)
  case type
  when :company
    unpost_company(id)
  when :property
    unpost_property(id)
  when :unit
    unpost_unit(id)
  else
    raise TypeError, "Invalid type: #{type}"
  end
end