mints 0.0.1 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,35 @@
1
1
  require_relative './client.rb'
2
2
  module Mints
3
+ ##
4
+ # == User context API
5
+ # User class contains functions that needs an API key and a session token as authentication
6
+ # == Usage example
7
+ # Initialize
8
+ # client = Mints::User.new(mints_url, api_key)
9
+ # Call any function
10
+ # client.get_contacts
11
+ # == Single resource options
12
+ # * +include+ - [String] include a relationship
13
+ # * +attributes+ - [Boolean] attach attributes to response
14
+ # * +categories+ - [Boolean] attach categories to response
15
+ # * +tags+ - [Boolean] attach tags to response
16
+ # == Resource collections options
17
+ # * +search+ - [String] filter by a search word
18
+ # * +scopes+ - [String] filter by a scope
19
+ # * +filters+ - [String] filter by where clauses
20
+ # * +jfilters+ - [String] filter using complex condition objects
21
+ # * +catfilters+ - [String] filter by categories
22
+ # * +fields+ - [String] indicates the columns that will be selected
23
+ # * +sort+ - [String] indicates the columns that will be selected
24
+ # * +include+ - [String] include a relationship
25
+ # * +attributes+ - [Boolean] attach attributes to response
26
+ # * +categories+ - [Boolean] attach categories to response
27
+ # * +taxonomies+ - [Boolean] attach categories to response
28
+ # * +tags+ - [Boolean] attach tags to response
3
29
  class User
4
30
  attr_reader :client
5
- def initialize(host, api_key, session_token = nil)
6
- @client = Mints::Client.new(host, api_key, 'user', session_token)
31
+ def initialize(host, api_key, session_token = nil, debug = false)
32
+ @client = Mints::Client.new(host, api_key, 'user', session_token, debug)
7
33
  end
8
34
 
9
35
  def login(email, password)
@@ -11,165 +37,371 @@ module Mints
11
37
  email: email,
12
38
  password: password,
13
39
  }
14
- response = @client.raw("post", "/users/login", data, '/api/v1')
40
+ response = @client.raw("post", "/users/login", nil, data, '/api/v1')
15
41
  if response.key? "api_token"
16
42
  @client.session_token = response["api_token"]
17
43
  end
18
44
  return response
19
45
  end
20
46
  ######################################### CRM #########################################
21
- ### Contacts ###
22
- def get_contacts
23
- return @client.get__crm__contacts
47
+ ##
48
+ # === Get contacts.
49
+ # Get a collection of contacts
50
+ #
51
+ # ==== Parameters
52
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::User-label-Resource+collections+options+] shown above can be used as parameter
53
+ def get_contacts(options = nil)
54
+ return @client.get__crm__contacts(options)
24
55
  end
25
56
 
26
- def get_contact(id)
27
- return @client.get__crm__contacts(id)
57
+ def get_contact(id, options = nil)
58
+ return @client.get__crm__contacts(id, options)
28
59
  end
29
60
 
30
- def create_contact(data)
31
- return @client.create__crm__contacts(data)
61
+ def create_contact(data, options = nil)
62
+ return @client.create__crm__contacts(data, options)
32
63
  end
33
64
 
34
- def update_contact(id, data)
35
- return @client.update__crm__contacts(id, data)
65
+ def update_contact(id, data, options = nil)
66
+ return @client.update__crm__contacts(id, data, options)
36
67
  end
37
- ### Companies ###
38
- def get_companies
39
- return @client.get__crm__companies
68
+
69
+ # === Get companies.
70
+ # Get a collection of companies
71
+ #
72
+ # ==== Parameters
73
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::User-label-Resource+collections+options+] shown above can be used as parameter
74
+ def get_companies(options = nil)
75
+ return @client.get__crm__companies(options)
40
76
  end
41
77
 
42
- def get_company(id)
43
- return @client.get__crm__companies(id)
78
+ def get_company(id, options = nil)
79
+ return @client.get__crm__companies(id, options)
44
80
  end
45
81
 
46
- def create_company(data)
47
- return @client.create__crm__companies(data)
82
+ def create_company(data, options = nil)
83
+ return @client.create__crm__companies(data, options)
48
84
  end
49
85
 
50
- def update_company(id, data)
51
- return @client.update__crm__companies(id, data)
86
+ def update_company(id, data, options = nil)
87
+ return @client.update__crm__companies(id, data, options)
52
88
  end
53
89
 
