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.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/Gemfile +0 -7
- data/lib/turba_kit.rb +117 -18
- data/lib/turba_kit/availability.rb +7 -0
- data/lib/turba_kit/call_to_action.rb +25 -0
- data/lib/turba_kit/checkins.rb +30 -0
- data/lib/turba_kit/content.rb +25 -0
- data/lib/turba_kit/countries.rb +11 -0
- data/lib/turba_kit/crowd_table.rb +37 -0
- data/lib/turba_kit/error.rb +15 -169
- data/lib/turba_kit/link.rb +25 -0
- data/lib/turba_kit/misc.rb +25 -0
- data/lib/turba_kit/notification.rb +25 -0
- data/lib/turba_kit/phonenumber.rb +25 -0
- data/lib/turba_kit/place.rb +25 -0
- data/lib/turba_kit/services.rb +39 -0
- data/lib/turba_kit/tip.rb +25 -0
- data/lib/turba_kit/units.rb +36 -0
- data/lib/turba_kit/version.rb +1 -1
- data/spec/cassettes/availability.json +1 -0
- data/spec/cassettes/checkins.json +1 -0
- data/spec/cassettes/countries.json +1 -0
- data/spec/cassettes/country_fr_.json +1 -0
- data/spec/cassettes/create_checkins.json +1 -0
- data/spec/cassettes/create_service_content.json +1 -0
- data/spec/cassettes/create_service_link.json +1 -0
- data/spec/cassettes/create_service_notification.json +1 -0
- data/spec/cassettes/create_service_phonenumber.json +1 -0
- data/spec/cassettes/create_service_place.json +1 -0
- data/spec/cassettes/create_service_tip.json +1 -0
- data/spec/cassettes/search_service.json +1 -0
- data/spec/cassettes/service.json +1 -0
- data/spec/cassettes/service_crowd_table.json +1 -0
- data/spec/cassettes/update_service_content.json +1 -0
- data/spec/cassettes/update_service_crowd_table.json +1 -0
- data/spec/cassettes/update_service_link.json +1 -0
- data/spec/cassettes/update_service_phonenumber.json +1 -0
- data/spec/cassettes/update_service_place.json +1 -0
- data/spec/cassettes/update_service_tip.json +1 -0
- data/spec/lib/availability_spec.rb +15 -0
- data/spec/lib/checkins_spec.rb +22 -0
- data/spec/lib/content_spec.rb +31 -0
- data/spec/lib/countries_spec.rb +12 -14
- data/spec/lib/crowd_table_spec.rb +24 -0
- data/spec/lib/link_spec.rb +30 -0
- data/spec/lib/notification_spec.rb +17 -0
- data/spec/lib/phonenumber_spec.rb +28 -0
- data/spec/lib/place_spec.rb +23 -36
- data/spec/lib/services_spec.rb +11 -53
- data/spec/lib/tip_spec.rb +30 -0
- data/spec/spec_helper.rb +0 -4
- data/turba_kit.gemspec +5 -2
- metadata +115 -269
- data/lib/turba_kit/arguments.rb +0 -14
- data/lib/turba_kit/authentication.rb +0 -10
- data/lib/turba_kit/client.rb +0 -168
- data/lib/turba_kit/client/categories.rb +0 -41
- data/lib/turba_kit/client/checkins.rb +0 -14
- data/lib/turba_kit/client/comments.rb +0 -9
- data/lib/turba_kit/client/contents.rb +0 -26
- data/lib/turba_kit/client/countries.rb +0 -14
- data/lib/turba_kit/client/crowd_table.rb +0 -25
- data/lib/turba_kit/client/links.rb +0 -26
- data/lib/turba_kit/client/migrations.rb +0 -15
- data/lib/turba_kit/client/notifications.rb +0 -26
- data/lib/turba_kit/client/organismes.rb +0 -41
- data/lib/turba_kit/client/phonenumbers.rb +0 -26
- data/lib/turba_kit/client/places.rb +0 -26
- data/lib/turba_kit/client/search.rb +0 -9
- data/lib/turba_kit/client/services.rb +0 -41
- data/lib/turba_kit/client/tips.rb +0 -26
- data/lib/turba_kit/configurable.rb +0 -74
- data/lib/turba_kit/default.rb +0 -102
- data/lib/turba_kit/response/raise_error.rb +0 -20
- data/spec/cassettes/TurbaKit_Client_Categories/_categories/handles_the_country_code_option.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Categories/_category/returns_a_category.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Categories/_create_category/creates_a_category.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Categories/_delete_category/deletes_a_category_and_returns_true.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Categories/_delete_category/returns_false_if_category_doesn_t_exist.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Categories/_update_category/updates_a_category.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Contents/_create_content/creates_a_content.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Contents/_delete_content/deletes_a_content.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Contents/_service_content/returns_a_content.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Contents/_service_contents/lists_contents.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Contents/_update_content/updates_a_content.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Countries/_countries/returns_all_countries.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Countries/_country/returns_a_country.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Crowds/_create_crowd/creates_a_crowd.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Crowds/_delete_crowd/deletes_a_crowd.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Crowds/_service_crowd/returns_a_crowd.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Crowds/_service_crowds/lists_crowds.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Crowds/_update_crowd/updates_a_crowd.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Links/_create_link/creates_a_link.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Links/_delete_link/deletes_a_link.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Links/_service_link/returns_a_link.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Links/_service_links/lists_links.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Links/_update_link/updates_a_link.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Notifications/_create_notification/creates_a_notification.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Notifications/_delete_notification/deletes_a_notification.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Notifications/_service_notification/returns_a_notification.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Notifications/_service_notifications/lists_notifications.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Notifications/_update_notification/updates_a_notification.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Organismes/_create_organisme/creates_an_organisme.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Organismes/_delete_organisme/deletes_a_organisme_and_returns_true.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Organismes/_delete_organisme/returns_false_if_organisme_doesn_t_exist.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Organismes/_organisme/returns_a_organisme.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Organismes/_organismes/handles_the_country_code_option.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Organismes/_update_organisme/updates_an_organisme.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Phonenumbers/_create_phonenumber/creates_a_phonenumber.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Phonenumbers/_delete_phonenumber/deletes_a_phonenumber.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Phonenumbers/_service_phonenumber/returns_a_phonenumber.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Phonenumbers/_service_phonenumbers/lists_phonenumbers.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Phonenumbers/_update_phonenumber/updates_a_phonenumber.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Places/_create_place/creates_a_place.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Places/_delete_place/deletes_a_place.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Places/_service_place/returns_a_place.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Places/_service_places/lists_places.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Places/_update_place/updates_a_place.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Services/_service/returns_a_service.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Services/_services/handles_the_country_code_option.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Tips/_create_tip/creates_a_tip.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Tips/_delete_tip/deletes_a_tip.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Tips/_service_tip/returns_a_tip.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Tips/_service_tips/lists_tips.json +0 -1
- data/spec/cassettes/TurbaKit_Client_Tips/_update_tip/updates_a_tip.json +0 -1
- data/spec/cassettes/Turkit_Client_Categories/_categories/handles_the_country_code_option.json +0 -1
- data/spec/cassettes/Turkit_Client_Categories/_categories/returns_all_categories.json +0 -1
- data/spec/cassettes/Turkit_Client_Categories/_category/returns_a_category.json +0 -1
- data/spec/cassettes/Turkit_Client_Categories/_create_category/creates_a_category.json +0 -1
- data/spec/cassettes/Turkit_Client_Categories/_delete_category/deletes_a_category_and_returns_true.json +0 -1
- data/spec/cassettes/Turkit_Client_Categories/_delete_category/returns_false_if_category_doesn_t_exist.json +0 -1
- data/spec/cassettes/Turkit_Client_Categories/_search_category/returns_a_list_of_categories.json +0 -1
- data/spec/cassettes/Turkit_Client_Categories/_update_category/updates_a_category.json +0 -1
- data/spec/cassettes/Turkit_Client_Contents/_create_content/creates_a_content.json +0 -1
- data/spec/cassettes/Turkit_Client_Contents/_delete_content/deletes_a_content.json +0 -1
- data/spec/cassettes/Turkit_Client_Contents/_service_content/returns_a_content.json +0 -1
- data/spec/cassettes/Turkit_Client_Contents/_service_contents/lists_contents.json +0 -1
- data/spec/cassettes/Turkit_Client_Contents/_update_content/updates_a_content.json +0 -1
- data/spec/cassettes/Turkit_Client_Countries/_countries/returns_all_countries.json +0 -1
- data/spec/cassettes/Turkit_Client_Countries/_country/returns_a_country.json +0 -1
- data/spec/cassettes/Turkit_Client_Crowds/_create_crowd/creates_a_crowd.json +0 -1
- data/spec/cassettes/Turkit_Client_Crowds/_delete_crowd/deletes_a_crowd.json +0 -1
- data/spec/cassettes/Turkit_Client_Crowds/_service_crowd/returns_a_crowd.json +0 -1
- data/spec/cassettes/Turkit_Client_Crowds/_service_crowds/lists_crowds.json +0 -1
- data/spec/cassettes/Turkit_Client_Crowds/_update_crowd/updates_a_crowd.json +0 -1
- data/spec/cassettes/Turkit_Client_Links/_create_link/creates_a_link.json +0 -1
- data/spec/cassettes/Turkit_Client_Links/_delete_link/deletes_a_link.json +0 -1
- data/spec/cassettes/Turkit_Client_Links/_service_link/returns_a_link.json +0 -1
- data/spec/cassettes/Turkit_Client_Links/_service_links/lists_links.json +0 -1
- data/spec/cassettes/Turkit_Client_Links/_update_link/updates_a_link.json +0 -1
- data/spec/cassettes/Turkit_Client_Notifications/_create_notification/creates_a_notification.json +0 -1
- data/spec/cassettes/Turkit_Client_Notifications/_delete_notification/deletes_a_notification.json +0 -1
- data/spec/cassettes/Turkit_Client_Notifications/_service_notification/returns_a_notification.json +0 -1
- data/spec/cassettes/Turkit_Client_Notifications/_service_notifications/lists_notifications.json +0 -1
- data/spec/cassettes/Turkit_Client_Notifications/_update_notification/updates_a_notification.json +0 -1
- data/spec/cassettes/Turkit_Client_Organismes/_create_organisme/creates_an_organisme.json +0 -1
- data/spec/cassettes/Turkit_Client_Organismes/_delete_organisme/deletes_a_organisme_and_returns_true.json +0 -1
- data/spec/cassettes/Turkit_Client_Organismes/_delete_organisme/returns_false_if_organisme_doesn_t_exist.json +0 -1
- data/spec/cassettes/Turkit_Client_Organismes/_organisme/returns_a_organisme.json +0 -1
- data/spec/cassettes/Turkit_Client_Organismes/_organismes/handles_the_country_code_option.json +0 -1
- data/spec/cassettes/Turkit_Client_Organismes/_organismes/returns_all_organismes.json +0 -1
- data/spec/cassettes/Turkit_Client_Organismes/_search_organisme/returns_a_list_of_organismes.json +0 -1
- data/spec/cassettes/Turkit_Client_Organismes/_update_organisme/updates_an_organisme.json +0 -1
- data/spec/cassettes/Turkit_Client_Phonenumbers/_create_phonenumber/creates_a_phonenumber.json +0 -1
- data/spec/cassettes/Turkit_Client_Phonenumbers/_delete_phonenumber/deletes_a_phonenumber.json +0 -1
- data/spec/cassettes/Turkit_Client_Phonenumbers/_service_phonenumber/returns_a_phonenumber.json +0 -1
- data/spec/cassettes/Turkit_Client_Phonenumbers/_service_phonenumbers/lists_phonenumbers.json +0 -1
- data/spec/cassettes/Turkit_Client_Phonenumbers/_update_phonenumber/updates_a_phonenumber.json +0 -1
- data/spec/cassettes/Turkit_Client_Places/_create_place/creates_a_place.json +0 -1
- data/spec/cassettes/Turkit_Client_Places/_delete_place/deletes_a_place.json +0 -1
- data/spec/cassettes/Turkit_Client_Places/_service_place/returns_a_place.json +0 -1
- data/spec/cassettes/Turkit_Client_Places/_service_places/lists_places.json +0 -1
- data/spec/cassettes/Turkit_Client_Places/_update_place/updates_a_place.json +0 -1
- data/spec/cassettes/Turkit_Client_Services/_search_service/returns_a_list_of_services.json +0 -1
- data/spec/cassettes/Turkit_Client_Services/_service/returns_a_service.json +0 -1
- data/spec/cassettes/Turkit_Client_Services/_services/handles_the_country_code_option.json +0 -1
- data/spec/cassettes/Turkit_Client_Services/_services/returns_all_services.json +0 -1
- data/spec/cassettes/Turkit_Client_Tips/_create_tip/creates_a_tip.json +0 -1
- data/spec/cassettes/Turkit_Client_Tips/_delete_tip/deletes_a_tip.json +0 -1
- data/spec/cassettes/Turkit_Client_Tips/_service_tip/returns_a_tip.json +0 -1
- data/spec/cassettes/Turkit_Client_Tips/_service_tips/lists_tips.json +0 -1
- data/spec/cassettes/Turkit_Client_Tips/_update_tip/updates_a_tip.json +0 -1
- data/spec/lib/categories_spec.rb +0 -64
- data/spec/lib/contents_spec.rb +0 -47
- data/spec/lib/crowds_spec.rb +0 -47
- data/spec/lib/links_spec.rb +0 -47
- data/spec/lib/notifications_spec.rb +0 -47
- data/spec/lib/organismes_spec.rb +0 -64
- data/spec/lib/phonenumbers_spec.rb +0 -47
- data/spec/lib/tips_spec.rb +0 -47
data/lib/turba_kit/arguments.rb
DELETED
data/lib/turba_kit/client.rb
DELETED
@@ -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,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
|