mints 0.0.20 → 0.0.21

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.
data/lib/contact.rb CHANGED
@@ -6,7 +6,7 @@ module Mints
6
6
  attr_reader :client
7
7
  ##
8
8
  # === Initialize.
9
- # Class constructor
9
+ # Class constructor.
10
10
  #
11
11
  # ==== Parameters
12
12
  # host:: (String) -- It's the visitor IP.
@@ -16,14 +16,36 @@ module Mints
16
16
  # ==== Return
17
17
  # Returns a Contact object
18
18
  def initialize(host, api_key, session_token = nil, contact_token_id = nil, debug = false)
19
+ @contact_v1_url = '/api/contact/v1'
19
20
  @client = Mints::Client.new(host, api_key, "contact", session_token, contact_token_id, nil, debug)
20
21
  end
21
22
 
23
+ ### V1/CONTACTS ###
24
+
25
+ ##
26
+ # === Register.
27
+ # Register a contact.
28
+ #
29
+ # ==== Parameters
30
+ # data:: (Hash) -- It's the register data.
31
+ #
32
+ # ==== Example
33
+ # data = {
34
+ # "email": "email@example.com",
35
+ # "given_name": "Given Name",
36
+ # "last_name": "Last Name",
37
+ # "password": "password"
38
+ # }
39
+ # @mints_contact.register(data);
40
+ def register(data)
41
+ return @client.raw("post", "/contacts/register", nil, data_transform(data))
42
+ end
43
+
22
44
  ##
23
45
  # === Login.
24
46
  # Starts a contact session.
25
47
  #
26
- # ==== Parameters:
48
+ # ==== Parameters
27
49
  # email:: (String) -- The email that will be logged.
28
50
  # password:: (String) -- The password of the email.
29
51
  #
@@ -41,11 +63,51 @@ module Mints
41
63
  return response
42
64
  end
43
65
 
66
+ ##
67
+ # === Recover Password.
68
+ # Send a email that contains a token to a contact. That token will be used in reset_password to establish a new password.
69
+ #
70
+ # ==== Parameters
71
+ # data:: (Hash) -- It's a data key where will be hosted the destination email.
72
+ #
73
+ # ==== Example
74
+ # data = { "email": "email@example.com" }
75
+ # @mints_contact.recover_password(data)
76
+ def recover_password(data)
77
+ return @client.raw("post", "/contacts/recover-password", nil, data_transform(data))
78
+ end
79
+
80
+ ##
81
+ # === Reset Password.
82
+ # Reset password using a token. The token is obtained by recover_password method.
83
+ #
84
+ # ==== Parameters
85
+ # data:: (Hash) -- It's a set of data which contains all the information to reset a contact password.
86
+ #
87
+ # ==== Example
88
+ # data = {
89
+ # "email": "email@example.com",
90
+ # "password": "password",
91
+ # "password_confirmation": "password",
92
+ # "token": "644aa3aa0831d782cc42e42b11aedea9a2234389af4f429a8d96651295ecfa09"
93
+ # }
94
+ # @mints_contact.reset_password(data)
95
+ def reset_password(data)
96
+ return @client.raw("post", "/contacts/reset-password", nil, data_transform(data))
97
+ end
98
+
99
+ ##
100
+ # === OAuth Login.
101
+ # Login a contact using oauth.
102
+ def oauth_login(data)
103
+ return @client.raw("post", "/contacts/oauth-login", nil, data)
104
+ end
105
+
44
106
  ##
45
107
  # === Magic Link Login.
46
108
  # Starts a contact session with a token received in the contact email. The token will be received by send_magic_link method.
47
109
  #
48
- # ==== Parameters:
110
+ # ==== Parameters
49
111
  # token:: (String) -- The email token that will be used to log in.
50
112
  #
51
113
  # ==== Example
@@ -61,10 +123,10 @@ module Mints
61
123
  end
62
124
 
63
125
  ##
64
- # === Send Magic Link
126
+ # === Send Magic Link.
65
127
  # Send magic link to contact by email. That magic link will be used in magic_link_login method.
66
128
  #
67
- # ==== Parameters:
129
+ # ==== Parameters
68
130
  # email:: (String) -- Contact's email.
69
131
  # template_slug:: (String) -- Email template's slug to be used in the email.
70
132
  # redirectUrl:: (String) -- Url to be redirected in the implemented page.
