clio_client 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Kyle d'Oliveira
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
# ClioClient
|
2
|
+
|
3
|
+
This is an API client for Clio V2.
|
4
|
+
|
5
|
+
As we are all aware, the importance of API-level developments is paramount in the cloud-based software industry. Clio’s open API allows you to create valuable add-ons for your clients, and in turn, construct profitable revenue streams for your business.
|
6
|
+
|
7
|
+
Please direct any inquiries to the appropriate channel:
|
8
|
+
|
9
|
+
For technical inquiries: api@goclio.com
|
10
|
+
For business and partnership inquiries: api.partnerships@goclio.com
|
11
|
+
A community driven Clio Developers Google Group also exists where you can connect and ask questions from other Clio API users. For more information visit https://groups.google.com/forum/?fromgroups=#!forum/clio-developers.
|
12
|
+
|
13
|
+
We look forward to seeing your developments and creating successful relationships!
|
14
|
+
|
15
|
+
More information about the API can be found at http://api-docs.goclio.com/v2/index.html
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
Add this line to your application's Gemfile:
|
20
|
+
|
21
|
+
gem 'clio_client'
|
22
|
+
|
23
|
+
And then execute:
|
24
|
+
|
25
|
+
$ bundle
|
26
|
+
|
27
|
+
Or install it yourself as:
|
28
|
+
|
29
|
+
$ gem install clio_client
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
You will need to do a few things before you can get started with Clio and the API. For convience, this information is pulled directly from Clio's API documentation at the top.
|
34
|
+
|
35
|
+
|
36
|
+
### Create a Clio Account
|
37
|
+
|
38
|
+
1. Visit http://www.goclio.com/signup/ and create an account.
|
39
|
+
2. If you are only using your account to develop and test applications, contact api@goclio.com with your login email and we’ll set your account as a developer.
|
40
|
+
|
41
|
+
### Create a Clio Application
|
42
|
+
|
43
|
+
1. Login to your new Clio account at https://app.goclio.com/session/new
|
44
|
+
2. Visit our developer portal at https://app.goclio.com/settings/developer_applications
|
45
|
+
3. Click the Add button to create a new application. Enter details about your application here - these details will be shown to Clio users when they’re asked to authorize your application
|
46
|
+
4. Make note of the key and the secret, as these will be used to authorize your application with Clio
|
47
|
+
|
48
|
+
Now that you have the your key and secret we can begin working. The Key will correspond to `client_id` and the secret will correspond to `client_secret`
|
49
|
+
|
50
|
+
To get the access token, you can use the client to generate the authorize url to redirect the user.
|
51
|
+
|
52
|
+
```
|
53
|
+
client = ClioClient::Session.new({client_id: client_id, client_secret: client_secret})
|
54
|
+
client.authorize_url("http://mysite.com")
|
55
|
+
=> https://app.goclio.com/oauth/authorize?response_type=code&client_id=xxxxxxxx&redirect_uri=http%3A%2F%2Fmysite.com
|
56
|
+
```
|
57
|
+
Once the authorization has been granted Clio will redirect back to, in this example, `http://mysite.com` with the authorization code in a params `code`
|
58
|
+
|
59
|
+
```
|
60
|
+
client.authorize_with_code "http://mysite.com", code
|
61
|
+
=> {"access_token"=>"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "token_type"=>"bearer"}
|
62
|
+
client.authorized?
|
63
|
+
=> true
|
64
|
+
```
|
65
|
+
|
66
|
+
At this point the client is ready to use. You will need to save the `access_token` for future use.
|
67
|
+
|
68
|
+
There are many different end points you can now interact with. They all act mostly the same.
|
69
|
+
|
70
|
+
The end points available are on the ClioClient::Session
|
71
|
+
```
|
72
|
+
activities
|
73
|
+
activity_descriptions
|
74
|
+
bills
|
75
|
+
calendar_entries
|
76
|
+
calendars
|
77
|
+
communications
|
78
|
+
contacts
|
79
|
+
custom_field_sets
|
80
|
+
custom_fields
|
81
|
+
document_versions
|
82
|
+
documents
|
83
|
+
groups
|
84
|
+
matters
|
85
|
+
notes
|
86
|
+
practice_areas
|
87
|
+
relationships
|
88
|
+
tasks
|
89
|
+
timeline_events
|
90
|
+
timer
|
91
|
+
users
|
92
|
+
```
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
#### For endpoints that can "Get all X"
|
97
|
+
|
98
|
+
```
|
99
|
+
time_entry = client.activities.first(type: 'TimeEntry')
|
100
|
+
=> #<ClioClient::TimeEntry id: 12059966, created_at: #<DateTime: 2012-04-25T16:16:31+00:00 ((2456043j,58591s,0n),+0s,2299161j)>, updated_at: #<DateTime: 2013-12-14T18:52:45+00:00 ((2456641j,67965s,0n),+0s,2299161j)>, type: "TimeEntry", date: #<Date: 2012-04-25 ((2456043j,0s,0n),+0s,2299161j)>, quantity: 3600.0, price: 10.0, total: "10.0", note: "Do something", billed: false, user_id: 344053630>
|
101
|
+
client.activities.list(type: 'TimeEntry').first == time_entry
|
102
|
+
=> true
|
103
|
+
|
104
|
+
```
|
105
|
+
|
106
|
+
The amount of data returned is limited, so we can iterate over all of the results. The last query is saved and the next page of results can be accessed like this
|
107
|
+
```
|
108
|
+
time_entries = client.activities.list(type: 'TimeEntry')
|
109
|
+
begin
|
110
|
+
do_stuff(time_entries)
|
111
|
+
time_entries = client.activities.next_page
|
112
|
+
end while time_entries.count > 0
|
113
|
+
```
|
114
|
+
|
115
|
+
#### For endpoints that can 'Get a X' there is a `find` method
|
116
|
+
```
|
117
|
+
time_entry = client.activities.find(12059966)
|
118
|
+
=> #<ClioClient::TimeEntry id: 12059966, created_at: #<DateTime: 2012-04-25T16:16:31+00:00 ((2456043j,58591s,0n),+0s,2299161j)>, updated_at: #<DateTime: 2013-12-14T18:52:45+00:00 ((2456641j,67965s,0n),+0s,2299161j)>, type: "TimeEntry", date: #<Date: 2012-04-25 ((2456043j,0s,0n),+0s,2299161j)>, quantity: 3600.0, price: 10.0, total: "10.0", note: "Do something", billed: false, user_id: 344053630>
|
119
|
+
```
|
120
|
+
|
121
|
+
If we can find an object we can also reload an object to get the current state of the object. This is useful for association on object that return a minimum amount of information
|
122
|
+
```
|
123
|
+
time_entry = client.activities.find(12059966)
|
124
|
+
time_entry.user
|
125
|
+
=> #<ClioClient::User id: 344053630, name: "Foo Bar">
|
126
|
+
|
127
|
+
time_entry.user.reload
|
128
|
+
=> #<ClioClient::User id: 344053630, created_at: #<DateTime: 2012-04-25T15:33:34+00:00 ((2456043j,56014s,0n),+0s,2299161j)>, updated_at: #<DateTime: 2014-01-14T00:30:14+00:00 ((2456672j,1814s,0n),+0s,2299161j)>, subscription_plan: "Attorneys", time_zone: "Indiana (East)", first_name: "Foo", last_name: "Bar", email: "foo@bar.com", enabled: false>
|
129
|
+
|
130
|
+
```
|
131
|
+
|
132
|
+
#### For endpoints that have CRUD actions
|
133
|
+
|
134
|
+
We can create a new object via
|
135
|
+
```
|
136
|
+
time_entry = client.activities.new('type' => 'TimeEntry', 'date' => Date.today)
|
137
|
+
=> #<ClioClient::TimeEntry type: "TimeEntry", date: #<Date: 2014-01-21 ((2456679j,0s,0n),+0s,2299161j)>>
|
138
|
+
```
|
139
|
+
|
140
|
+
You can save it with
|
141
|
+
```
|
142
|
+
time_entry = client.activities.new('type' => 'TimeEntry', 'date' => Date.today)
|
143
|
+
=> #<ClioClient::TimeEntry type: "TimeEntry", date: #<Date: 2014-01-21 ((2456679j,0s,0n),+0s,2299161j)>>
|
144
|
+
time_entry.save
|
145
|
+
=> #<ClioClient::TimeEntry id: 51171062, type: "TimeEntry", date: #<Date: 2014-01-21 ((2456679j,0s,0n),+0s,2299161j)>>
|
146
|
+
|
147
|
+
```
|
148
|
+
|
149
|
+
To update, you can use the same `save` method.
|
150
|
+
|
151
|
+
To destroy an object you can do
|
152
|
+
```
|
153
|
+
time_entry = client.activities.find(51171062)
|
154
|
+
=> #<ClioClient::TimeEntry id: 51171062, created_at: #<DateTime: 2014-01-22T05:10:50+00:00 ((2456680j,18650s,0n),+0s,2299161j)>, updated_at: #<DateTime: 2014-01-22T05:10:50+00:00 ((2456680j,18650s,0n),+0s,2299161j)>, type: "TimeEntry", date: #<Date: 2014-01-21 ((2456679j,0s,0n),+0s,2299161j)>, quantity: 0.0, price: 0.0, total: "0.0", billed: false, user_id: 344053630>
|
155
|
+
time_entry.destroy
|
156
|
+
=> nil
|
157
|
+
```
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
## Contributing
|
164
|
+
|
165
|
+
1. Fork it
|
166
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
167
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
168
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
169
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/clio_client.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'clio_client/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "clio_client"
|
8
|
+
spec.version = ClioClient::VERSION
|
9
|
+
spec.authors = ["Kyle d'Oliveira"]
|
10
|
+
spec.email = ["kyle@goclio.com"]
|
11
|
+
spec.description = "Api client for Clio"
|
12
|
+
spec.summary = "A simple ruby library to interact with Clio's Api"
|
13
|
+
spec.homepage = "https://github.com/doliveirakn/clio_client"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "debugger"
|
24
|
+
spec.add_development_dependency "awesome_print"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ClioClient
|
2
|
+
module Api
|
3
|
+
class Activity < Base
|
4
|
+
|
5
|
+
include ClioClient::Api::Crudable
|
6
|
+
include ClioClient::Api::Listable
|
7
|
+
include ClioClient::Api::Findable
|
8
|
+
|
9
|
+
private
|
10
|
+
def data_klass(attributes)
|
11
|
+
accepted_types = %w(TimeEntry ExpenseEntry)
|
12
|
+
if accepted_types.include? attributes["type"]
|
13
|
+
ClioClient.const_get attributes["type"].intern
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def end_point_url; 'activities'; end
|
18
|
+
def plural_resource; 'activities'; end
|
19
|
+
def singular_resource; 'activity'; end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ClioClient
|
2
|
+
module Api
|
3
|
+
class ActivityDescription < Base
|
4
|
+
|
5
|
+
include ClioClient::Api::Listable
|
6
|
+
|
7
|
+
private
|
8
|
+
def data_klass(*args)
|
9
|
+
ClioClient::ActivityDescription
|
10
|
+
end
|
11
|
+
|
12
|
+
def end_point_url; 'activity_descriptions'; end
|
13
|
+
def plural_resource; 'activity_descriptions'; end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ClioClient
|
2
|
+
module Api
|
3
|
+
class Bill < Base
|
4
|
+
|
5
|
+
include ClioClient::Api::Listable
|
6
|
+
include ClioClient::Api::Findable
|
7
|
+
|
8
|
+
def download(id)
|
9
|
+
session.get("#{end_point_url}/#{id}.pdf", {}, false)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
def data_klass(*args)
|
14
|
+
ClioClient::Bill
|
15
|
+
end
|
16
|
+
|
17
|
+
def end_point_url; 'bills'; end
|
18
|
+
def plural_resource; 'bills'; end
|
19
|
+
def singular_resource; 'bill'; end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ClioClient
|
2
|
+
module Api
|
3
|
+
class Calendar < Base
|
4
|
+
|
5
|
+
include ClioClient::Api::Listable
|
6
|
+
include ClioClient::Api::Findable
|
7
|
+
|
8
|
+
private
|
9
|
+
def data_klass(*args)
|
10
|
+
ClioClient::Calendar
|
11
|
+
end
|
12
|
+
|
13
|
+
def end_point_url; 'calendars'; end
|
14
|
+
def plural_resource; 'calendars'; end
|
15
|
+
def singular_resource; 'calendar'; end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ClioClient
|
2
|
+
module Api
|
3
|
+
class CalendarEntry < Base
|
4
|
+
|
5
|
+
include ClioClient::Api::Crudable
|
6
|
+
include ClioClient::Api::Listable
|
7
|
+
include ClioClient::Api::Findable
|
8
|
+
|
9
|
+
private
|
10
|
+
def data_klass(*args)
|
11
|
+
ClioClient::CalendarEntry
|
12
|
+
end
|
13
|
+
|
14
|
+
def end_point_url; 'calendar_entries'; end
|
15
|
+
def plural_resource; 'calendar_entries'; end
|
16
|
+
def singular_resource; 'calendar_entry'; end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ClioClient
|
2
|
+
module Api
|
3
|
+
class Communication < Base
|
4
|
+
|
5
|
+
include ClioClient::Api::Crudable
|
6
|
+
include ClioClient::Api::Listable
|
7
|
+
include ClioClient::Api::Findable
|
8
|
+
|
9
|
+
private
|
10
|
+
def data_klass(params)
|
11
|
+
if params['type'] == 'PhoneCommunication'
|
12
|
+
ClioClient::PhoneCommunication
|
13
|
+
elsif params['type'] == 'EmailCommunication'
|
14
|
+
ClioClient::EmailCommunication
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def end_point_url; 'communications'; end
|
19
|
+
def plural_resource; 'communications'; end
|
20
|
+
def singular_resource; 'communication'; end
|
21
|
+
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ClioClient
|
2
|
+
module Api
|
3
|
+
class Contact < Base
|
4
|
+
|
5
|
+
include ClioClient::Api::Listable
|
6
|
+
include ClioClient::Api::Findable
|
7
|
+
include ClioClient::Api::Crudable
|
8
|
+
|
9
|
+
private
|
10
|
+
def data_klass(attributes)
|
11
|
+
accepted_types = %w(Person Company)
|
12
|
+
if accepted_types.include? attributes["type"]
|
13
|
+
ClioClient.const_get attributes["type"].intern
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def end_point_url; 'contacts'; end
|
18
|
+
def plural_resource; 'contacts'; end
|
19
|
+
def singular_resource; 'contact'; end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ClioClient
|
2
|
+
module Api
|
3
|
+
module Crudable
|
4
|
+
|
5
|
+
def new(params = {})
|
6
|
+
data_item(params)
|
7
|
+
end
|
8
|
+
|
9
|
+
def create(params = {})
|
10
|
+
response = session.post(end_point_url, {singular_resource => params}.to_json)
|
11
|
+
data_item(response[singular_resource])
|
12
|
+
end
|
13
|
+
|
14
|
+
def update(id, params = {})
|
15
|
+
response = session.put("#{end_point_url}/#{id}", {singular_resource => params}.to_json)
|
16
|
+
data_item(response[singular_resource])
|
17
|
+
end
|
18
|
+
|
19
|
+
def destroy(id)
|
20
|
+
session.delete("#{end_point_url}/#{id}", false)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ClioClient
|
2
|
+
module Api
|
3
|
+
class CustomField < Base
|
4
|
+
|
5
|
+
include ClioClient::Api::Listable
|
6
|
+
include ClioClient::Api::Findable
|
7
|
+
|
8
|
+
private
|
9
|
+
def data_klass(*args)
|
10
|
+
ClioClient::CustomField
|
11
|
+
end
|
12
|
+
|
13
|
+
def end_point_url; 'custom_fields'; end
|
14
|
+
def plural_resource; 'custom_fields'; end
|
15
|
+
def singular_resource; 'custom_field'; end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ClioClient
|
2
|
+
module Api
|
3
|
+
class CustomFieldSet < Base
|
4
|
+
|
5
|
+
include ClioClient::Api::Listable
|
6
|
+
include ClioClient::Api::Findable
|
7
|
+
|
8
|
+
private
|
9
|
+
def data_klass(*args)
|
10
|
+
ClioClient::CustomFieldSet
|
11
|
+
end
|
12
|
+
|
13
|
+
def end_point_url; 'custom_field_sets'; end
|
14
|
+
def plural_resource; 'custom_field_sets'; end
|
15
|
+
def singular_resource; 'custom_field_set'; end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ClioClient
|
2
|
+
module Api
|
3
|
+
class Document < Base
|
4
|
+
|
5
|
+
include ClioClient::Api::Listable
|
6
|
+
include ClioClient::Api::Findable
|
7
|
+
include ClioClient::Api::Crudable
|
8
|
+
|
9
|
+
private
|
10
|
+
def data_klass(*args)
|
11
|
+
ClioClient::Document
|
12
|
+
end
|
13
|
+
|
14
|
+
def end_point_url; 'documents'; end
|
15
|
+
def plural_resource; 'documents'; end
|
16
|
+
def singular_resource; 'document'; end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module ClioClient
|
2
|
+
module Api
|
3
|
+
class DocumentVersion < Base
|
4
|
+
|
5
|
+
attr_accessor :document_id
|
6
|
+
|
7
|
+
include ClioClient::Api::Crudable
|
8
|
+
|
9
|
+
def download(id)
|
10
|
+
session.get("#{end_point_url}/#{id}/download")
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def data_item(params)
|
15
|
+
params["document_id"] = document_id
|
16
|
+
super(params)
|
17
|
+
end
|
18
|
+
|
19
|
+
def data_klass(*args)
|
20
|
+
ClioClient::DocumentVersion
|
21
|
+
end
|
22
|
+
|
23
|
+
def end_point_url; "documents/#{document_id}/document_versions"; end
|
24
|
+
def plural_resource; 'document_versions'; end
|
25
|
+
def singular_resource; 'document_version'; end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ClioClient
|
2
|
+
module Api
|
3
|
+
class Group < 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::Group
|
14
|
+
end
|
15
|
+
|
16
|
+
def end_point_url; 'groups'; end
|
17
|
+
def plural_resource; 'groups'; end
|
18
|
+
def singular_resource; 'group'; end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module ClioClient
|
2
|
+
module Api
|
3
|
+
|
4
|
+
module Listable
|
5
|
+
|
6
|
+
def first(params = {})
|
7
|
+
params[:limit] = 1
|
8
|
+
list(params).first
|
9
|
+
end
|
10
|
+
|
11
|
+
def list(params = {})
|
12
|
+
response = session.get(end_point_url, params)
|
13
|
+
@pagination_details = {last_query: params, records: 0, next_offset: response["next_offset"],
|
14
|
+
total_records: response["total_records"]
|
15
|
+
}
|
16
|
+
@pagination_details[:records] += response["records"] || 0
|
17
|
+
response[plural_resource].collect{ |r| data_item(r) }
|
18
|
+
end
|
19
|
+
|
20
|
+
def next_page
|
21
|
+
if more_pages?
|
22
|
+
params = @pagination_details[:last_query].merge(:offset => @pagination_details[:next_offset])
|
23
|
+
response = session.get(end_point_url, params)
|
24
|
+
@pagination_details[:next_offset] = response["next_offset"]
|
25
|
+
@pagination_details[:records] += response["records"] || 0
|
26
|
+
response[plural_resource].collect{ |r| data_item(r) }
|
27
|
+
else
|
28
|
+
@pagination_details = nil
|
29
|
+
[]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
def more_pages?
|
35
|
+
if @pagination_details
|
36
|
+
@pagination_details[:records] < @pagination_details[:total_records]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ClioClient
|
2
|
+
module Api
|
3
|
+
class Matter < 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::Matter
|
14
|
+
end
|
15
|
+
|
16
|
+
def end_point_url; 'matters'; end
|
17
|
+
def plural_resource; 'matters'; end
|
18
|
+
def singular_resource; 'matter'; end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ClioClient
|
2
|
+
module Api
|
3
|
+
class Note < 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::Note
|
14
|
+
end
|
15
|
+
|
16
|
+
def end_point_url; 'notes'; end
|
17
|
+
def plural_resource; 'notes'; end
|
18
|
+
def singular_resource; 'note'; end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|