mints 0.0.16 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/lib/client.rb +97 -38
  3. data/lib/contact.rb +124 -21
  4. data/lib/mints/controllers/admin_base_controller.rb +2 -2
  5. data/lib/mints/controllers/base_api_controller.rb +12 -11
  6. data/lib/mints/controllers/base_controller.rb +38 -9
  7. data/lib/mints_helper.rb +47 -0
  8. data/lib/pub.rb +147 -61
  9. data/lib/user/config/api_keys.rb +65 -0
  10. data/lib/user/config/appointments.rb +221 -0
  11. data/lib/user/config/attribute_groups.rb +77 -0
  12. data/lib/user/config/attributes.rb +86 -0
  13. data/lib/user/config/calendars.rb +89 -0
  14. data/lib/user/config/config.rb +65 -0
  15. data/lib/user/config/importers.rb +184 -0
  16. data/lib/user/config/public_folders.rb +108 -0
  17. data/lib/user/config/relationships.rb +138 -0
  18. data/lib/user/config/roles.rb +84 -0
  19. data/lib/user/config/seeds.rb +14 -0
  20. data/lib/user/config/system_settings.rb +53 -0
  21. data/lib/user/config/tags.rb +63 -0
  22. data/lib/user/config/taxonomies.rb +124 -0
  23. data/lib/user/config/teams.rb +70 -0
  24. data/lib/user/config/users.rb +76 -0
  25. data/lib/user/contacts/contacts.rb +21 -0
  26. data/lib/user/content/assets.rb +98 -0
  27. data/lib/user/content/content.rb +235 -0
  28. data/lib/user/content/content_instances.rb +147 -0
  29. data/lib/user/content/content_templates.rb +111 -0
  30. data/lib/user/content/conversations.rb +174 -0
  31. data/lib/user/content/dam.rb +88 -0
  32. data/lib/user/content/forms.rb +168 -0
  33. data/lib/user/content/message_templates.rb +162 -0
  34. data/lib/user/content/messages.rb +90 -0
  35. data/lib/user/content/pages.rb +81 -0
  36. data/lib/user/content/stories.rb +164 -0
  37. data/lib/user/content/story_templates.rb +95 -0
  38. data/lib/user/crm/companies.rb +111 -0
  39. data/lib/user/crm/contacts.rb +312 -0
  40. data/lib/user/crm/crm.rb +21 -0
  41. data/lib/user/crm/deals.rb +111 -0
  42. data/lib/user/crm/favorites.rb +17 -0
  43. data/lib/user/crm/segments.rb +132 -0
  44. data/lib/user/crm/users.rb +22 -0
  45. data/lib/user/crm/workflow_step_objects.rb +89 -0
  46. data/lib/user/crm/workflow_steps.rb +49 -0
  47. data/lib/user/crm/workflows.rb +70 -0
  48. data/lib/user/ecommerce/ecommerce.rb +29 -0
  49. data/lib/user/ecommerce/item_prices.rb +86 -0
  50. data/lib/user/ecommerce/locations.rb +166 -0
  51. data/lib/user/ecommerce/order_items_groups.rb +109 -0
  52. data/lib/user/ecommerce/order_statuses.rb +26 -0
  53. data/lib/user/ecommerce/orders.rb +258 -0
  54. data/lib/user/ecommerce/price_lists.rb +73 -0
  55. data/lib/user/ecommerce/product_templates.rb +104 -0
  56. data/lib/user/ecommerce/product_variations.rb +129 -0
  57. data/lib/user/ecommerce/products.rb +169 -0
  58. data/lib/user/ecommerce/skus.rb +88 -0
  59. data/lib/user/ecommerce/taxes.rb +82 -0
  60. data/lib/user/ecommerce/variant_options.rb +69 -0
  61. data/lib/user/ecommerce/variant_values.rb +72 -0
  62. data/lib/user/helpers/helpers.rb +113 -0
  63. data/lib/user/helpers/object_activities.rb +83 -0
  64. data/lib/user/helpers/object_folders.rb +82 -0
  65. data/lib/user/helpers/user_folders.rb +83 -0
  66. data/lib/user/marketing/marketing.rb +120 -0
  67. data/lib/user/profile/profile.rb +111 -0
  68. data/lib/user.rb +24 -368
  69. metadata +63 -3
