Class: FreeAgent::Contact

Inherits:
Base
  • Object
show all
Defined in:
lib/free_agent/contact.rb

Overview

Represents a Contact in FreeAgent.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#respond_to?

Instance Attribute Details

#first_nameString

Returns the current value of first_name.

Returns:

  • (String)

    the current value of first_name



9
10
11
# File 'lib/free_agent/contact.rb', line 9

def first_name
  @first_name
end

#last_nameString

Returns the current value of last_name.

Returns:

  • (String)

    the current value of last_name



9
10
11
# File 'lib/free_agent/contact.rb', line 9

def last_name
  @last_name
end

#organisation_nameString

Returns the current value of organisation_name.

Returns:

  • (String)

    the current value of organisation_name



9
10
11
# File 'lib/free_agent/contact.rb', line 9

def organisation_name
  @organisation_name
end

Instance Method Details

#invoices(options = {}) ⇒ Array<FreeAgent::Invoice>

Gets all the invoices associated to this contact.

Examples:

Simple query

contact.invoices
# => [...]

Query with custom find params

contact.invoices(:params => { :foo => 'bar' }
# => [...]

Gets all the invoices for this contact.

Parameters:

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

    Hash of options to customize the finder behavior.

Returns:



69
70
71
72
# File 'lib/free_agent/contact.rb', line 69

def invoices(*args)
  options = args.extract_options!
  Invoice.all(options.merge!(:from => "/contacts/#{id}/invoices.xml"))
end

#nameString? Also known as: name?

Creates the name of the contact, composed by the interpolation of #first_name and #last_name.

Returns:

  • (String, nil)

    The Contact name.



47
48
49
50
# File 'lib/free_agent/contact.rb', line 47

def name
  attrs = [first_name, last_name].reject(&:blank?)
  attrs.empty? ? nil : attrs.join(" ")
end