turba_kit 0.0.8 → 1.1.0

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.
Files changed (191) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -0
  3. data/Gemfile +0 -7
  4. data/lib/turba_kit.rb +117 -18
  5. data/lib/turba_kit/availability.rb +7 -0
  6. data/lib/turba_kit/call_to_action.rb +25 -0
  7. data/lib/turba_kit/checkins.rb +30 -0
  8. data/lib/turba_kit/content.rb +25 -0
  9. data/lib/turba_kit/countries.rb +11 -0
  10. data/lib/turba_kit/crowd_table.rb +37 -0
  11. data/lib/turba_kit/error.rb +15 -169
  12. data/lib/turba_kit/link.rb +25 -0
  13. data/lib/turba_kit/misc.rb +25 -0
  14. data/lib/turba_kit/notification.rb +25 -0
  15. data/lib/turba_kit/phonenumber.rb +25 -0
  16. data/lib/turba_kit/place.rb +25 -0
  17. data/lib/turba_kit/services.rb +39 -0
  18. data/lib/turba_kit/tip.rb +25 -0
  19. data/lib/turba_kit/units.rb +36 -0
  20. data/lib/turba_kit/version.rb +1 -1
  21. data/spec/cassettes/availability.json +1 -0
  22. data/spec/cassettes/checkins.json +1 -0
  23. data/spec/cassettes/countries.json +1 -0
  24. data/spec/cassettes/country_fr_.json +1 -0
  25. data/spec/cassettes/create_checkins.json +1 -0
  26. data/spec/cassettes/create_service_content.json +1 -0
  27. data/spec/cassettes/create_service_link.json +1 -0
  28. data/spec/cassettes/create_service_notification.json +1 -0
  29. data/spec/cassettes/create_service_phonenumber.json +1 -0
  30. data/spec/cassettes/create_service_place.json +1 -0
  31. data/spec/cassettes/create_service_tip.json +1 -0
  32. data/spec/cassettes/search_service.json +1 -0
  33. data/spec/cassettes/service.json +1 -0
  34. data/spec/cassettes/service_crowd_table.json +1 -0
  35. data/spec/cassettes/update_service_content.json +1 -0
  36. data/spec/cassettes/update_service_crowd_table.json +1 -0
  37. data/spec/cassettes/update_service_link.json +1 -0
  38. data/spec/cassettes/update_service_phonenumber.json +1 -0
  39. data/spec/cassettes/update_service_place.json +1 -0
  40. data/spec/cassettes/update_service_tip.json +1 -0
  41. data/spec/lib/availability_spec.rb +15 -0
  42. data/spec/lib/checkins_spec.rb +22 -0
  43. data/spec/lib/content_spec.rb +31 -0
  44. data/spec/lib/countries_spec.rb +12 -14
  45. data/spec/lib/crowd_table_spec.rb +24 -0
  46. data/spec/lib/link_spec.rb +30 -0
  47. data/spec/lib/notification_spec.rb +17 -0
  48. data/spec/lib/phonenumber_spec.rb +28 -0
  49. data/spec/lib/place_spec.rb +23 -36
  50. data/spec/lib/services_spec.rb +11 -53
  51. data/spec/lib/tip_spec.rb +30 -0
  52. data/spec/spec_helper.rb +0 -4
  53. data/turba_kit.gemspec +5 -2
  54. metadata +115 -269
  55. data/lib/turba_kit/arguments.rb +0 -14
  56. data/lib/turba_kit/authentication.rb +0 -10
  57. data/lib/turba_kit/client.rb +0 -168
  58. data/lib/turba_kit/client/categories.rb +0 -41
  59. data/lib/turba_kit/client/checkins.rb +0 -14
  60. data/lib/turba_kit/client/comments.rb +0 -9
  61. data/lib/turba_kit/client/contents.rb +0 -26
  62. data/lib/turba_kit/client/countries.rb +0 -14
  63. data/lib/turba_kit/client/crowd_table.rb +0 -25
  64. data/lib/turba_kit/client/links.rb +0 -26
  65. data/lib/turba_kit/client/migrations.rb +0 -15
  66. data/lib/turba_kit/client/notifications.rb +0 -26
  67. data/lib/turba_kit/client/organismes.rb +0 -41
  68. data/lib/turba_kit/client/phonenumbers.rb +0 -26
  69. data/lib/turba_kit/client/places.rb +0 -26
  70. data/lib/turba_kit/client/search.rb +0 -9
  71. data/lib/turba_kit/client/services.rb +0 -41
  72. data/lib/turba_kit/client/tips.rb +0 -26
  73. data/lib/turba_kit/configurable.rb +0 -74
  74. data/lib/turba_kit/default.rb +0 -102
  75. data/lib/turba_kit/response/raise_error.rb +0 -20
  76. data/spec/cassettes/TurbaKit_Client_Categories/_categories/handles_the_country_code_option.json +0 -1
  77. data/spec/cassettes/TurbaKit_Client_Categories/_category/returns_a_category.json +0 -1
  78. data/spec/cassettes/TurbaKit_Client_Categories/_create_category/creates_a_category.json +0 -1
  79. data/spec/cassettes/TurbaKit_Client_Categories/_delete_category/deletes_a_category_and_returns_true.json +0 -1
  80. data/spec/cassettes/TurbaKit_Client_Categories/_delete_category/returns_false_if_category_doesn_t_exist.json +0 -1
  81. data/spec/cassettes/TurbaKit_Client_Categories/_update_category/updates_a_category.json +0 -1
  82. data/spec/cassettes/TurbaKit_Client_Contents/_create_content/creates_a_content.json +0 -1
  83. data/spec/cassettes/TurbaKit_Client_Contents/_delete_content/deletes_a_content.json +0 -1
  84. data/spec/cassettes/TurbaKit_Client_Contents/_service_content/returns_a_content.json +0 -1
  85. data/spec/cassettes/TurbaKit_Client_Contents/_service_contents/lists_contents.json +0 -1
  86. data/spec/cassettes/TurbaKit_Client_Contents/_update_content/updates_a_content.json +0 -1
  87. data/spec/cassettes/TurbaKit_Client_Countries/_countries/returns_all_countries.json +0 -1
  88. data/spec/cassettes/TurbaKit_Client_Countries/_country/returns_a_country.json +0 -1
  89. data/spec/cassettes/TurbaKit_Client_Crowds/_create_crowd/creates_a_crowd.json +0 -1
  90. data/spec/cassettes/TurbaKit_Client_Crowds/_delete_crowd/deletes_a_crowd.json +0 -1
  91. data/spec/cassettes/TurbaKit_Client_Crowds/_service_crowd/returns_a_crowd.json +0 -1
  92. data/spec/cassettes/TurbaKit_Client_Crowds/_service_crowds/lists_crowds.json +0 -1
  93. data/spec/cassettes/TurbaKit_Client_Crowds/_update_crowd/updates_a_crowd.json +0 -1
  94. data/spec/cassettes/TurbaKit_Client_Links/_create_link/creates_a_link.json +0 -1
  95. data/spec/cassettes/TurbaKit_Client_Links/_delete_link/deletes_a_link.json +0 -1
  96. data/spec/cassettes/TurbaKit_Client_Links/_service_link/returns_a_link.json +0 -1
  97. data/spec/cassettes/TurbaKit_Client_Links/_service_links/lists_links.json +0 -1
  98. data/spec/cassettes/TurbaKit_Client_Links/_update_link/updates_a_link.json +0 -1
  99. data/spec/cassettes/TurbaKit_Client_Notifications/_create_notification/creates_a_notification.json +0 -1
  100. data/spec/cassettes/TurbaKit_Client_Notifications/_delete_notification/deletes_a_notification.json +0 -1
  101. data/spec/cassettes/TurbaKit_Client_Notifications/_service_notification/returns_a_notification.json +0 -1
  102. data/spec/cassettes/TurbaKit_Client_Notifications/_service_notifications/lists_notifications.json +0 -1
  103. data/spec/cassettes/TurbaKit_Client_Notifications/_update_notification/updates_a_notification.json +0 -1
  104. data/spec/cassettes/TurbaKit_Client_Organismes/_create_organisme/creates_an_organisme.json +0 -1
  105. data/spec/cassettes/TurbaKit_Client_Organismes/_delete_organisme/deletes_a_organisme_and_returns_true.json +0 -1
  106. data/spec/cassettes/TurbaKit_Client_Organismes/_delete_organisme/returns_false_if_organisme_doesn_t_exist.json +0 -1
  107. data/spec/cassettes/TurbaKit_Client_Organismes/_organisme/returns_a_organisme.json +0 -1
  108. data/spec/cassettes/TurbaKit_Client_Organismes/_organismes/handles_the_country_code_option.json +0 -1
  109. data/spec/cassettes/TurbaKit_Client_Organismes/_update_organisme/updates_an_organisme.json +0 -1
  110. data/spec/cassettes/TurbaKit_Client_Phonenumbers/_create_phonenumber/creates_a_phonenumber.json +0 -1
  111. data/spec/cassettes/TurbaKit_Client_Phonenumbers/_delete_phonenumber/deletes_a_phonenumber.json +0 -1
  112. data/spec/cassettes/TurbaKit_Client_Phonenumbers/_service_phonenumber/returns_a_phonenumber.json +0 -1
  113. data/spec/cassettes/TurbaKit_Client_Phonenumbers/_service_phonenumbers/lists_phonenumbers.json +0 -1
  114. data/spec/cassettes/TurbaKit_Client_Phonenumbers/_update_phonenumber/updates_a_phonenumber.json +0 -1
  115. data/spec/cassettes/TurbaKit_Client_Places/_create_place/creates_a_place.json +0 -1
  116. data/spec/cassettes/TurbaKit_Client_Places/_delete_place/deletes_a_place.json +0 -1
  117. data/spec/cassettes/TurbaKit_Client_Places/_service_place/returns_a_place.json +0 -1
  118. data/spec/cassettes/TurbaKit_Client_Places/_service_places/lists_places.json +0 -1
  119. data/spec/cassettes/TurbaKit_Client_Places/_update_place/updates_a_place.json +0 -1
  120. data/spec/cassettes/TurbaKit_Client_Services/_service/returns_a_service.json +0 -1
  121. data/spec/cassettes/TurbaKit_Client_Services/_services/handles_the_country_code_option.json +0 -1
  122. data/spec/cassettes/TurbaKit_Client_Tips/_create_tip/creates_a_tip.json +0 -1
  123. data/spec/cassettes/TurbaKit_Client_Tips/_delete_tip/deletes_a_tip.json +0 -1
  124. data/spec/cassettes/TurbaKit_Client_Tips/_service_tip/returns_a_tip.json +0 -1
  125. data/spec/cassettes/TurbaKit_Client_Tips/_service_tips/lists_tips.json +0 -1
  126. data/spec/cassettes/TurbaKit_Client_Tips/_update_tip/updates_a_tip.json +0 -1
  127. data/spec/cassettes/Turkit_Client_Categories/_categories/handles_the_country_code_option.json +0 -1
  128. data/spec/cassettes/Turkit_Client_Categories/_categories/returns_all_categories.json +0 -1
  129. data/spec/cassettes/Turkit_Client_Categories/_category/returns_a_category.json +0 -1
  130. data/spec/cassettes/Turkit_Client_Categories/_create_category/creates_a_category.json +0 -1
  131. data/spec/cassettes/Turkit_Client_Categories/_delete_category/deletes_a_category_and_returns_true.json +0 -1
  132. data/spec/cassettes/Turkit_Client_Categories/_delete_category/returns_false_if_category_doesn_t_exist.json +0 -1
  133. data/spec/cassettes/Turkit_Client_Categories/_search_category/returns_a_list_of_categories.json +0 -1
  134. data/spec/cassettes/Turkit_Client_Categories/_update_category/updates_a_category.json +0 -1
  135. data/spec/cassettes/Turkit_Client_Contents/_create_content/creates_a_content.json +0 -1
  136. data/spec/cassettes/Turkit_Client_Contents/_delete_content/deletes_a_content.json +0 -1
  137. data/spec/cassettes/Turkit_Client_Contents/_service_content/returns_a_content.json +0 -1
  138. data/spec/cassettes/Turkit_Client_Contents/_service_contents/lists_contents.json +0 -1
  139. data/spec/cassettes/Turkit_Client_Contents/_update_content/updates_a_content.json +0 -1
  140. data/spec/cassettes/Turkit_Client_Countries/_countries/returns_all_countries.json +0 -1
  141. data/spec/cassettes/Turkit_Client_Countries/_country/returns_a_country.json +0 -1
  142. data/spec/cassettes/Turkit_Client_Crowds/_create_crowd/creates_a_crowd.json +0 -1
  143. data/spec/cassettes/Turkit_Client_Crowds/_delete_crowd/deletes_a_crowd.json +0 -1
  144. data/spec/cassettes/Turkit_Client_Crowds/_service_crowd/returns_a_crowd.json +0 -1
  145. data/spec/cassettes/Turkit_Client_Crowds/_service_crowds/lists_crowds.json +0 -1
  146. data/spec/cassettes/Turkit_Client_Crowds/_update_crowd/updates_a_crowd.json +0 -1
  147. data/spec/cassettes/Turkit_Client_Links/_create_link/creates_a_link.json +0 -1
  148. data/spec/cassettes/Turkit_Client_Links/_delete_link/deletes_a_link.json +0 -1
  149. data/spec/cassettes/Turkit_Client_Links/_service_link/returns_a_link.json +0 -1
  150. data/spec/cassettes/Turkit_Client_Links/_service_links/lists_links.json +0 -1
  151. data/spec/cassettes/Turkit_Client_Links/_update_link/updates_a_link.json +0 -1
  152. data/spec/cassettes/Turkit_Client_Notifications/_create_notification/creates_a_notification.json +0 -1
  153. data/spec/cassettes/Turkit_Client_Notifications/_delete_notification/deletes_a_notification.json +0 -1
  154. data/spec/cassettes/Turkit_Client_Notifications/_service_notification/returns_a_notification.json +0 -1
  155. data/spec/cassettes/Turkit_Client_Notifications/_service_notifications/lists_notifications.json +0 -1
  156. data/spec/cassettes/Turkit_Client_Notifications/_update_notification/updates_a_notification.json +0 -1
  157. data/spec/cassettes/Turkit_Client_Organismes/_create_organisme/creates_an_organisme.json +0 -1
  158. data/spec/cassettes/Turkit_Client_Organismes/_delete_organisme/deletes_a_organisme_and_returns_true.json +0 -1
  159. data/spec/cassettes/Turkit_Client_Organismes/_delete_organisme/returns_false_if_organisme_doesn_t_exist.json +0 -1
  160. data/spec/cassettes/Turkit_Client_Organismes/_organisme/returns_a_organisme.json +0 -1
  161. data/spec/cassettes/Turkit_Client_Organismes/_organismes/handles_the_country_code_option.json +0 -1
  162. data/spec/cassettes/Turkit_Client_Organismes/_organismes/returns_all_organismes.json +0 -1
  163. data/spec/cassettes/Turkit_Client_Organismes/_search_organisme/returns_a_list_of_organismes.json +0 -1
  164. data/spec/cassettes/Turkit_Client_Organismes/_update_organisme/updates_an_organisme.json +0 -1
  165. data/spec/cassettes/Turkit_Client_Phonenumbers/_create_phonenumber/creates_a_phonenumber.json +0 -1
  166. data/spec/cassettes/Turkit_Client_Phonenumbers/_delete_phonenumber/deletes_a_phonenumber.json +0 -1
  167. data/spec/cassettes/Turkit_Client_Phonenumbers/_service_phonenumber/returns_a_phonenumber.json +0 -1
  168. data/spec/cassettes/Turkit_Client_Phonenumbers/_service_phonenumbers/lists_phonenumbers.json +0 -1
  169. data/spec/cassettes/Turkit_Client_Phonenumbers/_update_phonenumber/updates_a_phonenumber.json +0 -1
  170. data/spec/cassettes/Turkit_Client_Places/_create_place/creates_a_place.json +0 -1
  171. data/spec/cassettes/Turkit_Client_Places/_delete_place/deletes_a_place.json +0 -1
  172. data/spec/cassettes/Turkit_Client_Places/_service_place/returns_a_place.json +0 -1
  173. data/spec/cassettes/Turkit_Client_Places/_service_places/lists_places.json +0 -1
  174. data/spec/cassettes/Turkit_Client_Places/_update_place/updates_a_place.json +0 -1
  175. data/spec/cassettes/Turkit_Client_Services/_search_service/returns_a_list_of_services.json +0 -1
  176. data/spec/cassettes/Turkit_Client_Services/_service/returns_a_service.json +0 -1
  177. data/spec/cassettes/Turkit_Client_Services/_services/handles_the_country_code_option.json +0 -1
  178. data/spec/cassettes/Turkit_Client_Services/_services/returns_all_services.json +0 -1
  179. data/spec/cassettes/Turkit_Client_Tips/_create_tip/creates_a_tip.json +0 -1
  180. data/spec/cassettes/Turkit_Client_Tips/_delete_tip/deletes_a_tip.json +0 -1
  181. data/spec/cassettes/Turkit_Client_Tips/_service_tip/returns_a_tip.json +0 -1
  182. data/spec/cassettes/Turkit_Client_Tips/_service_tips/lists_tips.json +0 -1
  183. data/spec/cassettes/Turkit_Client_Tips/_update_tip/updates_a_tip.json +0 -1
  184. data/spec/lib/categories_spec.rb +0 -64
  185. data/spec/lib/contents_spec.rb +0 -47
  186. data/spec/lib/crowds_spec.rb +0 -47
  187. data/spec/lib/links_spec.rb +0 -47
  188. data/spec/lib/notifications_spec.rb +0 -47
  189. data/spec/lib/organismes_spec.rb +0 -64
  190. data/spec/lib/phonenumbers_spec.rb +0 -47
  191. data/spec/lib/tips_spec.rb +0 -47