@@ -24,10 +24,10 @@ module Mints
24
24
  response = @mints_contact.login(email, password)
25
25
  # Get session token from response
26
26
  session_token = response['session_token']
27
- id_token = response['contact']['id_token']
27
+ id_token = response['contact']['contact_token'] ? response['contact']['contact_token'] : response['contact']['id_token']
28
28
  # Set a permanent cookie with the session token
29
- cookies.permanent[:mints_contact_session_token] = session_token
30
- cookies.permanent[:mints_contact_id] = id_token
29
+ cookies.permanent[:mints_contact_session_token] = { value: session_token, secure: true, httponly: true }
30
+ cookies.permanent[:mints_contact_id] = { value: id_token, secure: true, httponly: true }
31
31
  @contact_token = id_token
32
32
  end
33
33
 
@@ -39,10 +39,10 @@ module Mints
39
39
  response = @mints_contact.login(email, password)
40
40
  # Get session token from response
41
41
  session_token = response['session_token']
42
- id_token = response['contact']['id_token']
42
+ id_token = response['contact']['contact_token'] ? response['contact']['contact_token'] : response['contact']['id_token']
43
43
  # Set a permanent cookie with the session token
44
- cookies.permanent[:mints_contact_session_token] = session_token
45
- cookies.permanent[:mints_contact_id] = id_token
44
+ cookies.permanent[:mints_contact_session_token] = { value: session_token, secure: true, httponly: true }
45
+ cookies.permanent[:mints_contact_id] = { value: id_token, secure: true, httponly: true }
46
46
  @contact_token = id_token
47
47
  end
48
48
 
@@ -64,10 +64,29 @@ module Mints
64
64
  # === Register visit.
65
65
  # Call register visit method from the public client and set/renew the cookie mints_contact_id
66
66
  def register_visit
67
+ if @debug
68
+ puts "REQUEST IN REGISTER VISIT: #{request}"
69
+ puts "BODY REQUEST: #{request.body}"
70
+ puts "AUTH REQUEST: #{request.authorization}"
71
+ puts "LENGTH REQUEST: #{request.content_length}"
72
+ puts "FORM DATA REQUEST: #{request.form_data?}"
73
+ puts "FULLPATH REQUEST: #{request.fullpath}"
74
+ puts "HEADERS REQUEST: #{request.headers}"
75
+ puts "IP REQUEST: #{request.ip}"
76
+ puts "REQUEST IP ADDRESS: #{request['ip_address']}"
77
+ puts "REQUEST REMOTE IP: #{request['remote_ip']}"
78
+ end
67
79
  response = @mints_pub.register_visit(request)
68
- @contact_token = response['user_token']
80
+ if @debug
81
+ puts "RESPONSE IN REGISTER VISIT: #{response}"
82
+ end
83
+ @contact_token = response['contact_token'] ? response['contact_token'] : response['user_token']
69
84
  @visit_id = response['visit_id']
70
- cookies.permanent[:mints_contact_id] = @contact_token
85
+ if @debug
86
+ puts "VISIT ID: #{@visit_id}"
87
+ end
88
+ cookies.permanent[:mints_contact_id] = { value: @contact_token, secure: true, httponly: true }
89
+ cookies.permanent[:mints_visit_id] = { value: @visit_id, secure: true, httponly: true }
71
90
  end
72
91
 
73
92
  ##
@@ -84,7 +103,8 @@ module Mints
84
103
  raise 'MintsBadCredentialsError'
85
104
  end
86
105
  # Initialize mints pub client, credentials taken from mints_config.yml.erb file
