clio_client 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +169 -0
- data/Rakefile +9 -0
- data/clio_client.gemspec +27 -0
- data/lib/clio_client/api/activity.rb +23 -0
- data/lib/clio_client/api/activity_description.rb +17 -0
- data/lib/clio_client/api/base.rb +18 -0
- data/lib/clio_client/api/bill.rb +23 -0
- data/lib/clio_client/api/calendar.rb +19 -0
- data/lib/clio_client/api/calendar_entry.rb +20 -0
- data/lib/clio_client/api/communication.rb +25 -0
- data/lib/clio_client/api/contact.rb +23 -0
- data/lib/clio_client/api/crudable.rb +25 -0
- data/lib/clio_client/api/custom_field.rb +19 -0
- data/lib/clio_client/api/custom_field_set.rb +19 -0
- data/lib/clio_client/api/document.rb +20 -0
- data/lib/clio_client/api/document_version.rb +29 -0
- data/lib/clio_client/api/findable.rb +16 -0
- data/lib/clio_client/api/group.rb +22 -0
- data/lib/clio_client/api/listable.rb +44 -0
- data/lib/clio_client/api/matter.rb +22 -0
- data/lib/clio_client/api/note.rb +22 -0
- data/lib/clio_client/api/practice_area.rb +22 -0
- data/lib/clio_client/api/relationship.rb +22 -0
- data/lib/clio_client/api/task.rb +22 -0
- data/lib/clio_client/api/timeline_event.rb +19 -0
- data/lib/clio_client/api/timer.rb +31 -0
- data/lib/clio_client/api/user.rb +31 -0
- data/lib/clio_client/authorization.rb +41 -0
- data/lib/clio_client/http.rb +92 -0
- data/lib/clio_client/models/account.rb +16 -0
- data/lib/clio_client/models/activity.rb +31 -0
- data/lib/clio_client/models/activity_description.rb +21 -0
- data/lib/clio_client/models/bill.rb +45 -0
- data/lib/clio_client/models/calendar.rb +19 -0
- data/lib/clio_client/models/calendar_entry.rb +32 -0
- data/lib/clio_client/models/communication.rb +34 -0
- data/lib/clio_client/models/company.rb +7 -0
- data/lib/clio_client/models/contact.rb +38 -0
- data/lib/clio_client/models/custom_field.rb +21 -0
- data/lib/clio_client/models/custom_field_set.rb +21 -0
- data/lib/clio_client/models/document.rb +33 -0
- data/lib/clio_client/models/document_version.rb +26 -0
- data/lib/clio_client/models/email_communication.rb +8 -0
- data/lib/clio_client/models/expense_entry.rb +9 -0
- data/lib/clio_client/models/group.rb +18 -0
- data/lib/clio_client/models/matter.rb +45 -0
- data/lib/clio_client/models/note.rb +23 -0
- data/lib/clio_client/models/person.rb +9 -0
- data/lib/clio_client/models/phone_communication.rb +8 -0
- data/lib/clio_client/models/practice_area.rb +18 -0
- data/lib/clio_client/models/relationship.rb +19 -0
- data/lib/clio_client/models/task.rb +29 -0
- data/lib/clio_client/models/time_entry.rb +9 -0
- data/lib/clio_client/models/timeline_event.rb +25 -0
- data/lib/clio_client/models/timer.rb +28 -0
- data/lib/clio_client/models/user.rb +28 -0
- data/lib/clio_client/resource.rb +183 -0
- data/lib/clio_client/session.rb +56 -0
- data/lib/clio_client/support/address.rb +16 -0
- data/lib/clio_client/support/custom_field_checkbox_value.rb +7 -0
- data/lib/clio_client/support/custom_field_contact_value.rb +10 -0
- data/lib/clio_client/support/custom_field_currency_value.rb +7 -0
- data/lib/clio_client/support/custom_field_date_value.rb +7 -0
- data/lib/clio_client/support/custom_field_email_value.rb +7 -0
- data/lib/clio_client/support/custom_field_matter_value.rb +9 -0
- data/lib/clio_client/support/custom_field_numeric_value.rb +7 -0
- data/lib/clio_client/support/custom_field_picklist_option.rb +13 -0
- data/lib/clio_client/support/custom_field_picklist_value.rb +9 -0
- data/lib/clio_client/support/custom_field_text_area_value.rb +7 -0
- data/lib/clio_client/support/custom_field_text_line_value.rb +7 -0
- data/lib/clio_client/support/custom_field_time_value.rb +7 -0
- data/lib/clio_client/support/custom_field_url_value.rb +7 -0
- data/lib/clio_client/support/custom_field_value.rb +13 -0
- data/lib/clio_client/support/email_address.rb +12 -0
- data/lib/clio_client/support/instant_messenger.rb +12 -0
- data/lib/clio_client/support/phone_number.rb +13 -0
- data/lib/clio_client/support/rate.rb +16 -0
- data/lib/clio_client/support/reminder.rb +11 -0
- data/lib/clio_client/support/web_site.rb +12 -0
- data/lib/clio_client/version.rb +3 -0
- data/lib/clio_client.rb +107 -0
- data/spec/api/crudable_spec.rb +54 -0
- data/spec/api/findable_spec.rb +25 -0
- data/spec/api/listable_spec.rb +27 -0
- data/spec/features/activities_spec.rb +35 -0
- data/spec/models/account_spec.rb +12 -0
- data/spec/models/activity_description_spec.rb +47 -0
- data/spec/models/activity_spec.rb +29 -0
- data/spec/models/bill_spec.rb +63 -0
- data/spec/models/calendar_entry_spec.rb +62 -0
- data/spec/models/calendar_spec.rb +20 -0
- data/spec/models/communication_spec.rb +39 -0
- data/spec/models/company_spec.rb +5 -0
- data/spec/models/contact_spec.rb +5 -0
- data/spec/models/custom_field_set_spec.rb +5 -0
- data/spec/models/custom_field_spec.rb +5 -0
- data/spec/models/document_spec.rb +5 -0
- data/spec/models/document_version_spec.rb +6 -0
- data/spec/models/email_communication_spec.rb +6 -0
- data/spec/models/expense_entry_spec.rb +5 -0
- data/spec/models/group_spec.rb +5 -0
- data/spec/models/matter_spec.rb +5 -0
- data/spec/models/note_spec.rb +5 -0
- data/spec/models/person_spec.rb +5 -0
- data/spec/models/phone_communication_spec.rb +5 -0
- data/spec/models/practice_area_spec.rb +5 -0
- data/spec/models/relationship_spec.rb +5 -0
- data/spec/models/resource_spec.rb +116 -0
- data/spec/models/task_spec.rb +5 -0
- data/spec/models/time_entry_spec.rb +41 -0
- data/spec/models/timeline_event_spec.rb +6 -0
- data/spec/models/timer_spec.rb +6 -0
- data/spec/models/user_spec.rb +5 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/support/associated_resource.rb +6 -0
- data/spec/support/dummy_endpoint.rb +11 -0
- data/spec/support/inherited_resource.rb +2 -0
- data/spec/support/resource_examples.rb +82 -0
- data/spec/support/test_resource.rb +11 -0
- metadata +286 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module ClioClient
|
|
2
|
+
module Api
|
|
3
|
+
class PracticeArea < Base
|
|
4
|
+
|
|
5
|
+
include ClioClient::Api::Listable
|
|
6
|
+
include ClioClient::Api::Findable
|
|
7
|
+
include ClioClient::Api::Crudable
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
def data_klass(*args)
|
|
13
|
+
ClioClient::PracticeArea
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def end_point_url; 'practice_areas'; end
|
|
17
|
+
def plural_resource; 'practice_areas'; end
|
|
18
|
+
def singular_resource; 'practice_area'; end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module ClioClient
|
|
2
|
+
module Api
|
|
3
|
+
class Relationship < Base
|
|
4
|
+
|
|
5
|
+
include ClioClient::Api::Listable
|
|
6
|
+
include ClioClient::Api::Findable
|
|
7
|
+
include ClioClient::Api::Crudable
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
def data_klass(*args)
|
|
13
|
+
ClioClient::Relationship
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def end_point_url; 'relationships'; end
|
|
17
|
+
def plural_resource; 'relationships'; end
|
|
18
|
+
def singular_resource; 'relationship'; end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module ClioClient
|
|
2
|
+
module Api
|
|
3
|
+
class Task < Base
|
|
4
|
+
|
|
5
|
+
include ClioClient::Api::Listable
|
|
6
|
+
include ClioClient::Api::Findable
|
|
7
|
+
include ClioClient::Api::Crudable
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
def data_klass(*args)
|
|
13
|
+
ClioClient::Task
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def end_point_url; 'tasks'; end
|
|
17
|
+
def plural_resource; 'tasks'; end
|
|
18
|
+
def singular_resource; 'task'; end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module ClioClient
|
|
2
|
+
module Api
|
|
3
|
+
class TimelineEvent < Base
|
|
4
|
+
|
|
5
|
+
include ClioClient::Api::Listable
|
|
6
|
+
|
|
7
|
+
private
|
|
8
|
+
|
|
9
|
+
def data_klass(*args)
|
|
10
|
+
ClioClient::TimelineEvent
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def end_point_url; 'timeline_events'; end
|
|
14
|
+
def plural_resource; 'timeline_events'; end
|
|
15
|
+
def singular_resource; 'timeline_event'; end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module ClioClient
|
|
2
|
+
module Api
|
|
3
|
+
class Timer < Base
|
|
4
|
+
|
|
5
|
+
def find
|
|
6
|
+
response = session.get("#{end_point_url}")
|
|
7
|
+
data_item(response[singular_resource])
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def start(params = {})
|
|
11
|
+
response = session.post(end_point_url, {singular_resource => params}.to_json)
|
|
12
|
+
data_item(response[singular_resource])
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def stop
|
|
16
|
+
session.delete("#{end_point_url}", false)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def data_klass(*args)
|
|
22
|
+
ClioClient::Timer
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def end_point_url; 'timer'; end
|
|
26
|
+
def plural_resource; 'timer'; end
|
|
27
|
+
def singular_resource; 'timer'; end
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module ClioClient
|
|
2
|
+
module Api
|
|
3
|
+
class User < Base
|
|
4
|
+
|
|
5
|
+
include ClioClient::Api::Listable
|
|
6
|
+
include ClioClient::Api::Findable
|
|
7
|
+
|
|
8
|
+
def avatar(id)
|
|
9
|
+
session.get("#{end_point_url}/#{id}/avatar")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def who_am_i
|
|
13
|
+
resp = session.get("#{end_point_url}/who_am_i")
|
|
14
|
+
[ClioClient::Account.new(resp["account"], session),
|
|
15
|
+
ClioClient::User.new(resp["user"], session)]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def data_klass(*args)
|
|
22
|
+
ClioClient::User
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def end_point_url; 'users'; end
|
|
26
|
+
def plural_resource; 'users'; end
|
|
27
|
+
def singular_resource; 'user'; end
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module ClioClient
|
|
2
|
+
|
|
3
|
+
module Authorization
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def authorize_url(redirect_uri, state = nil)
|
|
7
|
+
params = { response_type: :code,
|
|
8
|
+
client_id: self.client_id,
|
|
9
|
+
redirect_uri: redirect_uri
|
|
10
|
+
}
|
|
11
|
+
params[:state] = state if state
|
|
12
|
+
base_uri("/oauth/authorize", params).to_s
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def authorize_with_code(redirect_uri, code)
|
|
16
|
+
params = { code: code,
|
|
17
|
+
grant_type: "authorization_code",
|
|
18
|
+
client_id: self.client_id,
|
|
19
|
+
client_secret: self.client_secret,
|
|
20
|
+
redirect_uri: redirect_uri
|
|
21
|
+
}
|
|
22
|
+
uri = base_uri("/oauth/token")
|
|
23
|
+
req = Net::HTTP::Post.new(uri.request_uri)
|
|
24
|
+
req.set_form_data params
|
|
25
|
+
credentials = make_request(req, uri)
|
|
26
|
+
self.access_token = credentials["access_token"]
|
|
27
|
+
credentials
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def authorized?
|
|
31
|
+
begin
|
|
32
|
+
get("/users/who_am_i")
|
|
33
|
+
true
|
|
34
|
+
rescue ClioClient::Unauthorized
|
|
35
|
+
false
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
module ClioClient
|
|
2
|
+
|
|
3
|
+
class Unauthorized < Exception; end
|
|
4
|
+
class ResourceNotFound < Exception; end
|
|
5
|
+
class BadRequest < Exception; end
|
|
6
|
+
|
|
7
|
+
module Http
|
|
8
|
+
|
|
9
|
+
def base_uri(path, params = {})
|
|
10
|
+
uri = URI.parse("https://app.goclio.com")
|
|
11
|
+
uri.path = path
|
|
12
|
+
uri.query = URI.encode_www_form(params) if params.any?
|
|
13
|
+
uri
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def get(path, params ={}, parse=true)
|
|
17
|
+
uri = base_uri("#{api_prefix}/#{path}", params)
|
|
18
|
+
req = Net::HTTP::Get.new(uri.to_s)
|
|
19
|
+
make_api_request(req, uri, parse)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def put(path, body = "", parse=true)
|
|
23
|
+
uri = base_uri("#{api_prefix}/#{path}")
|
|
24
|
+
req = Net::HTTP::Put.new(uri.request_uri)
|
|
25
|
+
req.body = body
|
|
26
|
+
req.add_field("Content-Type", "application/json")
|
|
27
|
+
make_api_request(req, uri, parse)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def multipart_post(path, params, parse = true)
|
|
31
|
+
uri = base_uri("#{api_prefix}/#{path}")
|
|
32
|
+
req = Net::HTTP::Post::Multipart.new(uri.request_uri, params)
|
|
33
|
+
make_api_request(req, uri, parse)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def post(path, body ="", parse = true)
|
|
37
|
+
uri = base_uri("#{api_prefix}/#{path}")
|
|
38
|
+
req = Net::HTTP::Post.new(uri.request_uri)
|
|
39
|
+
req.body = body
|
|
40
|
+
req.add_field("Content-Type", "application/json")
|
|
41
|
+
make_api_request(req, uri, parse)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def delete(path, parse=true)
|
|
45
|
+
uri = base_uri("#{api_prefix}/#{path}")
|
|
46
|
+
req = Net::HTTP::Delete.new(uri.request_uri)
|
|
47
|
+
make_api_request(req, uri, parse)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def make_api_request(req, uri, parse = true)
|
|
51
|
+
return nil if self.access_token.nil? || self.access_token.empty?
|
|
52
|
+
req.add_field("Authorization", "Bearer #{self.access_token}")
|
|
53
|
+
make_request(req, uri, parse)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def make_request(req, uri, parse = true)
|
|
57
|
+
req.add_field("Accept", "text/json")
|
|
58
|
+
n = Net::HTTP.new(uri.host, uri.port)
|
|
59
|
+
n.use_ssl = true
|
|
60
|
+
res = n.start do |http|
|
|
61
|
+
http.request(req)
|
|
62
|
+
end
|
|
63
|
+
parse_response(res, parse)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def parse_response(res, parse)
|
|
67
|
+
if res.body !~ /^\s*$/ && !res.body.nil?
|
|
68
|
+
body = parse ? JSON.parse(res.body) : res.body
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
case res
|
|
72
|
+
when Net::HTTPNotFound
|
|
73
|
+
raise ClioClient::ResourceNotFound.new(body["message"])
|
|
74
|
+
when Net::HTTPSuccess
|
|
75
|
+
body
|
|
76
|
+
when Net::HTTPUnauthorized
|
|
77
|
+
raise ClioClient::Unauthorized.new(body["message"])
|
|
78
|
+
when Net::HTTPBadRequest
|
|
79
|
+
raise ClioClient::BadRequest.new(body["message"])
|
|
80
|
+
when Net::HTTPSeeOther
|
|
81
|
+
res["Location"]
|
|
82
|
+
else
|
|
83
|
+
raise "Unknown #{res.class} response. #{body["message"]}"
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
private
|
|
88
|
+
def api_prefix; "/api/v2"; end
|
|
89
|
+
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module ClioClient
|
|
2
|
+
|
|
3
|
+
class Account < Resource
|
|
4
|
+
|
|
5
|
+
set_attributes(id: {type: :int, readonly: true},
|
|
6
|
+
created_at: {type: :datetime, readonly: true},
|
|
7
|
+
updated_at: {type: :datetime, readonly: true},
|
|
8
|
+
maildrop_address: {type: :string},
|
|
9
|
+
name: {type: :string, readonly: true}
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
has_association :owner, ClioClient::User
|
|
13
|
+
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module ClioClient
|
|
2
|
+
|
|
3
|
+
class Activity < Resource
|
|
4
|
+
|
|
5
|
+
set_attributes(id: {type: :int, readonly: true},
|
|
6
|
+
created_at: {type: :datetime, readonly: true},
|
|
7
|
+
updated_at: {type: :datetime, readonly: true},
|
|
8
|
+
type: {type: :string, required: true},
|
|
9
|
+
date: {type: :date },
|
|
10
|
+
quantity: {type: :decimal, required: true},
|
|
11
|
+
price: {type: :decimal, required: true},
|
|
12
|
+
total: {type: :string, readonly: true},
|
|
13
|
+
note: {type: :string },
|
|
14
|
+
billed: {type: :boolean, readonly: true}
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
has_association :user, ClioClient::User
|
|
20
|
+
has_association :matter, ClioClient::Matter
|
|
21
|
+
has_association :activity_description, ClioClient::ActivityDescription
|
|
22
|
+
has_association :communication, ClioClient::Communication
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
def api
|
|
26
|
+
session.activities
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module ClioClient
|
|
2
|
+
|
|
3
|
+
class ActivityDescription < Resource
|
|
4
|
+
|
|
5
|
+
set_attributes(id: {type: :int, readonly: true},
|
|
6
|
+
name: {type: :string},
|
|
7
|
+
created_at: {type: :datetime, readonly: true},
|
|
8
|
+
updated_at: {type: :datetime, readonly: true},
|
|
9
|
+
activity_rate_default: {type: :rate}
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
has_many_association :rates, ClioClient::Rate
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
def api
|
|
16
|
+
session.activity_descriptions
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module ClioClient
|
|
2
|
+
class Bill < Resource
|
|
3
|
+
|
|
4
|
+
set_attributes(
|
|
5
|
+
id: {type: :int, readonly: true},
|
|
6
|
+
type: {type: :string, readonly: true},
|
|
7
|
+
original_bill_id: {type: :int, readonly: true},
|
|
8
|
+
created_at: {type: :datetime, readonly: true},
|
|
9
|
+
updated_at: {type: :datetime, readonly: true},
|
|
10
|
+
pdf_url: {type: :string, readonly: true},
|
|
11
|
+
number: {type: :string },
|
|
12
|
+
subject: {type: :string },
|
|
13
|
+
currency: {type: :string },
|
|
14
|
+
purchase_order: {type: :string },
|
|
15
|
+
memo: {type: :string },
|
|
16
|
+
start_at: {type: :datetime },
|
|
17
|
+
end_at: {type: :datetime },
|
|
18
|
+
issued_at: {type: :date },
|
|
19
|
+
due_at: {type: :date },
|
|
20
|
+
tax_rate: {type: :decimal },
|
|
21
|
+
secondary_tax_rate: {type: :decimal },
|
|
22
|
+
discount: {type: :decimal },
|
|
23
|
+
discount_type: {type: :string },
|
|
24
|
+
discount_note: {type: :note },
|
|
25
|
+
balance: {type: :decimal },
|
|
26
|
+
total: {type: :decimal },
|
|
27
|
+
status: {type: :string, readonly: true },
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
has_association :client, ClioClient::Contact
|
|
31
|
+
has_many_association :matters, ClioClient::Matter
|
|
32
|
+
|
|
33
|
+
def pdf
|
|
34
|
+
unless self.id.nil?
|
|
35
|
+
api.download(self.id)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
def api
|
|
41
|
+
session.bills
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module ClioClient
|
|
2
|
+
class Calendar < Resource
|
|
3
|
+
|
|
4
|
+
set_attributes(
|
|
5
|
+
id: {type: :int, readonly: true},
|
|
6
|
+
type: {type: :string, readonly: true},
|
|
7
|
+
created_at: {type: :datetime, readonly: true},
|
|
8
|
+
updated_at: {type: :datetime, readonly: true},
|
|
9
|
+
name: {type: :string },
|
|
10
|
+
color: {type: :string },
|
|
11
|
+
permission: {type: :string, readonly: true}
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
def api
|
|
16
|
+
session.calendars
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module ClioClient
|
|
2
|
+
class CalendarEntry < Resource
|
|
3
|
+
|
|
4
|
+
set_attributes(
|
|
5
|
+
id: {type: :int, readonly: true},
|
|
6
|
+
created_at: {type: :datetime, readonly: true},
|
|
7
|
+
updated_at: {type: :datetime, readonly: true},
|
|
8
|
+
start_date_time: {type: :datetime },
|
|
9
|
+
end_date_time: {type: :datetime },
|
|
10
|
+
start_date: {type: :date, readonly: true},
|
|
11
|
+
end_date: {type: :date },
|
|
12
|
+
summary: {type: :string },
|
|
13
|
+
description: {type: :string },
|
|
14
|
+
location: {type: :string },
|
|
15
|
+
permission: {type: :string, readonly: true},
|
|
16
|
+
recurrence_rule: {type: :string },
|
|
17
|
+
parent_calendar_entry_id: {type: :int },
|
|
18
|
+
original_event_start_date: {type: :datetime },
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
has_association :matter, ClioClient::Matter
|
|
22
|
+
has_association :calendar, ClioClient::Calendar
|
|
23
|
+
has_many_association :attending_calendars, ClioClient::Calendar
|
|
24
|
+
has_many_association :reminders, ClioClient::Reminder
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
def api
|
|
28
|
+
session.calendar_entries
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module ClioClient
|
|
2
|
+
|
|
3
|
+
class Communication < Resource
|
|
4
|
+
|
|
5
|
+
set_attributes(id: {type: :int, readonly: true},
|
|
6
|
+
type: {type: :string, readonly: true},
|
|
7
|
+
created_at: {type: :datetime, readonly: true},
|
|
8
|
+
updated_at: {type: :datetime, readonly: true},
|
|
9
|
+
subject: {type: :string},
|
|
10
|
+
body: {type: :string},
|
|
11
|
+
date: {type: :date},
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
alias_method :name, :subject
|
|
15
|
+
alias_method :name=, :subject=
|
|
16
|
+
|
|
17
|
+
has_association :matter, ClioClient::Matter
|
|
18
|
+
has_many_association(:senders, ClioClient::Resource,
|
|
19
|
+
:polymorphic => true,
|
|
20
|
+
:accepted_types => %w(Contact User))
|
|
21
|
+
|
|
22
|
+
has_many_association(:receivers, ClioClient::Resource,
|
|
23
|
+
:polymorphic => true,
|
|
24
|
+
:accepted_types => %w(Contact User))
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
def api
|
|
28
|
+
session.communications
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module ClioClient
|
|
2
|
+
class Contact < Resource
|
|
3
|
+
|
|
4
|
+
set_attributes(id: {type: :int, readonly: true},
|
|
5
|
+
type: {type: :string, readonly: true},
|
|
6
|
+
created_at: {type: :datetime, readonly: true},
|
|
7
|
+
updated_at: {type: :datetime, readonly: true},
|
|
8
|
+
name: {type: :string },
|
|
9
|
+
prefix: {type: :string },
|
|
10
|
+
first_name: {type: :string },
|
|
11
|
+
last_name: {type: :string },
|
|
12
|
+
title: {type: :string }
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
has_many_association :phone_numbers, ClioClient::PhoneNumber
|
|
16
|
+
has_many_association :email_addresses, ClioClient::EmailAddress
|
|
17
|
+
has_many_association :addresses, ClioClient::Address
|
|
18
|
+
has_many_association :web_sites, ClioClient::WebSite
|
|
19
|
+
has_many_association :instant_messengers, ClioClient::InstantMessenger
|
|
20
|
+
has_many_association(:custom_field_values, ClioClient::CustomFieldValue,
|
|
21
|
+
:polymorphic => true,
|
|
22
|
+
:accepted_types => %w(CustomFieldCheckboxValue CustomFieldContactValue
|
|
23
|
+
CustomFieldCurrencyValue CustomFieldDateValue CustomFieldTimeValue
|
|
24
|
+
CustomFieldEmailValue CustomFieldMatterValue CustomFieldNumericValue
|
|
25
|
+
CustomFieldPicklistValue CustomFieldTextAreaValue
|
|
26
|
+
CustomFieldTextLineValue CustomFieldUrlValue))
|
|
27
|
+
has_many_association :activity_rates, ClioClient::Rate
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
def api
|
|
32
|
+
session.contacts
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module ClioClient
|
|
2
|
+
class CustomField < Resource
|
|
3
|
+
|
|
4
|
+
set_attributes(id: {type: :int, readonly: true},
|
|
5
|
+
created_at: {type: :datetime, readonly: true},
|
|
6
|
+
updated_at: {type: :datetime, readonly: true},
|
|
7
|
+
name: {type: :string},
|
|
8
|
+
parent_type: {type: :string},
|
|
9
|
+
field_type: {type: :string},
|
|
10
|
+
displayed: {type: :boolean},
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
has_many_association :custom_field_picklist_options, ClioClient::CustomFieldPicklistOption
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
def api
|
|
17
|
+
session.custom_fields
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module ClioClient
|
|
2
|
+
class CustomFieldSet < Resource
|
|
3
|
+
|
|
4
|
+
set_attributes(id: {type: :int, readonly: true},
|
|
5
|
+
created_at: {type: :datetime, readonly: true},
|
|
6
|
+
updated_at: {type: :datetime, readonly: true},
|
|
7
|
+
name: {type: :string},
|
|
8
|
+
parent_type: {type: :string},
|
|
9
|
+
displayed: {type: :boolean},
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
has_many_association :members, ClioClient::CustomField
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
def api
|
|
17
|
+
session.custom_field_sets
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module ClioClient
|
|
2
|
+
class Document < Resource
|
|
3
|
+
|
|
4
|
+
set_attributes(id: {type: :int, readonly: true},
|
|
5
|
+
created_at: {type: :datetime, readonly: true},
|
|
6
|
+
updated_at: {type: :datetime, readonly: true},
|
|
7
|
+
description: {type: :string, readonly: true},
|
|
8
|
+
category: {type: :string, readonly: true},
|
|
9
|
+
content_type: {type: :string, readonly: true},
|
|
10
|
+
filename: {type: :string, readonly: true},
|
|
11
|
+
size: {type: :int, readonly: true},
|
|
12
|
+
last_modified: {type: :datetime},
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
has_association :matter, ClioClient::Matter
|
|
16
|
+
has_association :user, ClioClient::User
|
|
17
|
+
has_many_association :document_versions, ClioClient::DocumentVersion
|
|
18
|
+
|
|
19
|
+
def document_versions=(arr)
|
|
20
|
+
many = arr.collect do |attributes|
|
|
21
|
+
merged_attrs = attributes.merge("document_id" => id)
|
|
22
|
+
ClioClient::DocumentVersion.new(merged_attrs, session)
|
|
23
|
+
end
|
|
24
|
+
write_attribute("document_versions", many)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
def api
|
|
29
|
+
session.documents
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module ClioClient
|
|
2
|
+
class DocumentVersion < Resource
|
|
3
|
+
|
|
4
|
+
set_attributes(id: {type: :int, readonly: true},
|
|
5
|
+
document_id: {type: :int, readonly: true},
|
|
6
|
+
version: {type: :int, readonly: true},
|
|
7
|
+
created_at: {type: :datetime, readonly: true},
|
|
8
|
+
updated_at: {type: :datetime, readonly: true},
|
|
9
|
+
size: {type: :int, readonly: true},
|
|
10
|
+
content_type: {type: :string, readonly: true},
|
|
11
|
+
last_modified: {type: :datetime},
|
|
12
|
+
filename: {type: :string}
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
def download
|
|
16
|
+
api.download(id)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
def api
|
|
22
|
+
session.document_versions(document_id)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
end
|