Class: Hcp::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/hcp/resource.rb

Overview

A record as Housecall Pro answered it.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node: {}, company_id: nil) ⇒ Resource

Returns a new instance of Resource.

Parameters:

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

    the record as Housecall Pro answered it.

  • company_id (String, nil) (defaults to: nil)

    the location it was read as.



26
27
28
29
# File 'lib/hcp/resource.rb', line 26

def initialize(node: {}, company_id: nil)
  @node = node
  @company_id = company_id
end

Class Method Details

.amount(name, key = name) ⇒ Object

Declares a reader for a sum Housecall Pro counts in cents.



21
# File 'lib/hcp/resource.rb', line 21

def amount(name, key = name) = define_method(name) { money key.to_s }

.attribute(name, key = name) ⇒ Object

Declares a reader for what Housecall Pro answers under a name.



9
# File 'lib/hcp/resource.rb', line 9

def attribute(name, key = name) = define_method(name) { @node[key.to_s] }

.timestamp(name, key = name) ⇒ Object

Declares a reader for a moment Housecall Pro stamps.



15
# File 'lib/hcp/resource.rb', line 15

def timestamp(name, key = name) = define_method(name) { time key.to_s }

Instance Method Details

#idString

Returns the ID Housecall Pro files the record under.

Returns:

  • (String)

    the ID Housecall Pro files the record under.



32
# File 'lib/hcp/resource.rb', line 32

def id = @node['id']