87
- @mints_pub = Mints::Pub.new(@host, @api_key, nil, @debug)
106
+ @visit_id = cookies[:mints_visit_id] ? cookies[:mints_visit_id] : nil
107
+ @mints_pub = Mints::Pub.new(@host, @api_key, @contact_token, @visit_id, @debug)
88
108
  # Set contact token from cookie
89
109
  @mints_pub.client.session_token = @contact_token
90
110
  end
@@ -100,6 +120,15 @@ module Mints
100
120
  # === Set mints contact client.
101
121
  # Initialize the public client and set the contact token
102
122
  def set_mints_contact_client
123
+ if File.exists?("#{Rails.root}/mints_config.yml.erb")
124
+ template = ERB.new File.new("#{Rails.root}/mints_config.yml.erb").read
125
+ config = YAML.load template.result(binding)
126
+ @host = config["mints"]["host"]
127
+ @api_key = config["mints"]["api_key"]
128
+ @debug = config["sdk"]["debug"] ? config["sdk"]["debug"] : false
129
+ else
130
+ raise 'MintsBadCredentialsError'
131
+ end
103
132
  # Initialize mints clontact client
104
133
  session_token = cookies[:mints_contact_session_token] ? cookies[:mints_contact_session_token] : nil
105
134
  contact_token_id = cookies[:mints_contact_id] ? cookies[:mints_contact_id] : nil
@@ -0,0 +1,47 @@
1
+
2
+ module MintsHelper
3
+ # === Get query results.
4
+ # Method used to give the options to make a 'post' or 'get' request.
5
+ #
6
+ # ==== Parameters
7
+ # url:: (String) -- Url to make the request.
8
+ # options:: (Hash) -- List of {Resource collection Options}[#class-Mints::User-label-Resource+collections+options+] shown above can be used as parameter.
9
+ # use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
10
+ #
11
+ def get_query_results(url, options = nil, use_post = true)
12
+ if use_post
13
+ return @client.raw("post", "#{url}/query", options)
14
+ else
15
+ return @client.raw("get", url, options)
16
+ end
17
+ end
18
+
19
+ # === Data transform.
20
+ # Transform a 'data' variable to a standardized 'data' variable.
21
+ #
22
+ # ==== Parameters
23
+ # data:: (Hash) -- Data to be submited.
24
+ #
25
+ def data_transform(data)
26
+ data = correct_json(data)
27
+ unless data[:data]
28
+ data = {data: data}
29
+ end
30
+ return data.to_json
31
+ end
32
+
33
+ # === Correct json.
34
+ # Receives a json data and convert it to a symbolized object.
35
+ #
36
+ # ==== Parameters
37
+ # data:: (Hash) -- Data to be submited.
38
+ #
39
+ def correct_json(data)
40
+ if data.is_a? String
41
+ data = JSON.parse(data)
42
+ end
43
+ data = data.symbolize_keys
44
+ return data
45
+ end
46
+
47
+ end
data/lib/pub.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'yaml'
2
2
  require_relative './client.rb'
3
+ require_relative './mints_helper.rb'
4
+
3
5
  module Mints
4
6
  ##
5
7
  # == Public context API
@@ -70,30 +72,38 @@ module Mints
70
72
 
71
73
  class Pub
72
74
  attr_reader :client
73
-
74
75
  ##
75
76
  # === Initialize.
76
- # Class constructor
77
+ # Class constructor.
77
78
  #
78
79
  # ==== Parameters
79
- # * +host+ - [String] It's the visitor IP
80
- # * +api_key+ - [String] Mints instance api key
81
- # * +contact_token+ - [String] Cookie 'mints_contact_id' value (mints_contact_token)
80
+ # host:: (String) -- It's the visitor IP.
81
+ # api_key:: (String) -- Mints instance api key.
82
+ # contact_token_id:: (Integer) -- Cookie 'mints_contact_id' value (mints_contact_token).
83
+ #
82
84
  # ==== Return