54
- ### Deals ###
55
- def get_deals
56
- return @client.get__crm__deals
90
+ # === Get deals.
91
+ # Get a collection of deals
92
+ #
93
+ # ==== Parameters
94
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::User-label-Resource+collections+options+] shown above can be used as parameter
95
+ def get_deals(options = nil)
96
+ return @client.get__crm__deals(options)
57
97
  end
58
98
 
59
- def get_deal(id)
60
- return @client.get__crm__deals(id)
99
+ def get_deal(id, options = nil)
100
+ return @client.get__crm__deals(id, options)
61
101
  end
62
102
 
63
- def create_deal(data)
64
- return @client.create__crm__deals(data)
103
+ def create_deal(data, options = nil)
104
+ return @client.create__crm__deals(data, options)
65
105
  end
66
106
 
67
- def update_deal(id, data)
68
- return @client.update__crm__deals(id, data)
107
+ def update_deal(id, data, options = nil)
108
+ return @client.update__crm__deals(id, data, options)
69
109
  end
70
110
 
71
111
  ######################################### Content #########################################
72
- ### Stories ###
73
- def get_stories
74
- return @client.get__content__stories
112
+ # === Get stories.
113
+ # Get a collection of stories
114
+ #
115
+ # ==== Parameters
116
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::User-label-Resource+collections+options+] shown above can be used as parameter
117
+ def get_stories(options = nil)
118
+ return @client.get__content__stories(options)
75
119
  end
76
120
 
77
- def get_story(id)
78
- return @client.get__content__stories(id)
121
+ def get_story(id, options = nil)
122
+ return @client.get__content__stories(id, options)
79
123
  end
80
124
 
81
- def create_story(data)
82
- return @client.create__content__stories(data)
125
+ def create_story(data, options = nil)
126
+ return @client.create__content__stories(data, options)
83
127
  end
84
128
 
85
- def update_story(id, data)
86
- return @client.update__content__stories(id, data)
129
+ def update_story(id, data, options = nil)
130
+ return @client.update__content__stories(id, data, options)
87
131
  end
88
132
 
89
- ### Content instances ###
90
- def get_content_instances
91
- return @client.get__content__instances
133
+ # === Get story templates.
134
+ # Get a collection of story templates
135
+ #
136
+ # ==== Parameters
137
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::User-label-Resource+collections+options+] shown above can be used as parameter
138
+ def get_story_templates(options = nil)
139
+ return @client.get__content__story_templates(options)
92
140
  end
93
141
 
94
- def get_content_instance(id)
95
- return @client.get__content__instances(id)
142
+ def get_story_template(id, options = nil)
143
+ return @client.get__content__story_templates(id, options)
96
144
  end
97
145
 
98
- def create_content_instance(data)
99
- return @client.create__content__instances(data)
146
+ def create_story_template(data, options = nil)
147
+ return @client.create__content__story_templates(data, options)
100
148
  end
101
149
 
102
- def update_content_instance(id, data)
103
- return @client.update__content__instances(id, data)
150
+ def update_story_template(id, data, options = nil)
151
+ return @client.update__content__story_templates(id, data, options)
104
152
  end
105
153
 
106
- ### Content pages ###
107
- def get_content_pages
108
- return @client.get__content__pages
154
+ # === Get content instances.
155
+ # Get a collection of content instances
156
+ #
157
+ # ==== Parameters
158
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::User-label-Resource+collections+options+] shown above can be used as parameter
159
+ def get_content_instances(options = nil)
160
+ return @client.get__content__instances(options)
109
161
  end
110
162
 
111
- def get_content_page(id)
112
- return @client.get__content__pages(id)
163
+ def get_content_instance(id, options = nil)
164
+ return @client.get__content__instances(id, options)
113
165
  end
114
166
 
115
- def create_content_page(data)
116
- return @client.create__content__pages(data)
167
+ def create_content_instance(data, options = nil)
168
+ return @client.create__content__instances(data, options)
117
169
  end
118
170
 
119
- def update_content_page(id, data)
120
- return @client.update__content__pages(id, data)
171
+ def update_content_instance(id, data, options = nil)
172
+ return @client.update__content__instances(id, data, options)
121
173
  end
122
174
 
123
- ### Content templates ###
124
- def get_content_templates
125
- return @client.get__content__templates
175
+ # === Get content pages.
176
+ # Get a collection of content pages
177
+ #
178
+ # ==== Parameters
179
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::User-label-Resource+collections+options+] shown above can be used as parameter
180
+ def get_content_pages(options = nil)
181
+ return @client.get__content__pages(options)
126
182
  end
