Class: MyJohnDeereApi::Model::Organization

Inherits:
Base
  • Object
show all
Defined in:
lib/my_john_deere_api/model/organization.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#client, #id, #links, #record, #record_type

Instance Method Summary collapse

Methods inherited from Base

#accessor, #initialize

Constructor Details

This class inherits a constructor from MyJohnDeereApi::Model::Base

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/my_john_deere_api/model/organization.rb', line 5

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/my_john_deere_api/model/organization.rb', line 5

def type
  @type
end

Instance Method Details

#assetsObject

assets associated with this organization



26
27
28
29
# File 'lib/my_john_deere_api/model/organization.rb', line 26

def assets
  return @assets if defined?(@assets)
  @assets = MyJohnDeereApi::Request::Collection::Assets.new(client, organization: id)
end

#connections_uriObject

the URI for JD connections page, if available



41
42
43
# File 'lib/my_john_deere_api/model/organization.rb', line 41

def connections_uri
  record['links'].detect{|link| link['rel'] == 'connections'}&.fetch('uri')
end

#fieldsObject

fields associated with this organization



18
19
20
21
# File 'lib/my_john_deere_api/model/organization.rb', line 18

def fields
  return @fields if defined?(@fields)
  @fields = MyJohnDeereApi::Request::Collection::Fields.new(client, organization: id)
end

#member?Boolean

Since the member attribute is boolean, we reflect this in the method name instead of using a standard attr_reader.

Returns:

  • (Boolean)


11
12
13
# File 'lib/my_john_deere_api/model/organization.rb', line 11

def member?
  @member
end

#needs_connection?Boolean

whether this organization still needs to be approved in JD “connections”

Returns:

  • (Boolean)


34
35
36
# File 'lib/my_john_deere_api/model/organization.rb', line 34

def needs_connection?
  links.key?('connections')
end