83
- # Returns a Client object
84
- def initialize(host, api_key, contact_token_id = nil, debug = false)
85
- @client = Mints::Client.new(host, api_key, 'public', nil, contact_token_id, debug)
85
+ # Returns a Client object.
86
+ def initialize(host, api_key, contact_token_id = nil, visit_id = nil, debug = false)
87
+ @client = Mints::Client.new(host, api_key, 'public', nil, contact_token_id, visit_id, debug)
86
88
  end
87
89
 
88
90
  ##
89
91
  # === Register Visit.
90
- # Register a ghost/contact visit in Mints.Cloud
92
+ # Register a ghost/contact visit in Mints.Cloud.
91
93
  #
92
94
  # ==== Parameters
93
- # * +request+ - [ActionDispatch::Request] request
94
- # * +ip+ - [String] It's the visitor IP
95
- # * +user_agent+ - The visitor's browser user agent
96
- # * +url+ - [String] URL visited
95
+ # request:: (ActionDispatch::Request) -- request.
96
+ # ip:: (String) -- It's the visitor IP.
97
+ # user_agent:: (String) -- The visitor's browser user agent.
98
+ # url:: (String) -- URL visited.
99
+ #
100
+ # ==== Example
101
+ # request = {
102
+ # "remote_ip" => "http://1.1.1.1/",
103
+ # "user_agent" => "User Agent",
104
+ # "fullpath" => "https://fullpath/example"
105
+ # }
106
+ # @mints_pub.register_visit(request, request["remote_ip"], request["user_agent"], request["fullpath"])
97
107
  def register_visit(request, ip = nil, user_agent = nil, url = nil)