@@ -88,15 +150,63 @@ module Mints
88
150
  return response
89
151
  end
90
152
 
153
+ ### CONTACT/V1 ###
154
+
155
+ ##
156
+ # === Me.
157
+ # Get contact logged info.
158
+ #
159
+ # ==== Parameters
160
+ # # options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
161
+ #
162
+ # ==== First Example
163
+ # @data = @mints_contact.me
164
+ #
165
+ # ==== Second Example
166
+ # options = {
167
+ # "attributes": true,
168
+ # "taxonomies": true
169
+ # }
170
+ # @data = @mints_contact.me(options)
171
+ def me(options = nil)
172
+ return @client.raw("get", "/me", options, nil, @contact_v1_url)
173
+ end
174
+
175
+ ##
176
+ # === Status.
177
+ # Get contact logged status.
178
+ #
179
+ # ==== Example
180
+ # @data = @mints_contact.status
181
+ def status
182
+ return @client.raw("get", "/status", nil, nil, @contact_v1_url)
183
+ end
184
+
185
+ ##
186
+ # === Update.
187
+ # Update logged contact attributes.
188
+ #
189
+ # ==== Parameters
190
+ # data:: (Hash) -- It's the data to update with a session active.
191
+ #
192
+ # ==== Example
193
+ # data = {
194
+ # "given_name": "Given Name",
195
+ # "last_name": "Last Name"
196
+ # }
197
+ # @data = @mints_contact.update(data)
198
+ def update(data)
199
+ return @client.raw("put", "/update", nil, data_transform(data), @contact_v1_url)
200
+ end
201
+
91
202
  ##
92
203
  # === Logout.
93
204
  # Ends a contact session previously logged.
94
205
  #
95
206
  # ==== Example
96
- # @mints_contact.login("email@example.com", "password")
97
- # @mints_contact.logout
207
+ # @data = @mints_contact.logout
98
208
  def logout
99
- response = @client.raw("post", "/contacts/logout") if session_token?
209
+ response = @client.raw("post", "/logout", nil, nil, @contact_v1_url) if session_token?
100
210
  if response["success"]
101
211
  @client.session_token = nil
102
212
  end
@@ -107,119 +217,569 @@ module Mints
107
217
  # === Change Password.
108
218
  # Change password without email. To change the password a contact must be logged.
109
219
  #
110
- # ==== Parameters:
220
+ # ==== Parameters
111
221
  # data:: (Hash) -- A new password allocated in a data key.
112
222
  #
113
223
  # ==== Example
114
- # @mints_contact.login("email@example.com", "password")
115
- # data = { "password": "123456" }
224
+ # data = { "password": "new_password" }
116
225
  # @data = @mints_contact.change_password(data)
117
226
  def change_password(data)
118
- return @client.raw("post", "/contacts/change-password", nil, data_transform(data))
227
+ return @client.raw("post", "/change-password", nil, data_transform(data), @contact_v1_url)
119
228
  end
120
229
 
230
+ # Conversations
231
+
121
232
  ##
122
- # === Recover Password.
123
- # Send a email that contains a token to a contact. That token will be used in reset_password to establish a new password.
233
+ # === Get Conversations.
234
+ # Get a collection of conversations.
124
235
  #
125
- # ==== Parameters:
126
- # data:: (Hash) -- It's a data key where will be hosted the destination email.
236
+ # ==== Parameters
237
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
238
+ # FIXME: This method doesn't return data.
239
+ def get_conversations(options = nil)
240
+ return @client.raw("get", "/content/conversations", options, nil, @contact_v1_url)
241
+ end
242
+
243
+ ##
244
+ # === Get Conversation.
245
+ # Get a conversation info.
246
+ #
247
+ # ==== Parameters
248
+ # id:: (Integer) -- Conversation id.
249
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
250
+ # FIXME: This method doesn't return data.
251
+ def get_conversation(id, options = nil)
252
+ return @client.raw("get", "/content/conversations/#{id}", options, nil, @contact_v1_url)
253
+ end
254
+
255
+ ##
256
+ # === Create Conversation.
257
+ # Create a conversation with data.
258
+ #
259
+ # ==== Parameters
260
+ # data:: (Hash) -- Data to be submited.
127
261
  #
128
262
  # ==== Example
