conversocial 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +97 -21
- data/lib/conversocial/resources/query_engines/base.rb +4 -0
- data/lib/conversocial/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef8feb5467b16254c542a01b58fd1001df721499
|
4
|
+
data.tar.gz: a1a4267eeb246cb6a1d6218173c1832fcbda5fe5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1f31b5dc24413551180556a05c390cc883463247d235d43ff81ba500e8504cbb266ff303bbddf798053a285090e295860426d62799d21cadf5728e5d017ebf4
|
7
|
+
data.tar.gz: 1530913cc3cbbea2d7e72aa190aed25f04df0792ec6ff833b1a662b0d1ce030386073fb20c55cad4606613ae737c5595a673a04c58a443388ee51aa2fe4775bb
|
data/README.md
CHANGED
@@ -16,44 +16,120 @@ Or install it yourself as:
|
|
16
16
|
|
17
17
|
$ gem install conversocial
|
18
18
|
|
19
|
-
##
|
20
|
-
|
21
|
-
Disclaimer: I am still working on in depth documentation for this gem. In the meantime, I tried to provide some quick example snippets here.
|
19
|
+
## Initialize
|
22
20
|
|
23
21
|
Initialize the client with your key and secret
|
24
22
|
|
25
23
|
client = Conversocial::Client.new :key => '...', :secret => '...'
|
26
24
|
|
27
|
-
|
25
|
+
## Resources
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
client.
|
32
|
-
client.
|
33
|
-
client.
|
34
|
-
client.
|
35
|
-
client.reports
|
27
|
+
Currently, this gem wraps most of the resources exposed by the Conversocial API. You can access these resources via the following query engines on the client object.
|
28
|
+
|
29
|
+
client.accounts
|
30
|
+
client.authors
|
31
|
+
client.channels
|
32
|
+
client.conversations
|
33
|
+
client.reports
|
34
|
+
client.tags
|
35
|
+
client.users
|
36
36
|
|
37
|
-
|
37
|
+
Each of these returns a QueryEngine object for that respective resource with a variety of fetch/find/filter methods that can be chained together to programmatically build richer queries. When a query is executed, it will return a model or an array of models. (See section below for more information on models)
|
38
38
|
|
39
|
+
|
40
|
+
## Finding Items
|
41
|
+
All of the query engines have a find method which takes an id. Some examples below:
|
42
|
+
|
39
43
|
client.accounts.find 13954
|
40
|
-
|
44
|
+
=> #<Conversocial::Resources::Models::Account(url: https://api.conversocial.com/v1.1/accounts/13954, reports: https://api.conversocial.com/v1.1/reports?account=13954, id: 13954, channels: ["#<Channel(id: 64079)>", "#<Channel(id: 64091)>", "#<Channel(id: 64080)>", "#<Channel(id: 64082)>"], description: My Test Account, package: Enterprise, created_date: 2013-09-24 17:16:06 -0700, name: My Test Account)>
|
41
45
|
|
42
|
-
|
46
|
+
client.tags.find 25494
|
47
|
+
=> #<Conversocial::Resources::Models::Tag(id: 25494, name: Test Tag, url: https://api.conversocial.com/v1.1/tags/25494, is_active: true)>
|
43
48
|
|
44
|
-
client.tags.each_page{ |tags| .... }
|
45
|
-
client.conversations( :status => 'unread' ).each_page{ |conversations| puts "conversation ids on this page are #{conversations.map(&:id).inspect}" }
|
46
49
|
|
47
|
-
To get all the conversations for today
|
48
50
|
|
49
|
-
|
51
|
+
## Fetching Data
|
52
|
+
With the exception of authors, all query engines support a fetch method that can be used to return multiple items
|
53
|
+
|
54
|
+
client.tags.fetch
|
55
|
+
=> [#<Conversocial::Resources::Models::Tag(id: 25494, name: Tag1, url: https://api.conversocial.com/v1.1/tags/25494, is_active: true)>, #<Conversocial::Resources::Models::Tag(id: 25495, name: Tag2, url: https://api.conversocial.com/v1.1/tags/25495, is_active: true)>, #<Conversocial::Resources::Models::Tag(id: 25496, name: Tag3, url: https://api.conversocial.com/v1.1/tags/25496, is_active: true)>, #<Conversocial::Resources::Models::Tag(id: 25497, name: Tag4, url: https://api.conversocial.com/v1.1/tags/25497, is_active: true)>, #<Conversocial::Resources::Models::Tag(id: 25498, name: Tag5 url: https://api.conversocial.com/v1.1/tags/25498, is_active: true)>, #<Conversocial::Resources::Models::Tag(id: 25499, name: Conversational, url: https://api.conversocial.com/v1.1/tags/25499, is_active: true)>, #<Conversocial::Resources::Models::Tag(id: 25500, name: Tag6, url: https://api.conversocial.com/v1.1/tags/25500, is_active: true)>, #<Conversocial::Resources::Models::Tag(id: 25501, name: Tag7, url: https://api.conversocial.com/v1.1/tags/25501, is_active: true)>, #<Conversocial::Resources::Models::Tag(id: 25502, name: Tag8, url: https://api.conversocial.com/v1.1/tags/25502, is_active: true)>, #<Conversocial::Resources::Models::Tag(id: 25877, name: Tag9, url: https://api.conversocial.com/v1.1/tags/25877, is_active: true)>]
|
56
|
+
|
57
|
+
## Filtering
|
58
|
+
It is possible to filter your find and fetch queries.
|
59
|
+
|
60
|
+
client.conversations.where( :status => 'unread' ).fetch
|
61
|
+
client.conversations.where( :status => ['unread', 'archived'] ).fetch
|
62
|
+
|
63
|
+
It is possible to chain filters
|
64
|
+
|
65
|
+
client.conversations.where(:status => 'archived').where(:assigned_to => user.id ).fetch
|
66
|
+
|
67
|
+
## Comparison Filters
|
68
|
+
|
69
|
+
#get all conversations where oldest sort date is greater than or equal to today
|
70
|
+
client.conversations.greater_than_or_equal_to(:oldest_sort_date, Date.today ).fetch
|
71
|
+
|
72
|
+
#get all conversations where oldest sort date is greater than today
|
73
|
+
client.conversations.greater_than(:oldest_sort_date, Date.today ).fetch
|
74
|
+
|
75
|
+
#get all conversations where oldest sort date is lesser than or equal to today
|
76
|
+
client.conversations.lesser_than_or_equal_to(:oldest_sort_date, Date.today ).fetch
|
77
|
+
|
78
|
+
#get all conversations where oldest sort date is lesser than today
|
79
|
+
client.conversations.lesser_than(:oldest_sort_date, Date.today ).fetch
|
80
|
+
|
81
|
+
## Sorting
|
82
|
+
It is possible to sort your queries
|
50
83
|
|
84
|
+
client.conversations.sort(:oldest_sort_date).fetch
|
51
85
|
|
86
|
+
## Limiting
|
87
|
+
The only resources that can be limited are conversations.
|
52
88
|
|
89
|
+
client.conversations.limit(4).fetch #only return up to four conversations
|
90
|
+
|
91
|
+
## Selecting
|
92
|
+
By default, all fields are selected when you query for resources. However, it is possible to select only a few fields and reduce your api usage.
|
93
|
+
|
94
|
+
conversations.select( 'id', 'status' ).fetch.first
|
95
|
+
=> #<Conversocial::Resources::Models::Conversation(id: 5399e4ff0e4b3d76a56e5533, url: not_yet_loaded, status: archived, is_priority: not_yet_loaded, contains_private: not_yet_loaded, tags: not_yet_loaded, author: not_yet_loaded, channels: not_yet_loaded, assigned_to: not_yet_loaded, content_ids: not_yet_loaded, handling_times: not_yet_loaded)>
|
96
|
+
|
97
|
+
In the example above, you can see that only the id and status are returned. If for some reason, you decide that you need every field you can call refresh on the returned model. You may be wondering what happens if you attempt to invoke an unloaded field. In this case, the model will automatically refresh itself.
|
98
|
+
|
99
|
+
tag = client.tags.where(:fields => 'id').first
|
100
|
+
=> #<Conversocial::Resources::Models::Tag(id: 25494, name: not_yet_loaded, url: https://api.conversocial.com/v1.1/tags/25494, is_active: not_yet_loaded)>
|
101
|
+
tag.refresh
|
102
|
+
=> #<Conversocial::Resources::Models::Tag(id: 25494, name: Test Tag, url: https://api.conversocial.com/v1.1/tags/25494, is_active: true)>
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
## Pagination
|
108
|
+
Using the pagination api is the best way to enumerate through an entire dataset.
|
109
|
+
|
110
|
+
client.tags.each_page do |tags|
|
111
|
+
tags.each do |tag|
|
112
|
+
puts "processing #{tag.name}"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
To get all the conversations for today
|
117
|
+
|
118
|
+
client.conversations.greater_than_or_equal_to(:oldest_sort_date, Date.today ).limit(50).each_page do | |conversations|
|
119
|
+
conversations.each do |conversation|
|
120
|
+
puts "processing conversation #{conversation.id}"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
|
125
|
+
## Future Developments
|
53
126
|
Items not yet supported, but that will be in a soon future version
|
54
127
|
|
55
|
-
|
56
|
-
|
128
|
+
-saving of reports
|
129
|
+
|
130
|
+
-the keyvalue resource
|
131
|
+
|
132
|
+
-more documentation
|
57
133
|
|
58
134
|
## Contributing
|
59
135
|
|
@@ -61,4 +137,4 @@ Items not yet supported, but that will be in a soon future version
|
|
61
137
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
62
138
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
63
139
|
4. Push to the branch (`git push origin my-new-feature`)
|
64
|
-
5. Create a new Pull Request
|
140
|
+
5. Create a new Pull Request
|
data/lib/conversocial/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conversocial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Misha Conway
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|