Class: Insightly::ReadOnly
- Inherits:
-
Base
- Object
- Base
- Insightly::ReadOnly
show all
- Defined in:
- lib/insightly/read_only.rb
Direct Known Subclasses
Country, Currency, CustomField, OpportunityCategory, OpportunityStateReason, Relationship, Tag, TaskCategory, TaskLink, TeamMember, User
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
all, api_field, custom_fields, #load, #reload, #remote_id, #to_json, #url_base
Constructor Details
Returns a new instance of ReadOnly.
3
4
5
6
|
# File 'lib/insightly/read_only.rb', line 3
def initialize
@data = {}
end
|
Class Method Details
.build(data) ⇒ Object
11
12
13
|
# File 'lib/insightly/read_only.rb', line 11
def self.build(data)
self.new.build(data)
end
|
Instance Method Details
#==(other) ⇒ Object
14
15
16
|
# File 'lib/insightly/read_only.rb', line 14
def ==(other)
self.remote_data == other.remote_data
end
|
#build(data) ⇒ Object
7
8
9
10
|
# File 'lib/insightly/read_only.rb', line 7
def build(data)
@data = data
self
end
|
#get_collection(path, content_type = :json) ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'lib/insightly/read_only.rb', line 35
def get_collection(path, content_type = :json)
response = RestClient::Request.new(:method => :get,
:url => "#{config.endpoint}/#{path.to_s}",
:user => config.api_key,
:password => "",
:headers => {:accept => content_type, :content_type => content_type}).execute
process(response, content_type)
end
|
#process(result, content_type) ⇒ Object
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/insightly/read_only.rb', line 20
def process(result, content_type)
puts result
if content_type == :json
JSON.parse(result.to_str)
elsif content_type == :xml
Hash.from_xml(result.to_str)
else
result.to_str
end
end
|
#remote_data ⇒ Object
17
18
19
|
# File 'lib/insightly/read_only.rb', line 17
def remote_data
@data
end
|