@@ -1,14 +0,0 @@
1
- module TurbaKit
2
-
3
- # Extracts options from method arguments
4
- # @private
5
- class Arguments < Array
6
- attr_reader :options
7
-
8
- def initialize(args)
9
- @options = args.last.is_a?(::Hash) ? args.pop : {}
10
- super(args)
11
- end
12
-
13
- end
14
- end
@@ -1,10 +0,0 @@
1
- module TurbaKit
2
-
3
- # Authentication methods for {TurbaKit::Client}
4
- module Authentication
5
-
6
- def api_key_authenticated?
7
- !!@api_key
8
- end
9
- end
10
- end
@@ -1,168 +0,0 @@
1
- require 'sawyer'
2
- require 'turba_kit/arguments'
3
- require 'turba_kit/authentication'
4
- require 'turba_kit/configurable'
5
- require 'turba_kit/client/categories'
6
- require 'turba_kit/client/organismes'
7
- require 'turba_kit/client/services'
8
- require 'turba_kit/client/countries'
9
- require 'turba_kit/client/phonenumbers'
10
- require 'turba_kit/client/contents'
11
- require 'turba_kit/client/links'
12
- require 'turba_kit/client/tips'
13
- require 'turba_kit/client/places'
14
- require 'turba_kit/client/notifications'
15
- require 'turba_kit/client/crowd_table'
16
- require 'turba_kit/client/comments'
17
- require 'turba_kit/client/checkins'
18
- require 'turba_kit/client/search'
19
- require 'turba_kit/client/migrations'
20
-
21
- module TurbaKit
22
-
23
- # Client for the Turba API
24
- #
25
- # @see http://github.com/turba-webservices/turba_kit
26
- class Client
27
-
28
- include TurbaKit::Authentication
29
- include TurbaKit::Configurable
30
- include TurbaKit::Client::Categories
31
- include TurbaKit::Client::Organismes
32
- include TurbaKit::Client::Services
33
- include TurbaKit::Client::Countries
34
- include TurbaKit::Client::Phonenumbers
35
- include TurbaKit::Client::Contents
36
- include TurbaKit::Client::Links
37
- include TurbaKit::Client::Tips
38
- include TurbaKit::Client::Places
39
- include TurbaKit::Client::Notifications
40
- include TurbaKit::Client::CrowdTable
41
- include TurbaKit::Client::Comments
42
- include TurbaKit::Client::Checkins
43
- include TurbaKit::Client::Search
44
- include TurbaKit::Client::Migrations
45
-
46
- # Header keys that can be passed in options hash to {#get},{#head}
47
- CONVENIENCE_HEADERS = Set.new([:accept, :content_type])
48
-
49
- def initialize(options = {})
50
- TurbaKit::Configurable.keys.each do |key|
51
- instance_variable_set(:"@#{key}", options[key] || TurbaKit.instance_variable_get(:"@#{key}"))
52
- end
53
- end
54
-
55
- # Compares client options to a Hash of requested options
56
- #
57
- # @param opts [Hash] Options to compare with current client options
58
- # @return [Boolean]
59
- def same_options?(opts)
60
- opts.hash == options.hash
61
- end
62
-
63
- # Text representation of the client, masking api key
64
- #
65
- # @return [String]
66
- def inspect
67
- inspected = super
68
-
69
- # Only show last 4 of api key, secret
70
- if @api_key
71
- inspected = inspected.gsub! @api_key, "#{'*'*36}#{@api_key[36..-1]}"
72
- end
73
-
74
- inspected
75
- end
76
-
77
- def get(url, options = {})
78
- request :get, url, parse_query_and_convenience_headers(options)
79
- end
80
-
81
- def post(url, options = {})
82
- request :post, url, options
83
- end
84
-
85
- def put(url, options = {})
86
- request :put, url, options
87
- end
88
-
89
- def delete(url, options = {})
90
- request :delete, url, options
91
- end
92
-
93
- def last_response
94
- @last_response if defined? @last_response
95
- end
96
-
97
- def agent
98
- @agent ||= Sawyer::Agent.new("#{api_endpoint}#{api_version}/", sawyer_options) do |http|
99
- http.headers[:accept] = default_media_type
100
- http.headers[:user_agent] = user_agent
101
- http.headers['X-API-KEY'] = api_key
102
- end
103
- end
104
-
105
- # Fetch the root resource for the API
106
- #
107
- # @return [Sawyer::Resource]
108
- def root
109
- get "/"
110
- end
111
-
112
- private
113
-
114
- def query_string(*args)
115
- return if args.flatten.blank?
116
- query_string = ''
117
- arguments = TurbaKit::Arguments.new(args).flatten[0]
118
- query_string = arguments.map {|k, v| "#{k}=#{v}"}.join('&')
119
- query_string
120
- end
121
-
122
- def boolean_from_response(method, path, options = {})
123
- request(method, path, options)
124
- @last_response.status == 204
125
- rescue TurbaKit::NotFound
126
- false
127
- end
128
-
129
- def sawyer_options
130
- opts = { links_parser: Sawyer::LinkParsers::Simple.new }
131
- conn_opts = @connection_options
132
- conn_opts[:builder] = @middleware if @middleware
133
- conn_opts[:proxy] = @proxy if @proxy
134
- opts[:faraday] = Faraday.new(conn_opts)
135
- # opts[:serializer] = Sawyer::Serializer.message_pack
136
- opts
137
- end
138
-
139
- def parse_query_and_convenience_headers(options)
140
- headers = options.fetch(:headers, {})
141
- CONVENIENCE_HEADERS.each do |h|
142
- if header = options.delete(h)
143
- headers[h] = header
144
- end
145
- end
146
- query = options.delete(:query)
147
- opts = { query: options }
148
- opts[:query].merge!(query) if query && query.is_a?(Hash)
149
- opts[:headers] = headers unless headers.empty?
150
-
151
- opts
152
- end
153
-
154
- def request(method, path, data, options = {})
155
- if data.is_a?(Hash)
156
- options[:query] = data.delete(:query) || {}
157
- options[:headers] = data.delete(:headers) || {}
158
- if accept = data.delete(:accept)
159
- options[:headers][:accept] = accept
160
- end
161
- end
162
-
163
- @last_response = response = agent.call(method, URI::Parser.new.escape(path.to_s), data, options)
164
-
165
- response.data
166
- end
167
- end
168
- end
@@ -1,41 +0,0 @@
1
- module TurbaKit
2
- class Client
3
- module Categories
4
- def category(id_or_uri_id, *args)
5
- get("categories/#{id_or_uri_id}?#{query_string(args)}")[:category]
6
- end
7
-
8
- def categories(*args)
9
- get("categories?#{query_string(args)}")[:categories]
10
- end
11
-
12
- def create_category(params)
13
- params = {category: params}
14
- post("categories", options.merge(params))[:category]
15
- end
16
-
17
- def delete_category(id_or_uri_id)
18
- boolean_from_response :delete, "categories/#{id_or_uri_id}", options
19
- end
20
-
21
- def search_category(query, *args)
22
- get("categories?q=#{query}&#{query_string(args)}")[:categories]
23
- end
24
-
25
- # Update a category
26
- #
27
- # @param id_or_uri_id [String] ID of the category
28
- # @param params [Hash] A customizable set of params.
29
- # @option category_params [String] :title Category title.
30
- # @option category_params [String] :url Category URL.
31
- # @option category_params [String] :country_code Category country code.
32
- # @return [Sawyer::Resource] The updated category
33
- # @see https://github.com/turba-webservices/api-documentation/blob/master/v2/sections/categories.md#update-category
34
- # @example Change the title of Category xxxxxx
35
- # TurbaKit.update_issue("xxxxxx", {title: "A new title"})
36
- def update_category(id_or_uri_id, category_params = {})
37
- put("categories/#{id_or_uri_id}", options.merge({category: category_params}))[:category]
38
- end
39
- end
40
- end
41
- end
@@ -1,14 +0,0 @@
1
- module TurbaKit
2
- class Client
3
- module Checkins
4
- def create_wait_checkin(service_id, wait)
5
- post("services/#{service_id}/checkins?wait=#{wait}")
6
- end
7
-
8
- def recent_checkins(limit = 5, since)
9
- since ||= 10.days.ago
10
- get("checkins?limit=#{limit}&since=#{since}")
11
- end
12
- end
13
- end
14
- end
@@ -1,9 +0,0 @@
1
- module TurbaKit
2
- class Client
3
- module Comments
4
- def comments(page_url, domain, shortname, disqus_api_key)
5
- get("comments?disqus_api_key=#{disqus_api_key}&url=#{page_url}&domain=#{domain}&disqus_shortname=#{shortname}")[:comments]
6
- end
7
- end
8
- end
9
- end
@@ -1,26 +0,0 @@
1
- module TurbaKit
2
- class Client
3
- module Contents
4
- def service_content(service_id, content_id)
5
- get("services/#{service_id}/contents/#{content_id}")[:content]
6
- end
7
-
8
- def service_contents(service_id)
9
- get("services/#{service_id}/contents")[:contents]
10
- end
11
-
12
- def create_content(service_id, params, options = {})
13
- # params = {type: type}
14
- post("services/#{service_id}/contents", {content: options.merge(params)})[:content]
15
- end
16
-
17
- def update_content(service_id, content_id, *args)
18
- put("services/#{service_id}/contents/#{content_id}", {content: options.merge(args[0])})[:content]
19
- end
20
-
21
- def delete_content(service_id, content_id)
22
- boolean_from_response :delete, "services/#{service_id}/contents/#{content_id}", options
23
- end
24
- end
25
- end
26
- end
@@ -1,14 +0,0 @@
1
- module TurbaKit
2
- class Client
3
- module Countries
4
- def country(country_code)
5
- countries = get("countries")[:countries]
6
- countries.select{|k, v| k[:country_code] == country_code}.first
7
- end
8
-
9
- def countries
10
- get("countries")[:countries]
11
- end
12
- end
13
- end
14
- end
@@ -1,25 +0,0 @@
1
- module TurbaKit
2
- class Client
3
- module CrowdTable
4
- def service_crowd_table(service_id)
5
- get("services/#{service_id}/crowd_table")[:crowd_table]
6
- end
7
-
8
- def create_crowd_table(service_id, params, options = {})
9
- post("services/#{service_id}/crowd_table", {crowd_table: options.merge(params)})[:crowd_table]
10
- end
11
-
12
- def update_crowd_table(service_id, crowd_id, *args)
13
- put("services/#{service_id}/crowd_table", {crowd_table: options.merge(args[0])})[:crowd_table]
14
- end
15
-
16
- def delete_crowd_table(service_id, crowd_id)
17
- boolean_from_response :delete, "services/#{service_id}/crowd_table", options
18
- end
19
-
20
- def copy_crowd_table(service_id, services_ids)
21
- boolean_from_response :post, "services/#{service_id}/crowd_table/copy/#{services_ids}", options
22
- end
23
- end
24
- end
25
- end
@@ -1,26 +0,0 @@
1
- module TurbaKit
2
- class Client
3
- module Links
4
- def service_link(service_id, link_id)
5
- get("services/#{service_id}/links/#{link_id}")[:link]
6
- end
7
-
8
- def service_links(service_id)
9
- get("services/#{service_id}/links")[:links]
10
- end
11
-
12
- def create_link(service_id, params, options = {})
13
- # params = {text: text, url: url}
14
- post("services/#{service_id}/links", {link: options.merge(params)})[:link]
15
- end
16
-
17
- def update_link(service_id, link_id, *args)
18
- put("services/#{service_id}/links/#{link_id}", {link: options.merge(args[0])})[:link]
19
- end
20
-
21
- def delete_link(service_id, link_id)
22
- boolean_from_response :delete, "services/#{service_id}/links/#{link_id}", options
23
- end
24
- end
25
- end
26
- end
@@ -1,15 +0,0 @@
1
- module TurbaKit
2
- class Client
3
- module Migrations
4
- def create_service_child(service_id)
5
- params = {origin_id: service_id, migration: 'add_new_child'}
6
- post("migrations", options.merge(params))
7
- end
8
-
9
- def create_migration(params)
10
- p params
11
- post("migrations", params)
12
- end
13
- end
14
- end
15
- end
@@ -1,26 +0,0 @@
1
- module TurbaKit
2
- class Client
3
- module Notifications
4
- def service_notification(service_id, notification_id)
5
- get("services/#{service_id}/notifications/#{notification_id}")[:notification]
6
- end
7
-
8
- def service_notifications(service_id)
9
- get("services/#{service_id}/notifications")[:notifications]
10
- end
11
-
12
- def create_notification(service_id, params, options = {})
13
- # params = {text: text}
14
- post("services/#{service_id}/notifications", {notification: options.merge(params)})[:notification]
15
- end
16
-
17
- def update_notification(service_id, notification_id, *args)
18
- put("services/#{service_id}/notifications/#{notification_id}", {notification: options.merge(args[0])})[:notification]
19
- end
20
-
21
- def delete_notification(service_id, notification_id)
22
- boolean_from_response :delete, "services/#{service_id}/notifications/#{notification_id}", options
23
- end
24
- end
25
- end
26
- end
@@ -1,41 +0,0 @@
1
- module TurbaKit
2
- class Client
3
- module Organismes
4
- def organisme(id_or_uri_id, *args)
5
- get("organismes/#{id_or_uri_id}?#{query_string(args)}")[:organisme]
6
- end
7
-
8
- def organismes(*args)
9
- get("organismes?#{query_string(args)}")[:organismes]
10
- end
11
-
12
- def create_organisme(params)
13
- params = {organisme: params}
14
- post("organismes", options.merge(params))[:organisme]
15
- end
16
-
17
- def delete_organisme(id_or_uri_id)
18
- boolean_from_response :delete, "organismes/#{id_or_uri_id}", options
19
- end
20
-
21
- def search_organisme(query, *args)
22
- get("organismes?q=#{query}&#{query_string(args)}")[:organismes]
23
- end
24
-
25
- # Update an organisme
26
- #
27
- # @param id_or_uri_id [String] ID of the organisme
28
- # @param params [Hash] A customizable set of params.
29
- # @option organisme_params [String] :title Category title.
30
- # @option organisme_params [String] :url Category URL.
31
- # @option organisme_params [String] :country_code Category country code.
32
- # @return [Sawyer::Resource] The updated organisme
33
- # @see https://github.com/turba-webservices/api-documentation/blob/master/v2/sections/organismes.md#update-organisme
34
- # @example Change the title of Category xxxxxx
35
- # TurbaKit.update_issue("xxxxxx", {title: "A new title"})
36
- def update_organisme(id_or_uri_id, organisme_params = {})
37
- put("organismes/#{id_or_uri_id}", options.merge({organisme: organisme_params}))[:organisme]
38
- end
39
- end
40
- end
41
- end