conversocial 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c43003f6dc1bf8accf333960ecf3b2007067ff1
4
- data.tar.gz: 84a988b6866afacbac1f41f48c74d986b6bb4cb3
3
+ metadata.gz: 39314cece44480bb907b43d273ebac7380338506
4
+ data.tar.gz: e09b7ce8e03411f766bae1c63987517d4dca844a
5
5
  SHA512:
6
- metadata.gz: 9c108a618244ce1790d069d3875b560662c260eff7078c1c9f4e15495cef27efdd50e18ddb5e42dff38ff1ba3b2850fefecd5ab13f640e71487611d50ce742da
7
- data.tar.gz: 1fa44ea6c3e921cab7b6a46422c49126904da39f94822a78b79169d8b5c2b1503e539ae14f23dfaccbf5cf1412d05c44592063b297eec6ae7c0892f349853dc3
6
+ metadata.gz: 9430b25701982c8bea259beac69fdcd50b38373269cbef6bab93c24a34009d4ff03f1476909c49e571f076041c1850351f3d57dded34e1844ff0890cc78cecbb
7
+ data.tar.gz: e441b23bb382487ffd1cb2d26c184ed455baaba1e9e373e25ec9b66d329da10bdc55c7bf2d76fd2b21539e2a6d1d5f5b96c4dbae4cec0a183db449c324d4f64d
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Conversocial
2
2
 
3
- TODO: Write a gem description
3
+ Ruby gem that wraps the conversocial api in an ORM pattern
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,42 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
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.
22
+
23
+ Initialize the client with your key and secret
24
+
25
+ client = Conversocial::Client.new :key => '...', :secret => '...'
26
+
27
+ And then fetch some data
28
+
29
+ client.conversations.limit(3).fetch #note that limit is only supported on conversations
30
+ client.conversations.where( :status => 'unread' ).fetch
31
+ client.tags.fetch
32
+ client.users.fetch
33
+ client.accounts.fetch
34
+ client.channels.fetch
35
+ client.reports.fetch
36
+
37
+ To find a resource by id
38
+
39
+ client.accounts.find 13954
40
+ client.tags.find 98999
41
+
42
+ To paginate through all of a certain resource do
43
+
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
+
47
+ To get all the conversations for today
48
+
49
+ client.conversations.order(:oldest_sort_date).greater_than_or_equal_to(:oldest_sort_date, Date.today ).limit(50).each_page{ |conversations| ... }
50
+
51
+
52
+
53
+ Items not yet supported, but that will be in a soon future version
54
+
55
+ -saving of reports
56
+ -the keyvalue resource
22
57
 
23
58
  ## Contributing
24
59
 
data/conversocial.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["mishaAconway@gmail.com"]
11
11
  spec.summary = %q{Ruby gem that wraps the conversocial api in an ORM pattern}
12
12
  spec.description = %q{Ruby gem that wraps the conversocial api in an ORM pattern}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/MishaConway/ruby-conversocial"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -50,6 +50,12 @@ module Conversocial
50
50
  end
51
51
 
52
52
  def where options
53
+ options = options.map do |k,v|
54
+ v = v.utc.strftime '%Y-%m-%dT%H:%M:%S' if v.kind_of? Time
55
+ v = v.to_s if v.kind_of? Date
56
+ [k,v]
57
+ end.to_h
58
+
53
59
  @query_params.merge! options
54
60
  self
55
61
  end
@@ -74,10 +80,7 @@ module Conversocial
74
80
  def size
75
81
  fetch.size
76
82
  end
77
-
78
- def count
79
- size
80
- end
83
+ alias :count :size
81
84
 
82
85
  def last
83
86
  fetch.last
@@ -88,11 +91,40 @@ module Conversocial
88
91
  (fetch_ex add_query_params("", default_fetch_query_params.merge(@query_params)))[:items]
89
92
  end
90
93
 
91
- protected
92
94
 
95
+ def sort field
96
+ field = field.join ',' if field.kind_of? Array
97
+ where :sort => field
98
+ end
99
+ alias :sort_by :sort
100
+ alias :order :sort
101
+ alias :order_by :sort
102
+
103
+ def greater_than field, value
104
+ comparison_filter field, "gt", value
105
+ end
106
+
107
+ def greater_than_or_equal_to field, value
108
+ comparison_filter field, "gte", value
109
+ end
110
+
111
+ def lesser_than field, value
112
+ comparison_filter field, "lt", value
113
+ end
114
+
115
+ def less_than_or_equal_to field, value
116
+ comparison_filter field, "lte", value
117
+ end
93
118
 
119
+ def to_fetch_url
120
+ absolute_path add_query_params("", default_fetch_query_params.merge(@query_params))
121
+ end
94
122
 
123
+ protected
95
124
 
125
+ def comparison_filter field, comparison_operator_modifier, value
126
+ where "#{field}_#{comparison_operator_modifier}".to_sym => value
127
+ end
96
128
 
97
129
  def fetch_ex url
98
130
  json = get_json url
@@ -148,7 +180,7 @@ module Conversocial
148
180
  else
149
181
  if 404 == response.code.to_i
150
182
  if json['message'] == "No such #{resource_name}"
151
- # puts "returning nil here"
183
+ #puts "returning nil here"
152
184
  return nil
153
185
  end
154
186
  end
@@ -1,3 +1,3 @@
1
1
  module Conversocial
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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.2
4
+ version: 0.0.3
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-28 00:00:00.000000000 Z
11
+ date: 2014-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -76,7 +76,7 @@ files:
76
76
  - lib/conversocial/resources/query_engines/tag.rb
77
77
  - lib/conversocial/resources/query_engines/user.rb
78
78
  - lib/conversocial/version.rb
79
- homepage: ''
79
+ homepage: https://github.com/MishaConway/ruby-conversocial
80
80
  licenses:
81
81
  - MIT
82
82
  metadata: {}