129
- # data = { "email": "email@example.com" }
130
- # @mints_contact.recover_password(data)
131
- def recover_password(data)
132
- return @client.raw("post", "/contacts/recover-password", nil, data_transform(data))
263
+ # data = {
264
+ # "title": "New Conversation To Test"
265
+ # }
266
+ # @data = @mints_contact.create_conversation(data)
267
+ def create_conversation(data)
268
+ return @client.raw("post", "/content/conversations", nil, data_transform(data), @contact_v1_url)
133
269
  end
134
270
 
135
271
  ##
136
- # === Reset Password.
137
- # Reset password using a token. The token is obtained by recover_password method.
272
+ # === Update Conversation.
273
+ # Update a location template info.
138
274
  #
139
- # ==== Parameters:
140
- # data:: (Hash) -- It's a set of data which contains all the information to reset a contact password.
275
+ # ==== Parameters
276
+ # id:: (Integer) -- Conversation id.
277
+ # data:: (Hash) -- Data to be submited.
278
+ # FIXME: This method doesn't locate conversation id to be updated.
279
+ def update_conversation(id, data)
280
+ return @client.raw("put", "/content/conversations/#{id}", nil, data_transform(data), @contact_v1_url)
281
+ end
282
+
283
+ ##
284
+ # === Update Conversation Status.
285
+ # Update a conversation status.
286
+ #
287
+ # ==== Parameters
288
+ # id:: (Integer) -- Conversation id.
289
+ # data:: (Hash) -- Data to be submited.
290
+ # FIXME: This method doesn't locate conversation id to be updated.
291
+ def update_conversation_status(id, data)
292
+ return @client.raw("put", "/content/conversations/#{id}/status", nil, data_transform(data), @contact_v1_url)
293
+ end
294
+
295
+ ##
296
+ # === Get Conversation Participants.
297
+ # Update a conversation participants.
298
+ #
299
+ # ==== Parameters
300
+ # id:: (Integer) -- Conversation id.
301
+ # FIXME: This method doesn't locate conversation id to be updated.
302
+ def get_conversation_participants(id)
303
+ #TODO: Test if this method needs data in options.
304
+ return @client.raw("get", "/content/conversations/#{id}/participants", nil, nil, @contact_v1_url)
305
+ end
306
+
307
+ ##
308
+ # === Get Messages.
309
+ # Get a collection of messages.
310
+ #
311
+ # ==== Parameters
312
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
313
+ # FIXME: This method doesn't return data.
314
+ def get_messages(options = nil)
315
+ return @client.raw("get", "/content/messages", options, nil, @contact_v1_url)
316
+ end
317
+
318
+ ##
319
+ # === Get Message.
320
+ # Get a message info.
321
+ #
322
+ # ==== Parameters
323
+ # id:: (Integer) -- Message id.
324
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
325
+ # FIXME: This method doesn't return data.
326
+ def get_message(id, options = nil)
327
+ return @client.raw("get", "/content/messages/#{id}", options, nil, @contact_v1_url)
328
+ end
329
+
330
+ ##
331
+ # === Create Message.
332
+ # Create a message with data.
333
+ #
334
+ # ==== Parameters
335
+ # data:: (Hash) -- Data to be submited.
141
336
  #
142
337
  # ==== Example
143
- # data = {
144
- # "email": "email@example.com",
145
- # "password": "password",
146
- # "password_confirmation": "password",
147
- # "token": "644aa3aa0831d782cc42e42b11aedea9a2234389af4f429a8d96651295ecfa09"
338
+ # data = {
339
+ # "conversation_id": 3,
340
+ # "type": "text",
341
+ # "value": {
342
+ # "text": "Message Text"
343
+ # }
148
344
  # }
149
- # @mints_contact.reset_password(data)
150
- def reset_password(data)
151
- return @client.raw("post", "/contacts/reset-password", nil, data_transform(data))
345
+ # @data = @mints_contact.create_message(data)
346
+ def create_message(data)
347
+ return @client.raw("post", "/content/messages", nil, data_transform(data), @contact_v1_url)
152
348
  end
153
349
 
350
+ # Appointments
351
+
154
352
  ##