127
183
 
128
- def get_content_page(id)
129
- return @client.get__content__templates(id)
184
+ def get_content_page(id, options = nil)
185
+ return @client.get__content__pages(id, options)
130
186
  end
131
187
 
132
- def create_content_page(data)
133
- return @client.create__content__templates(data)
188
+ def create_content_page(data, options = nil)
189
+ return @client.create__content__pages(data, options)
134
190
  end
135
191
 
136
- def update_content_page(id, data)
137
- return @client.update__content__templates(id, data)
192
+ def update_content_page(id, data, options = nil)
193
+ return @client.update__content__pages(id, data, options)
138
194
  end
139
195
 
140
- ######################################### Ecommerce #########################################
141
- ### Products ###
142
- def get_products
143
- return @client.get__ecommerce__products
196
+ # === Get content templates.
197
+ # Get a collection of content templates
198
+ #
199
+ # ==== Parameters
200
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::User-label-Resource+collections+options+] shown above can be used as parameter
201
+ def get_content_templates(options = nil)
202
+ return @client.get__content__templates(options)
144
203
  end
145
204
 
146
- def get_product(id)
147
- return @client.get__ecommerce__products(id)
205
+ def get_content_template(id, options = nil)
206
+ return @client.get__content__templates(id, options)
148
207
  end
149
208
 
150
- def create_product(data)
151
- return @client.create__ecommerce__products(data)
209
+ def create_content_template(data, options = nil)
210
+ return @client.create__content__templates(data, options)
152
211
  end
153
212
 
154
- def update_product(id, data)
155
- return @client.update__ecommerce__products(id, data)
213
+ def update_content_template(id, data, options = nil)
214
+ return @client.update__content__templates(id, data, options)
156
215
  end
157
216
 
158
- ### Locations ###
159
- def get_locations
160
- return @client.get__ecommerce__locations
217
+ # === Get products.
218
+ # Get a collection of products
219
+ #
220
+ # ==== Parameters
221
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::User-label-Resource+collections+options+] shown above can be used as parameter
222
+ def get_products(options = nil)
223
+ return @client.get__ecommerce__products(options)
161
224
  end
162
225
 
163
- def get_location(id)
164
- return @client.get__ecommerce__locations(id)
226
+ def get_product(id, options = nil)
227
+ return @client.get__ecommerce__products(id, options)
165
228
  end
166
229
 
167
- def create_location(data)
168
- return @client.create__ecommerce__locations(data)
230
+ def create_product(data, options = nil)
231
+ return @client.create__ecommerce__products(data, options)
169
232
  end
170
233
 
171
- def update_location(id, data)
172
- return @client.update__ecommerce__locations(id, data)
234
+ def update_product(id, data, options = nil)
235
+ return @client.update__ecommerce__products(id, data, options)
173
236
  end