98
108
  data = {
99
109
  ip_address: ip || request.remote_ip,
@@ -106,31 +116,40 @@ module Mints
106
116
 
107
117
  ##
108
118
  # === Register Visit timer.
109
- # Register a page visit time
119
+ # Register a page visit time.
110
120
  #
111
121
  # ==== Parameters
112
- # * +visit+ - [String] It's the visitor IP
113
- # * +time+ - [Integer] The visitor's browser user agent
122
+ # visit:: (String) -- It's the visitor IP.
123
+ # time:: (Integer) -- The visitor's browser user agent.
124
+ #
125
+ # ==== Example
126
+ # @mints_pub.register_visit_timer("60da2325d29acc7e55684472", 4)
114
127
  def register_visit_timer(visit, time)
115
128
  return @client.raw("get", "/register-visit-timer?visit=#{visit}&time=#{time}")
116
129
  end
117
130
 
118
131
  ##
119
132
  # === Get Asset Info.
120
- # Get a description of an Asset
133
+ # Get a description of an Asset.
121
134
  #
122
135
  # ==== Parameters
123
- # * +slug+ - [String] It's the string identifier of the asset.
136
+ # slug:: (String) -- It's the string identifier of the asset.
137
+ #
138
+ # ==== Example
139
+ # @mints_pub.get_asset_info("asset_slug")
124
140
  def get_asset_info(slug)
125
141
  return @client.raw("get", "/content/asset-info/#{slug}")
126
142
  end
127
143
 
128
144
  ##
129
145
  # === Get Stories.
130
- # Get a collection of stories
146
+ # Get a collection of stories.
131
147
  #
132
148
  # ==== Parameters
133
- # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
149
+ # options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
150
+ #
151
+ # ==== Example
152
+ # @mints_pub.get_stories
134
153
  def get_stories(options = nil)
135
154
  return @client.raw("get", "/content/stories", options)
136
155
  end
@@ -140,18 +159,24 @@ module Mints
140
159
  # Get a single story.
141
160
  #
142
161
  # ==== Parameters
143
- # * +slug+ - [String] It's the string identifier generated by Mints
144
- # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
162
+ # slug:: (String) -- It's the string identifier generated by Mints.
163
+ # options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
164
+ #
165
+ # ==== Example
166
+ # @mints_pub.get_story("story_slug")
145
167
  def get_story(slug, options = nil)
146
- return @client.raw("get", "/content/stories/#{slug}", options)
168
+ return @client.raw("get", "/content/stories/#{slug}", options, nil, nil, nil, true)
147
169
  end
148
170
 
149
171
  ##
150
172
  # === Get Forms.
151
- # Get a collection of forms
173
+ # Get a collection of forms.
152
174
  #
153
175
  # ==== Parameters
154
- # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
176
+ # options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
177
+ #
178
+ # ==== Example
179
+ # @mints_pub.get_forms
155
180
  def get_forms(options = nil)
156
181
  return @client.raw("get", "/content/forms", options)
157
182
  end
@@ -161,28 +186,42 @@ module Mints
161
186
  # Get a single form.
162
187
  #
163
188
  # ==== Parameters
164
- # * +slug+ - [String] It's the string identifier generated by Mints
165
- # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
189
+ # slug:: (String) -- It's the string identifier generated by Mints.
190
+ # options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
191
+ #
192
+ # ==== Example
193
+ # @mints_pub.get_form("form_slug")
166
194
  def get_form(slug, options = nil)
167
- return @client.raw("get", "/content/forms/#{slug}", options)
195
+ return @client.raw("get", "/content/forms/#{slug}", options, nil, nil, nil, true)
168
196
  end
169
197
 
170
198
  ##
171
199
  # === Submit Form.
172
- # Submit a form.
200
+ # Submit a form with data.
173
201
  #
174
202
  # ==== Parameters
175
- # * +data+ - [Hash] Data to be submited
203
+ # data:: (Hash) -- Data to be submited.
204
+ #
205
+ # ==== Example
206
+ # data = {
207
+ # 'form_slug': 'form_slug',
208
+ # 'email': 'email@example.com',
209
+ # 'given_name': 'given_name',
210
+ # 'f1': 'Field 1 answer',
211
+ # 'f2': 'Field 2 answer',
212
+ # 'f3': 'Field 3 answer'
213
+ # }
214
+ # @data = @mints_pub.submit_form(data)
176
215
  def submit_form(data)
177
- return @client.raw("post", "/content/forms/submit", nil, data)
216
+ return @client.raw("post", "/content/forms/submit", nil, data_transform(data))
178
217
  end
179
218
 
180
219
  ##
181
220
  # === Get Content Instances.
182
- # Get a collection of content instances
221
+ # Get a collection of content instances. _Note:_ Options must be specified.
183
222
  #
184
223
  # ==== Parameters
185
- # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
224
+ # options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
186
225
  def get_content_instances(options = nil)
187
226
  return @client.raw("get", "/content/content-instances", options)
188
227
  end
@@ -192,31 +231,38 @@ module Mints
192
231
  # Get a single content instance.
193
232
  #
194
233
  # ==== Parameters
195
- # * +slug+ - [String] It's the string identifier generated by Mints
196
- # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
234
+ # slug:: (String) -- It's the string identifier generated by Mints.
235
+ # options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
236
+ #
237
+ # ==== Example
238
+ # @mints_pub.get_content_instance("content_instance_slug")
197
239
  def get_content_instance(slug, options = nil)
198
240
  return @client.raw("get", "/content/content-instances/#{slug}", options)
199
241
  end
200
242
 
243
+ #TODO: This method is commented for future use
201
244
  ##
202
245
  # === Get Content Pages.
203
246
  # Get all content pages.
204
247
  #
205
248
  # ==== Parameters
206
- # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
207
- def get_content_pages(options = nil)
208
- return @client.raw("get", "/content/content-pages", options)
209
- end
249
+ # options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
250
+ # def get_content_pages(options = nil)
251
+ #return @client.raw("get", "/content/content-pages", options)
252
+ #end
210
253
 
211
254
  ##
212
255
  # === Get Content Page.
213
- # Get a single content page
256
+ # Get a single content page.
214
257
  #
215
258
  # ==== Parameters
216
- # * +slug+ - [String] It's the slug
217
- # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
259
+ # slug:: (String) -- It's the string identifier generated by Mints.
260
+ # options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
261
+ #
262
+ # ==== Example
263
+ # @mints_pub.get_content_page("test-page")
218
264
  def get_content_page(slug, options = nil)
219
- return @client.raw("get", "/content/content-pages/#{slug}", options)
265
+ return @client.raw("get", "/content/content-pages/#{slug}", options, nil, nil, nil, true)
220
266
  end
221
267
 
222
268
  ##
@@ -224,7 +270,10 @@ module Mints
224
270
  # Get all locations.
225
271
  #
226
272
  # ==== Parameters
227
- # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
273
+ # options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
274
+ #
275
+ # ==== Example
276
+ # @mints_pub.get_locations
228
277
  def get_locations(options = nil)
229
278
  return @client.raw("get", "/ecommerce/locations", options)
230
279
  end
@@ -234,7 +283,10 @@ module Mints
234
283
  # Get a collection of products.
235
284
  #
236
285
  # ==== Parameters
237
- # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
286
+ # options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
287
+ #
288
+ # ==== Example
289
+ # @mints_pub.get_products
238
290
  def get_products(options = nil)
239
291
  return @client.raw("get", "/ecommerce/products", options)
240
292
  end
@@ -244,10 +296,13 @@ module Mints
244
296
  # Get a single product.
245
297
  #
246
298
  # ==== Parameters
247
- # * +slug+ - [String] It's the string identifier generated by Mints
248
- # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
299
+ # slug:: (String) -- It's the string identifier generated by Mints.
300
+ # options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
301
+ #
302
+ # ==== Example
303
+ # @mints_pub.get_product("product_slug")
249
304
  def get_product(slug, options = nil)
250
- return @client.raw("get", "/ecommerce/products/#{slug}", options)
305
+ return @client.raw("get", "/ecommerce/products/#{slug}", options, nil, nil, nil, true)
251
306
  end
252
307
 
253
308
  ##
@@ -255,18 +310,30 @@ module Mints
255
310
  # Get a collection of categories.
256
311
  #
257
312
  # ==== Parameters
258
- # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
313
+ # options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
314
+ #
315
+ # ==== Example
316
+ # options = {
317
+ # "object_type": "stories"
318
+ # }
319
+ # @mints_pub.get_categories(options)
259
320
  def get_categories(options = nil)
260
321
  return @client.raw("get", "/config/categories", options)
261
322
  end
262
323
 
263
324
  ##
264
325
  # === Get Category.
265
- # Get a single category
326
+ # Get a single category.
266
327
  #
267
328
  # ==== Parameters
268
- # * +slug+ - [String] It's the string identifier generated by Mints
269
- # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
329
+ # slug:: (String) -- It's the string identifier generated by Mints.
330
+ # options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
331
+ #
332
+ # ==== Example
333
+ # options = {
334
+ # "object_type": "locations"
335
+ # }
336
+ # @mints_pub.get_category("asset_slug", options)
270
337
  def get_category(slug, options = nil)
271
338
  return @client.raw("get", "/config/categories/#{slug}", options)
272
339
  end
@@ -276,18 +343,24 @@ module Mints
276
343
  # Get a collection of tags.
277
344
  #
278
345
  # ==== Parameters
279
- # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
346
+ # options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
347
+ #
348
+ # ==== Example
349
+ # @mints_pub.get_tags
280
350
  def get_tags(options = nil)
281
351
  return @client.raw("get", "/config/tags", options)
282
352
  end
283
353
 
284
354
  ##
285
355
  # === Get Tag.
286
- # Get a single tag
356
+ # Get a single tag.
287
357
  #
288
358
  # ==== Parameters
289
- # * +slug+ - [String] It's the string identifier generated by Mints
290
- # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
359
+ # slug:: (String) -- It's the string identifier generated by Mints.
360
+ # options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
361
+ #
362
+ # ==== Example
363
+ # @mints_pub.get_tag("tag_slug")
291
364
  def get_tag(slug, options = nil)
292
365
  return @client.raw("get", "/config/tags/#{slug}", options)
293
366
  end
@@ -297,18 +370,24 @@ module Mints
297
370
  # Get a collection of taxonomies.
298
371
  #
299
372
  # ==== Parameters
300
- # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
373
+ # options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
374
+ #
375
+ # ==== Example
376
+ # @mints_pub.get_taxonomies
301
377
  def get_taxonomies(options = nil)
302
378
  return @client.raw("get", "/config/taxonomies", options)
303
379
  end
304
380
 
305
381
  ##
306
382
  # === Get Taxonomy.
307
- # Get a single taxonomy
383
+ # Get a single taxonomy.
308
384
  #
309
385
  # ==== Parameters
310
- # * +slug+ - [String] It's the string identifier generated by Mints
311
- # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
386
+ # slug:: (String) -- It's the string identifier generated by Mints.
387
+ # options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
388
+ #
389
+ # ==== Example
390
+ # @mints_pub.get_taxonomy("taxonomy_slug")
312
391
  def get_taxonomy(slug, options = nil)
313
392
  return @client.raw("get", "/config/taxonomies/#{slug}", options)
314
393
  end
@@ -318,9 +397,16 @@ module Mints
318
397
  # Get a collection of attributes.
319
398
  #
320
399
  # ==== Parameters
321
- # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
400
+ # options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
401
+ #
402
+ # ==== Example
403
+ # @mints_pub.get_attributes
322
404
  def get_attributes(options = nil)
323
405
  return @client.raw("get", "/config/attributes", options)
324
406
  end
407
+
408
+ private
409
+
410
+ include MintsHelper
325
411
  end
326
412
  end
@@ -0,0 +1,65 @@
1
+ module ApiKeys
2
+ ##
3
+ # == Api keys
4
+ #
5
+
6
+ # === Get api keys.
7
+ # Get a collection of api keys.
8
+ #
9
+ # ==== Parameters
10
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
11
+ #
12
+ # ==== First Example
13
+ # @data = @mints_user.get_api_keys
14
+ #
15
+ # ==== Second Example
16
+ # options = { "fields": "id" }
17
+ # @data = @mints_user.get_api_keys(options)
18
+ def get_api_keys(options = nil)
19
+ return @client.raw("get", "/config/api-keys", options)
20
+ end
21
+
22
+ # === Get api key.
23
+ # Get an api key info.
24
+ #
25
+ # ==== Parameters
26
+ # id:: (Integer) -- Api key id.
27
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
28
+ #
29
+ # ==== First Example
30
+ # @data = @mints_user.get_api_key(2)
31
+ #
32
+ # ==== Second Example
33
+ # options = { "fields": "id" }
34
+ # @data = @mints_user.get_api_key(2, options)
35
+ def get_api_key(id, options = nil)
36
+ return @client.raw("get", "/config/api-keys/#{id}", options)
37
+ end
38
+
39
+ # === Create api key.
40
+ # Create an api key with data.
41
+ #
42
+ # ==== Parameters
43
+ # data:: (Hash) -- Data to be submited.
44
+ #
45
+ # ==== Example
46
+ # data = {
47
+ # "description": "New Api Key Description"
48
+ # }
49
+ # @data = @mints_user.create_api_key(data)
50
+ def create_api_key(data)
51
+ return @client.raw("post", "/config/api-keys", nil, data_transform(data))
52
+ end
53
+
54
+ # === Delete api key.
55
+ # Delete an api key.
56
+ #
57
+ # ==== Parameters
58
+ # id:: (Integer) -- Api key id.
59
+ #
60
+ # ==== Example
61
+ # @data = @mints_user.delete_api_key(2)
62
+ def delete_api_key(id)
63
+ return @client.raw("delete", "/config/api-keys/#{id}")
64
+ end
65
+ end