155
- # === OAuth Login.
156
- # Login a contact using oauth.
157
- def oauth_login(data)
158
- return @client.raw("post", "/contacts/oauth-login", nil, data)
353
+ # === Get Appointments.
354
+ # Get a collection of appointments.
355
+ #
356
+ # ==== Parameters
357
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
358
+ #
359
+ # ==== First Example
360
+ # @data = @mints_contact.get_appointments
361
+ #
362
+ # ==== Second Example
363
+ # options = {
364
+ # "fields": "id, created_at"
365
+ # }
366
+ # @data = @mints_contact.get_appointments(options)
367
+ def get_appointments(options = nil)
368
+ return @client.raw("get", "/contacts/appointments", options)
159
369
  end
160
370
 
161
371
  ##
162
- # === Me.
163
- # Get contact logged info.
372
+ # === Get Appointment.
373
+ # Get an appointment info.
374
+ #
375
+ # ==== Parameters
376
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
164
377
  #
165
378
  # ==== First Example
166
- # @mints_contact.me
379
+ # @data = @mints_contact.get_appointment(1)
167
380
  #
168
381
  # ==== Second Example
169
- # options = {
170
- # "attributes": true,
171
- # "taxonomies": true
172
- # }
173
- # @data = @mints_contact.me(options)
174
- def me(options = nil)
175
- return @client.raw("get", "/contacts/me", options)
382
+ # options = {
383
+ # "fields": "id, created_at"
384
+ # }
385
+ # @data = @mints_contact.get_appointment(1, options)
386
+ def get_appointment(id, options = nil)
387
+ return @client.raw("get", "/contacts/appointments/#{id}", options)
176
388
  end
177
389
 
178
390
  ##
179
- # === Status.
180
- # Get contact logged status.
391
+ # === Create Appointment.
392
+ # Create an appointment with data.
393
+ #
394
+ # ==== Parameters
395
+ # data:: (Hash) -- Data to be submited.
181
396
  #
182
397
  # ==== Example
183
- # @mints_contact.status
184
- def status
185
- return @client.raw("get", "/contacts/status")
398
+ # data = {
399
+ # "object_model": "products",
400
+ # "object_id": 1,
401
+ # "title": "New Appointment",
402
+ # "start": "2021-11-25T14:15:00+00:00",
403
+ # "end": "2022-01-01T13:00:00+00:00"
404
+ # }
405
+ # @data = @mints_contact.create_appointment(data)
406
+ def create_appointment(data)
407
+ return @client.raw("post", "/contacts/appointments", nil, data_transform(data))
186
408
  end
187
409
 
188
410
  ##
189
- # === Update.
190
- # Update logged contact attributes.
411
+ # === Update Appointment.
412
+ # Update an appointment info.
191
413
  #
192
- # ==== Parameters:
193
- # data:: (Hash) -- It's the data to update with a session active.
414
+ # ==== Parameters
415
+ # id:: (Integer) -- Appointment id.
416
+ # data:: (Hash) -- Data to be submited.
194
417
  #
195
418
  # ==== Example
196
- # @mints_contact.login("email@example.com", "password")
197
419
  # data = {
198
- # "given_name": "Given Name",
199
- # "last_name": "Last Name"
420
+ # "object_id": 2
200
421
  # }
201
- # @mints_contact.update(data)
202
- def update(data)
203
- return @client.raw("put", "/contacts/update", nil, data_transform(data))
422
+ # @data = @mints_contact.update_appointment(1, data)
423
+ def update_appointment(id, data)
424
+ return @client.raw("put", "/contacts/appointments/#{id}", nil, data_transform(data))
204
425
  end
205
426
 
206
427
  ##
207
- # === Register.
208
- # Register a contact.
428
+ # === Scheduled Appointments.
429
+ # Get a collection of appointments filtering by object_type, object_id and dates range.
209
430
  #
210
- # ==== Parameters:
211
- # data:: (Hash) -- It's the register data.
431
+ # ==== Parameters
432
+ # data:: (Hash) -- Data to be submited.
212
433
  #
213
434
  # ==== Example
214
435
  # data = {
215
- # "email": "email@example.com",
216
- # "given_name": "Given Name",
217
- # "last_name": "Last Name",
218
- # "password": "password"
436
+ # "object_model": "products",
437
+ # "object_id": 2,
438
+ # "start": "2021-11-25T14:15:00+00:00",
439
+ # "end": "2022-01-01T13:00:00+00:00"
219
440
  # }