174
- end
237
+
238
+ # === Get skus.
239
+ # Get a collection of skus
240
+ #
241
+ # ==== Parameters
242
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::User-label-Resource+collections+options+] shown above can be used as parameter
243
+ def get_skus(options = nil)
244
+ return @client.get__ecommerce__skus(options)
245
+ end
246
+
247
+ def get_sku(id, options = nil)
248
+ return @client.get__ecommerce__skus(id, options)
249
+ end
250
+
251
+ def create_sku(data, options = nil)
252
+ return @client.create__ecommerce__skus(data, options)
253
+ end
254
+
255
+ def update_sku(id, data, options = nil)
256
+ return @client.update__ecommerce__skus(id, data, options)
257
+ end
258
+
259
+ # === Get prices.
260
+ # Get a collection of prices
261
+ #
262
+ # ==== Parameters
263
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::User-label-Resource+collections+options+] shown above can be used as parameter
264
+ def get_prices(options = nil)
265
+ return @client.get__ecommerce__prices(options)
266
+ end
267
+
268
+ def get_price(id, options = nil)
269
+ return @client.get__ecommerce__prices(id, options)
270
+ end
271
+
272
+ def create_price(data, options = nil)
273
+ return @client.create__ecommerce__prices(data, options)
274
+ end
275
+
276
+ def update_price(id, data, options = nil)
277
+ return @client.update__ecommerce__prices(id, data, options)
278
+ end
279
+
280
+ # === Get prece lists.
281
+ # Get a collection of prece lists
282
+ #
283
+ # ==== Parameters
284
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::User-label-Resource+collections+options+] shown above can be used as parameter
285
+ def get_price_lists(options = nil)
286
+ return @client.get__ecommerce__price_lists(options)
287
+ end
288
+
289
+ def get_price_list(id, options = nil)
290
+ return @client.get__ecommerce__price_lists(id, options)
291
+ end
292
+
293
+ def create_price_list(data, options = nil)
294
+ return @client.create__ecommerce__price_lists(data, options)
295
+ end
296
+
297
+ def update_price_list(id, data, options = nil)
298
+ return @client.update__ecommerce__price_lists(id, data, options)
299
+ end
300
+
301
+ # === Get product brands.
302
+ # Get a collection of product brands
303
+ #
304
+ # ==== Parameters
305
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::User-label-Resource+collections+options+] shown above can be used as parameter
306
+ def get_product_brands(options = nil)
307
+ return @client.get__ecommerce__product_brands(options)
308
+ end
309
+
310
+ def get_prodict_brand(id, options = nil)
311
+ return @client.get__ecommerce__product_brands(id, options)
312
+ end
313
+
314
+ def create_prodict_brand(data, options = nil)
315
+ return @client.create__ecommerce__product_brands(data, options)
316
+ end
317
+
318
+ def update_product_brand(id, data, options = nil)
319
+ return @client.update__ecommerce__product_brands(id, data, options)
320
+ end
321
+
322
+ # === Get product types.
323
+ # Get a collection of product types
324
+ #
325
+ # ==== Parameters
326
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::User-label-Resource+collections+options+] shown above can be used as parameter
327
+ def get_product_types(options = nil)
328
+ return @client.get__ecommerce__product_types(options)
329
+ end
330
+
331
+ def get_prodict_type(id, options = nil)
332
+ return @client.get__ecommerce__product_types(id, options)
333
+ end
334
+
335
+ def create_prodict_type(data, options = nil)
336
+ return @client.create__ecommerce__product_types(data, options)
337
+ end
338
+
339
+ def update_product_type(id, data, options = nil)
340
+ return @client.update__ecommerce__product_types(id, data, options)
341
+ end
342
+
343
+ # === Get product templates.
344
+ # Get a collection of product templates
345
+ #
346
+ # ==== Parameters
347
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::User-label-Resource+collections+options+] shown above can be used as parameter
348
+ def get_product_templates(options = nil)
349
+ return @client.get__ecommerce__product_templates(options)
350
+ end
351
+
352
+ def get_prodict_template(id, options = nil)
353
+ return @client.get__ecommerce__product_templates(id, options)
354
+ end
355
+
356
+ def create_prodict_template(data, options = nil)
357
+ return @client.create__ecommerce__product_templates(data, options)
358
+ end
359
+
360
+ def update_product_template(id, data, options = nil)
361
+ return @client.update__ecommerce__product_templates(id, data, options)
362
+ end
363
+
364
+
365
+ # === Get locations.
366
+ # Get a collection of locations
367
+ #
368
+ # ==== Parameters
369
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::User-label-Resource+collections+options+] shown above can be used as parameter
370
+ def get_locations(options = nil)
371
+ return @client.get__ecommerce__locations(options)
372
+ end
373
+
374
+ def get_location(id, options = nil)
375
+ return @client.get__ecommerce__locations(id, options)
376
+ end
377
+
378
+ def create_location(data, options = nil)
379
+ return @client.create__ecommerce__locations(data, options)
380
+ end
381
+
382
+ def update_location(id, data, options = nil)
383
+ return @client.update__ecommerce__locations(id, data, options)
384
+ end
385
+
386
+ # === Get taxonomies.
387
+ # Get a collection of taxonomies
388
+ #
389
+ # ==== Parameters
390
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::User-label-Resource+collections+options+] shown above can be used as parameter
391
+ def get_taxonomies(options = nil)
392
+ return @client.get__config__taxonomies(options)
393
+ end
394
+
395
+ def get_taxonomy(id, options = nil)
396
+ return @client.get__config__taxonomies(id, options)
397
+ end
398
+
399
+ def create_taxonomy(data, options = nil)
400
+ return @client.create__config__taxonomies(data, options)
401
+ end
402
+
403
+ def update_taxonomy(id, data, options = nil)
404
+ return @client.update__config__taxonomies(id, data, options)
405
+ end
406
+ end
175
407
  end