220
- # @mints_contact.register(data);
221
- def register(data)
222
- return @client.raw("post", "/contacts/register", nil, data_transform(data))
441
+ # @data = @mints_contact.scheduled_appointments(data)
442
+ def scheduled_appointments(data)
443
+ return @client.raw("post", "/contacts/appointments/scheduled-appointments", nil, data_transform(data))
444
+ end
445
+
446
+ ##
447
+ # === Attach Invitee.
448
+ # Attach invitee to an appointment.
449
+ #
450
+ # ==== Parameters
451
+ # data:: (Hash) -- Data to be submited.
452
+ #
453
+ # ==== Example
454
+ # data = {
455
+ # "appointment_id": 1,
456
+ # "invitee_ids": 1
457
+ # }
458
+ # @data = @mints_contact.attach_invitee(data)
459
+ def attach_invitee(data)
460
+ return @client.raw("post", "/contacts/appointments/attach-invitee", nil, data_transform(data))
461
+ end
462
+
463
+ ##
464
+ # === Attach Follower.
465
+ # Attach follower to an appointment.
466
+ #
467
+ # ==== Parameters
468
+ # data:: (Hash) -- Data to be submited.
469
+ #
470
+ # ==== Example
471
+ # data = {
472
+ # "appointment_id": 1,
473
+ # "follower_ids": 1
474
+ # }
475
+ # @data = @mints_contact.attach_follower(data)
476
+ def attach_follower(data)
477
+ return @client.raw("post", "/contacts/appointments/attach-follower", nil, data_transform(data))
478
+ end
479
+
480
+ ##
481
+ # === Detach Invitee.
482
+ # Detach invitee from an appointment.
483
+ #
484
+ # ==== Parameters
485
+ # data:: (Hash) -- Data to be submited.
486
+ #
487
+ # ==== Example
488
+ # data = {
489
+ # "appointment_id": 1,
490
+ # "invitee_ids": 1
491
+ # }
492
+ # @data = @mints_contact.detach_invitee(data)
493
+ def detach_invitee(data)
494
+ return @client.raw("post", "/contacts/appointments/detach-invitee", nil, data_transform(data))
495
+ end
496
+
497
+ ##
498
+ # === Detach Follower.
499
+ # Detach follower from an appointment.
500
+ #
501
+ # ==== Parameters
502
+ # data:: (Hash) -- Data to be submited.
503
+ #
504
+ # ==== Example
505
+ # data = {
506
+ # "appointment_id": 1,
507
+ # "follower_ids": 1
508
+ # }
509
+ # @data = @mints_contact.detach_follower(data)
510
+ def detach_follower(data)
511
+ return @client.raw("post", "/contacts/appointments/detach-follower", nil, data_transform(data))
512
+ end
513
+
514
+ ##
515
+ # === Sync Invitee.
516
+ # Sync an invitee from an appointment.
517
+ #
518
+ # ==== Parameters
519
+ # data:: (Hash) -- Data to be submited.
520
+ #
521
+ # ==== Example
522
+ # data = {
523
+ # "appointment_id": 1,
524
+ # "invitee_ids": 1
525
+ # }
526
+ # @data = @mints_contact.sync_invitee(data)
527
+ def sync_invitee(data)
528
+ return @client.raw("post", "/contacts/appointments/sync-invitee", nil, data_transform(data))
529
+ end
530
+
531
+ ##
532
+ # === Sync Follower.
533
+ # Sync a follower from an appointment.
534
+ #
535
+ # ==== Parameters
536
+ # data:: (Hash) -- Data to be submited.
537
+ #
538
+ # ==== Example
539
+ # data = {
540
+ # "appointment_id": 1,
541
+ # "follower_ids": 1
542
+ # }
543
+ # @data = @mints_contact.sync_follower(data)
544
+ def sync_follower(data)
545
+ return @client.raw("post", "/contacts/appointments/sync-follower", nil, data_transform(data))
546
+ end
547
+
548
+ ##
549
+ # === Get Orders.
550
+ # Get a collection of orders.
551
+ #
552
+ # ==== Parameters
553
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
554
+ # use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
555
+ #
556
+ # ==== First Example
557
+ # @data = @mints_pub.get_orders
558
+ #
559
+ # ==== Second Example
560
+ # options = { "fields": "title" }
561
+ # @data = @mints_pub.get_orders(options)
562
+ #
563
+ # ==== Third Example
564
+ # options = { "fields": "title" }
565
+ # @data = @mints_pub.get_orders(options, false)
566
+ def get_orders(options = nil, use_post = true)
567
+ if use_post
568
+ return @client.raw("post", "/ecommerce/orders/query", options, nil, @contact_v1_url)
569
+ else
570
+ return @client.raw("get", "/ecommerce/orders", options, nil, @contact_v1_url)
571
+ end
572
+ end
573
+
574
+ ##
575
+ # === Get Order.
576
+ # Get an order info.
577
+ #
578
+ # ==== Parameters
579
+ # id:: (Integer) -- Order id.
580
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
581
+ #
582
+ # ==== First Example
583
+ # @data = @mints_pub.get_product(25)
584
+ #
585
+ # ==== Second Example
586
+ # options = {
587
+ # "fields": "title"
588
+ # }
589
+ # @data = @mints_pub.get_product(25, options)
590
+ def get_order(id, options = nil)
591
+ return @client.raw("get", "/ecommerce/orders/#{id}", options, nil, @contact_v1_url)
592
+ end
593
+
594
+ ##
595
+ # === Create Order.
596
+ # Create a order with data.
597
+ #
598
+ # ==== Parameters
599
+ # data:: (Hash) -- Data to be submited.
600
+ #
601
+ # ==== Example
602
+ # data = {
603
+ # "order_template_id": 1,
604
+ # "order_status_id": 1,
605
+ # "sales_channel_id": 1
606
+ # }
607
+ # @data = @mints_pub.create_order(data)
608
+ def create_order(data)
609
+ return @client.raw("post", "/ecommerce/orders", nil, data_transform(data), @contact_v1_url)
610
+ end
611
+
612
+ ##
613
+ # === Update Order.
614
+ # Update an order info.
615
+ #
616
+ # ==== Parameters
617
+ # id:: (Integer) -- Order Id
618
+ # data:: (Hash) -- Data to be submited.
619
+ # FIXME: This method doesnt update an order.
620
+ def update_order(id, data)
621
+ return @client.raw("put", "/ecommerce/orders/#{id}", nil, data_transform(data), @contact_v1_url)
622
+ end
623
+
624
+ #TODO: No tested
625
+ # === Detach Order Item From Order Item Group.
626
+ # Detach an order item from an order item group.
627
+ #
628
+ # ==== Parameters
629
+ # orderItemId:: (Integer) -- Order item id.
630
+ # groupId:: (Integer) -- Order items group id.
631
+ #
632
+ def detach_order_item_from_order_item_group(orderItemId, groupId)
633
+ return @client.raw("put", "/ecommerce/order-items/detach/#{orderItemId}/order-items-groups/#{groupId}", nil, nil, @contact_v1_url)
634
+ end
635
+
636
+ #TODO: No tested
637
+ # === Update Order Item From Order Item Group.
638
+ # Update an order item data from an order item group.
639
+ #
640
+ # ==== Parameters
641
+ # orderItemId:: (Integer) -- Order item id.
642
+ # groupId:: (Integer) -- Order items group id.
643
+ #
644
+ def update_order_item_from_order_item_group(orderItemId, groupId, data)
645
+ return @client.raw("put", "/ecommerce/order-items/update/#{orderItemId}/order-items-groups/#{groupId}", nil, data_transform(data), @contact_v1_url)
646
+ end
647
+
648
+ ##
649
+ # === Get My Shopping Cart.
650
+ # Get a collection of items in the shopping cart.
651
+ #
652
+ # ==== Example
653
+ # @data = @mints_contact.get_my_shopping_cart
654
+ # FIXME: This method returns a nil data.
655
+ def get_my_shopping_cart
656
+ return @client.raw("get", "/ecommerce/my-shopping-cart", nil, nil, @contact_v1_url)
657
+ end
658
+
659
+ ##
660
+ # === Add Item To Shopping Cart.
661
+ # Add an item into a shopping cart.
662
+ #
663
+ # ==== Parameters
664
+ # data:: (Hash) -- Data to be submited.
665
+ #
666
+ # ==== Example
667
+ # data = {
668
+ # "quantity": 1,
669
+ # "sku_id": 1,
670
+ # "price_list_id": 1
671
+ # }
672
+ # @data = @mints_contact.add_item_to_shopping_cart(data)
673
+ def add_item_to_shopping_cart(data)
674
+ return @client.raw("post", "/ecommerce/shopping-cart", nil, data_transform(data), @contact_v1_url)
675
+ end
676
+
677
+ ##
678
+ # === Get Order Items.
679
+ # Get a collection of order items.
680
+ #TODO: Find a way to show order items.
681
+ def get_order_items(options = nil)
682
+ return @client.raw("get", "/ecommerce/order-items", options, nil, @contact_v1_url)
683
+ end
684
+
685
+ ##
686
+ # === Get Order Item.
687
+ # Get an order item info.
688
+ #TODO: Find a way to show order items.
689
+ def get_order_item(id, options = nil)
690
+ return @client.raw("get", "/ecommerce/order-items/#{id}", options, nil, @contact_v1_url)
691
+ end
692
+
693
+ ##
694
+ # === Get Order Item Groups.
695
+ # Get a collection of order item groups.
696
+ #
697
+ # ==== Parameters
698
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
699
+ #
700
+ # ==== First Example
701
+ # @data = @mints_contact.get_order_item_groups
702
+ #
703
+ # ==== Second Example
704
+ # options = {
705
+ # "fields": "id"
706
+ # }
707
+ # @data = @mints_contact.get_order_item_groups(options)
708
+ def get_order_item_groups(options = nil)
709
+ return @client.raw("get", "/ecommerce/order-items-groups", options, nil, @contact_v1_url)
710
+ end
711
+
712
+ ##
713
+ # === Get Order Item Group.
714
+ # Get an order item group info.
715
+ #
716
+ # ==== Parameters
717
+ # id:: (Integer) -- Order Item Group Id.
718
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
719
+ #
720
+ # ==== First Example
721
+ # @data = @mints_contact.get_order_item_group(130)
722
+ #
723
+ # ==== Second Example
724
+ # options = {
725
+ # "fields": "id"
726
+ # }
727
+ # @data = @mints_contact.get_order_item_group(130, options)
728
+ def get_order_item_group(id, options = nil)
729
+ return @client.raw("get", "/ecommerce/order-items-groups/#{id}", options, nil, @contact_v1_url)
730
+ end
731
+
732
+ ##
733
+ # === Create Order Item Group.
734
+ # Create an order item group with data if you are related to that order.
735
+ #
736
+ # ==== Parameters
737
+ # data:: (Hash) -- Data to be submited.
738
+ #
739
+ # ==== First Example
740
+ # data = {
741
+ # "name": "New Order Item Group",
742
+ # "quantity": 1,
743
+ # "order_id": 1,
744
+ # "on_sale_price": 100
745
+ # }
746
+ # @data = @mints_contact.create_order_item_group(data)
747
+ #
748
+ # ==== Second Example
749
+ # data = {
750
+ # "name": "",
751
+ # "quantity": 1,
752
+ # "order_id": 1,
753
+ # "sku_id": 1
754
+ # }
755
+ # @data = @mints_contact.create_order_item_group(data)
756
+ def create_order_item_group(data)
757
+ return @client.raw("post", "/ecommerce/order-items-groups", nil, data_transform(data), @contact_v1_url)
758
+ end
759
+
760
+ ##
761
+ # === Update Order Item Group.
762
+ # Update an order item group info if you are related to that order.
763
+ #
764
+ # ==== Parameters
765
+ # id:: (Integer) -- Order Item Group Id.
766
+ # data:: (Hash) -- Data to be submited.
767
+ #
768
+ # ==== First Example
769
+ # data = {
770
+ # "name": "New Order Item Group Name Updated"
771
+ # }
772
+ # @data = @mints_contact.update_order_item_group(130, data)
773
+ def update_order_item_group(id, data)
774
+ return @client.raw("put", "/ecommerce/order-items-groups/#{id}", nil, data_transform(data), @contact_v1_url)
775
+ end
776
+
777
+ ##
778
+ # === Delete Order Item Group.
779
+ # Delete an order item group.
780
+ # FIXME: This method doesn't work. Throw no action error.
781
+ def delete_order_item_group(id)
782
+ return @client.raw("delete", "/ecommerce/order-items-groups/#{id}", nil, nil, @contact_v1_url)
223
783
  end
224
784
 
225
785
  private