mints 0.0.29 → 0.0.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/contact/ecommerce/ecommerce.rb +2 -0
- data/lib/contact/ecommerce/orders.rb +0 -1
- data/lib/contact/ecommerce/vouchers.rb +18 -0
- data/lib/errors.rb +1 -1
- data/lib/mints/helpers/contact_auth_helper.rb +2 -2
- data/lib/pub/config/attributes.rb +13 -0
- data/lib/pub/config/config.rb +15 -0
- data/lib/pub/config/public_folders.rb +51 -0
- data/lib/pub/config/tags.rb +42 -0
- data/lib/pub/config/taxonomies.rb +49 -0
- data/lib/pub/content/assets.rb +16 -0
- data/lib/pub/content/content.rb +22 -0
- data/lib/pub/content/content_bundles.rb +40 -0
- data/lib/pub/content/content_instance_versions.rb +56 -0
- data/lib/pub/content/content_instances.rb +37 -0
- data/lib/pub/content/forms.rb +47 -0
- data/lib/pub/content/stories.rb +44 -0
- data/lib/pub/content/story_versions.rb +46 -0
- data/lib/pub/ecommerce/ecommerce.rb +14 -0
- data/lib/pub/ecommerce/locations.rb +25 -0
- data/lib/pub/ecommerce/orders.rb +31 -0
- data/lib/pub/ecommerce/products.rb +45 -0
- data/lib/pub.rb +6 -427
- data/lib/user/ecommerce/ecommerce.rb +2 -0
- data/lib/user/ecommerce/locations.rb +2 -2
- data/lib/user/ecommerce/vouchers.rb +90 -0
- metadata +21 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a9a445aee572bf7d3208545a3fed7fef5979e0151d7bdacde92b060e1142d6e
|
4
|
+
data.tar.gz: 14f88f53ccff619b7e3980c0ea606ce05e71461129885f47f7c59dc4a88cb5c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 895fed64e6d46023b5e34c2a26fb751d10ea8f8115c64648b130cde117da07c9fa59cbfc5a343a0850641d9ee8fbcda42addd9583681d4da7135beb2d0e51e4a
|
7
|
+
data.tar.gz: 9ca24a98b56455221ddb5f56a143debd9f15ecd979a019970d2915bf15ee3a18d2c70c83aa4a94a9f36aad1fee81b84cee905f76b4f793ab9eba59de57c28ccf
|
@@ -3,10 +3,12 @@
|
|
3
3
|
require_relative './order_items_groups'
|
4
4
|
require_relative './order_items'
|
5
5
|
require_relative './orders'
|
6
|
+
require_relative './vouchers'
|
6
7
|
|
7
8
|
module Ecommerce
|
8
9
|
include OrderItemsGroups
|
9
10
|
include OrderItems
|
10
11
|
include Orders
|
12
|
+
include Vouchers
|
11
13
|
|
12
14
|
end
|
@@ -108,7 +108,6 @@ module Orders
|
|
108
108
|
#
|
109
109
|
# ==== Example
|
110
110
|
# @data = @mints_contact.get_my_shopping_cart
|
111
|
-
# FIXME: This method returns a nil data.
|
112
111
|
def get_my_shopping_cart(options = nil)
|
113
112
|
@client.raw('get', '/ecommerce/my-shopping-cart', options, nil, @contact_v1_url)
|
114
113
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Vouchers
|
4
|
+
##
|
5
|
+
# === Apply voucher.
|
6
|
+
# Apply voucher code to the existing order, only applies to sale orders.
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# order_id:: (Integer) -- Order id.
|
10
|
+
# data:: (Hash) -- Data to be submitted.
|
11
|
+
#
|
12
|
+
# ==== Example
|
13
|
+
# data = { description: 'This is the transaction description', voucher_code: 'XAZWQ12MP' }
|
14
|
+
# @data = @mints_contact.apply_voucher(1, data)
|
15
|
+
def apply_voucher(order_id, data)
|
16
|
+
@client.raw('post', "/ecommerce/orders/#{order_id}/voucher", nil, data_transform(data))
|
17
|
+
end
|
18
|
+
end
|
data/lib/errors.rb
CHANGED
@@ -43,9 +43,9 @@ module ContactAuthHelper
|
|
43
43
|
def mints_contact_logout
|
44
44
|
# Logout from mints
|
45
45
|
@mints_contact.logout
|
46
|
-
# Delete
|
46
|
+
# Delete session token and keep the contact token id
|
47
|
+
# Never delete the mints_contact_id cookie to avoid the creation of ghosts
|
47
48
|
cookies.delete(:mints_contact_session_token)
|
48
|
-
cookies.delete(:mints_contact_id)
|
49
49
|
@contact_token = nil
|
50
50
|
end
|
51
51
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Attributes
|
4
|
+
##
|
5
|
+
# === Get Attributes.
|
6
|
+
# Get a collection of attributes.
|
7
|
+
#
|
8
|
+
# ==== Example
|
9
|
+
# @data = @mints_pub.get_attributes
|
10
|
+
def get_attributes
|
11
|
+
@client.raw('get', '/config/attributes')
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
### V1/CONFIG ###
|
4
|
+
|
5
|
+
require_relative './attributes'
|
6
|
+
require_relative './public_folders'
|
7
|
+
require_relative './tags'
|
8
|
+
require_relative './taxonomies'
|
9
|
+
|
10
|
+
module Config
|
11
|
+
include Attributes
|
12
|
+
include PublicFolders
|
13
|
+
include Tags
|
14
|
+
include Taxonomies
|
15
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PublicFolders
|
4
|
+
##
|
5
|
+
# === Get Public Folders.
|
6
|
+
# Get a collection of public folders.
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
10
|
+
#
|
11
|
+
# ==== First Example
|
12
|
+
# options = {
|
13
|
+
# object_type: "products"
|
14
|
+
# }
|
15
|
+
# @data = @mints_pub.get_public_folders(options)
|
16
|
+
#
|
17
|
+
# ==== Second Example
|
18
|
+
# options = {
|
19
|
+
# object_type: "products",
|
20
|
+
# fields: "id",
|
21
|
+
# sort: "-id"
|
22
|
+
# }
|
23
|
+
# @data = @mints_pub.get_public_folders(options)
|
24
|
+
def get_public_folders(options = nil)
|
25
|
+
@client.raw('get', '/config/public-folders', options)
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# === Get Public Folder.
|
30
|
+
# Get a public folder info.
|
31
|
+
#
|
32
|
+
# ==== Parameters
|
33
|
+
# slug:: (String) -- It's the string identifier generated by Mints.
|
34
|
+
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
35
|
+
#
|
36
|
+
# ==== First Example
|
37
|
+
# options = {
|
38
|
+
# object_type: "products"
|
39
|
+
# }
|
40
|
+
# @data = @mints_pub.get_public_folder('yellow', options)
|
41
|
+
#
|
42
|
+
# ==== Second Example
|
43
|
+
# options = {
|
44
|
+
# object_type: "products",
|
45
|
+
# fields: 'id, title'
|
46
|
+
# }
|
47
|
+
# @data = @mints_pub.get_public_folder('yellow', options)
|
48
|
+
def get_public_folder(slug, options)
|
49
|
+
@client.raw('get', "/config/public-folders/#{slug}", options)
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tags
|
4
|
+
##
|
5
|
+
# === Get Tags.
|
6
|
+
# Get a collection of tags.
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
10
|
+
#
|
11
|
+
# ==== First Example
|
12
|
+
# @data = @mints_pub.get_tags
|
13
|
+
#
|
14
|
+
# ==== Second Example
|
15
|
+
# options = {
|
16
|
+
# fields: "id, tag"
|
17
|
+
# }
|
18
|
+
# @data = @mints_pub.get_tags(options)
|
19
|
+
def get_tags(options = nil)
|
20
|
+
@client.raw('get', '/config/tags', options)
|
21
|
+
end
|
22
|
+
|
23
|
+
##
|
24
|
+
# === Get Tag.
|
25
|
+
# Get a single tag.
|
26
|
+
#
|
27
|
+
# ==== Parameters
|
28
|
+
# slug:: (String) -- It's the string identifier generated by Mints.
|
29
|
+
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
30
|
+
#
|
31
|
+
# ==== First Example
|
32
|
+
# @data = @mints_pub.get_tag("tag_slug")
|
33
|
+
#
|
34
|
+
# ==== Second Example
|
35
|
+
# options = {
|
36
|
+
# fields: "id, tag"
|
37
|
+
# }
|
38
|
+
# @data = @mints_pub.get_tag("tag-example", options)
|
39
|
+
def get_tag(slug, options = nil)
|
40
|
+
@client.raw('get', "/config/tags/#{slug}", options)
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Taxonomies
|
4
|
+
##
|
5
|
+
# === Get Taxonomies.
|
6
|
+
# Get a collection of taxonomies.
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
10
|
+
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
11
|
+
#
|
12
|
+
# ==== First Example
|
13
|
+
# @data = @mints_pub.get_taxonomies
|
14
|
+
#
|
15
|
+
# ==== Second Example
|
16
|
+
# options = {
|
17
|
+
# fields: 'id, title'
|
18
|
+
# }
|
19
|
+
# @data = @mints_pub.get_taxonomies(options)
|
20
|
+
#
|
21
|
+
# ==== Third Example
|
22
|
+
# options = {
|
23
|
+
# fields: 'id, title'
|
24
|
+
# }
|
25
|
+
# @data = @mints_pub.get_taxonomies(options, false)
|
26
|
+
def get_taxonomies(options = nil, use_post = true)
|
27
|
+
get_query_results('/config/taxonomies', options, use_post)
|
28
|
+
end
|
29
|
+
|
30
|
+
##
|
31
|
+
# === Get Taxonomy.
|
32
|
+
# Get a single taxonomy.
|
33
|
+
#
|
34
|
+
# ==== Parameters
|
35
|
+
# slug:: (String) -- It's the string identifier generated by Mints.
|
36
|
+
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
37
|
+
#
|
38
|
+
# ==== First Example
|
39
|
+
# @data = @mints_pub.get_taxonomy('taxonomy_slug')
|
40
|
+
#
|
41
|
+
# ==== Second Example
|
42
|
+
# options = {
|
43
|
+
# fields: 'title'
|
44
|
+
# }
|
45
|
+
# @data = @mints_pub.get_taxonomy('taxonomy_slug', options)
|
46
|
+
def get_taxonomy(slug, options = nil)
|
47
|
+
@client.raw('get', "/config/taxonomies/#{slug}", options)
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Assets
|
4
|
+
##
|
5
|
+
# === Get Asset Info.
|
6
|
+
# Get a description of an Asset.
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# slug:: (String) -- It's the string identifier of the asset.
|
10
|
+
#
|
11
|
+
# ==== Example
|
12
|
+
# @data = @mints_pub.get_asset_info("asset_slug")
|
13
|
+
def get_asset_info(slug)
|
14
|
+
@client.raw('get', "/content/asset-info/#{slug}")
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
### V1/CONTENT ###
|
4
|
+
|
5
|
+
require_relative './assets'
|
6
|
+
require_relative './content_bundles'
|
7
|
+
require_relative './content_instance_versions'
|
8
|
+
require_relative './content_instances'
|
9
|
+
require_relative './forms'
|
10
|
+
require_relative './stories'
|
11
|
+
require_relative './story_versions'
|
12
|
+
|
13
|
+
module Content
|
14
|
+
include Assets
|
15
|
+
include ContentBundles
|
16
|
+
include ContentInstanceVersions
|
17
|
+
include ContentInstances
|
18
|
+
include Forms
|
19
|
+
include Stories
|
20
|
+
include StoryVersions
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ContentBundles
|
4
|
+
##
|
5
|
+
# === Get Content Pages.
|
6
|
+
# Get all content pages.
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
10
|
+
def get_content_bundles(options = nil)
|
11
|
+
@client.raw('get', '/content/content-bundles', options)
|
12
|
+
end
|
13
|
+
|
14
|
+
##
|
15
|
+
# === Get Content Page.
|
16
|
+
# Get a single content page.
|
17
|
+
#
|
18
|
+
# ==== Parameters
|
19
|
+
# slug:: (String) -- It's the string identifier generated by Mints.
|
20
|
+
#
|
21
|
+
# ==== Example
|
22
|
+
# @data = @mints_pub.get_content_page("test-page")
|
23
|
+
def get_content_page(slug, options = nil)
|
24
|
+
warn '[DEPRECATED] The get_content_page method is deprecated and will be removed in the future, use get_content_bundle instead'
|
25
|
+
@client.raw('get', "/content/content-pages/#{slug}", options)
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# === Get Content Bundle.
|
30
|
+
# Get a single content bundle.
|
31
|
+
#
|
32
|
+
# ==== Parameters
|
33
|
+
# slug:: (String) -- It's the string identifier generated by Mints.
|
34
|
+
#
|
35
|
+
# ==== Example
|
36
|
+
# @data = @mints_pub.get_content_bundle("test-page")
|
37
|
+
def get_content_bundle(slug, options = nil)
|
38
|
+
@client.raw('get', "/content/content-bundles/#{slug}", options)
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ContentInstanceVersions
|
4
|
+
##
|
5
|
+
# === Get Content Instance Versions.
|
6
|
+
# Get a collection of content instance versions.
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
10
|
+
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
11
|
+
#
|
12
|
+
# ==== First Example
|
13
|
+
# @data = @mints_pub.get_content_instance_versions
|
14
|
+
#
|
15
|
+
# ==== Second Example
|
16
|
+
# options = {
|
17
|
+
# fields: 'id, title'
|
18
|
+
# }
|
19
|
+
# @data = @mints_pub.get_content_instance_versions(options)
|
20
|
+
#
|
21
|
+
# ==== Third Example
|
22
|
+
# options = {
|
23
|
+
# fields: 'id, title'
|
24
|
+
# }
|
25
|
+
# @data = @mints_pub.get_content_instance_versions(options, false)
|
26
|
+
def get_content_instance_versions(options = nil)
|
27
|
+
unless options&.[](:template) || options&.[]('template')
|
28
|
+
raise Mints::Errors::DynamicError.new(
|
29
|
+
self,
|
30
|
+
'Error 422 | Missing required fields, see the details for more information',
|
31
|
+
'Add the template option, example { template: slug }',
|
32
|
+
422,
|
33
|
+
{ template: ['The template option is required'] }
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
@client.raw('get', '/content/content-instance-versions', options)
|
38
|
+
end
|
39
|
+
|
40
|
+
##
|
41
|
+
# === Get Content Instance Version.
|
42
|
+
# Get a single content instance version.
|
43
|
+
#
|
44
|
+
# ==== Parameters
|
45
|
+
# slug:: (String) -- It's the string identifier generated by Mints.
|
46
|
+
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
47
|
+
#
|
48
|
+
# ==== First Example
|
49
|
+
# @data = @mints_pub.get_content_instance_version('content_instance_version_slug')
|
50
|
+
#
|
51
|
+
# ==== Second Example
|
52
|
+
# @data = @mints_pub.get_content_instance_version('content_instance_version_slug', options)
|
53
|
+
def get_content_instance_version(slug, options = nil)
|
54
|
+
@client.raw('get', "/content/content-instance-versions/#{slug}", options)
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module ContentInstances
|
2
|
+
##
|
3
|
+
# === Get Content Instances.
|
4
|
+
# Get a collection of content instances. _Note:_ Options must be specified.
|
5
|
+
#
|
6
|
+
# ==== Parameters
|
7
|
+
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
8
|
+
#
|
9
|
+
# ==== First Example
|
10
|
+
# options = {
|
11
|
+
# "template": "content_instance_template_slug"
|
12
|
+
# }
|
13
|
+
# @data = @mints_pub.get_content_instances(options)
|
14
|
+
#
|
15
|
+
# ==== Second Example
|
16
|
+
# options = {
|
17
|
+
# "template": "content_instance_template_slug",
|
18
|
+
# sort: "-id"
|
19
|
+
# }
|
20
|
+
# @data = @mints_pub.get_content_instances(options)
|
21
|
+
def get_content_instances(options = nil)
|
22
|
+
@client.raw('get', '/content/content-instances', options)
|
23
|
+
end
|
24
|
+
|
25
|
+
##
|
26
|
+
# === Get Content Instance.
|
27
|
+
# Get a single content instance.
|
28
|
+
#
|
29
|
+
# ==== Parameters
|
30
|
+
# slug:: (String) -- It's the string identifier generated by Mints.
|
31
|
+
#
|
32
|
+
# ==== Example
|
33
|
+
# @data = @mints_pub.get_content_instance("content_instance_slug")
|
34
|
+
def get_content_instance(slug)
|
35
|
+
@client.raw('get', "/content/content-instances/#{slug}")
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Forms
|
4
|
+
##
|
5
|
+
# === Get Forms.
|
6
|
+
# Get a collection of forms.
|
7
|
+
#
|
8
|
+
# ==== Example
|
9
|
+
# @data = @mints_pub.get_forms
|
10
|
+
def get_forms(options = nil)
|
11
|
+
@client.raw('get', '/content/forms', options)
|
12
|
+
end
|
13
|
+
|
14
|
+
##
|
15
|
+
# === Get Form.
|
16
|
+
# Get a single form.
|
17
|
+
#
|
18
|
+
# ==== Parameters
|
19
|
+
# slug:: (String) -- It's the string identifier generated by Mints.
|
20
|
+
#
|
21
|
+
# ==== Example
|
22
|
+
# @data = @mints_pub.get_form("form_slug")
|
23
|
+
def get_form(slug, options = nil)
|
24
|
+
@client.raw('get', "/content/forms/#{slug}", options)
|
25
|
+
end
|
26
|
+
|
27
|
+
##
|
28
|
+
# === Submit Form.
|
29
|
+
# Submit a form with data.
|
30
|
+
#
|
31
|
+
# ==== Parameters
|
32
|
+
# data:: (Hash) -- Data to be submitted.
|
33
|
+
#
|
34
|
+
# ==== Example
|
35
|
+
# data = {
|
36
|
+
# 'form_slug': 'form_slug',
|
37
|
+
# 'email': 'email@example.com',
|
38
|
+
# 'given_name': 'given_name',
|
39
|
+
# 'f1': 'Field 1 answer',
|
40
|
+
# 'f2': 'Field 2 answer',
|
41
|
+
# 'f3': 'Field 3 answer'
|
42
|
+
# }
|
43
|
+
# @data = @mints_pub.submit_form(data)
|
44
|
+
def submit_form(data)
|
45
|
+
@client.raw('post', '/content/forms/submit', nil, data_transform(data))
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stories
|
4
|
+
##
|
5
|
+
# === Get Stories.
|
6
|
+
# Get a collection of stories.
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
10
|
+
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
11
|
+
#
|
12
|
+
# ==== First Example
|
13
|
+
# @data = @mints_pub.get_stories
|
14
|
+
#
|
15
|
+
# ==== Second Example
|
16
|
+
# options = { fields: 'id, slug' }
|
17
|
+
# @data = @mints_pub.get_stories(options)
|
18
|
+
#
|
19
|
+
# ==== Third Example
|
20
|
+
# options = {
|
21
|
+
# fields: 'id, slug'
|
22
|
+
# }
|
23
|
+
# @data = @mints_pub.get_stories(options, false)
|
24
|
+
def get_stories(options = nil, use_post = true)
|
25
|
+
get_query_results('/content/stories', options, use_post)
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# === Get Story.
|
30
|
+
# Get a single story.
|
31
|
+
#
|
32
|
+
# ==== Parameters
|
33
|
+
# slug:: (String) -- It's the string identifier generated by Mints.
|
34
|
+
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
35
|
+
#
|
36
|
+
# ==== First Example
|
37
|
+
# @data = @mints_pub.get_story("story_slug")
|
38
|
+
#
|
39
|
+
# ==== Second Example
|
40
|
+
# @data = @mints_pub.get_story("story_slug", options.to_json)
|
41
|
+
def get_story(slug, options = nil)
|
42
|
+
@client.raw('get', "/content/stories/#{slug}", options)
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module StoryVersions
|
4
|
+
##
|
5
|
+
# === Get Story Versions.
|
6
|
+
# Get a collection of story version.
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
10
|
+
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
11
|
+
#
|
12
|
+
# ==== First Example
|
13
|
+
# @data = @mints_pub.get_story_versions
|
14
|
+
#
|
15
|
+
# ==== Second Example
|
16
|
+
# options = {
|
17
|
+
# fields: 'id, title'
|
18
|
+
# }
|
19
|
+
# @data = @mints_pub.get_story_versions(options)
|
20
|
+
#
|
21
|
+
# ==== Third Example
|
22
|
+
# options = {
|
23
|
+
# fields: 'id, title'
|
24
|
+
# }
|
25
|
+
# @data = @mints_pub.get_story_versions(options, false)
|
26
|
+
def get_story_versions(options = nil, use_post = true)
|
27
|
+
get_query_results('/content/story-versions', options, use_post)
|
28
|
+
end
|
29
|
+
|
30
|
+
##
|
31
|
+
# === Get Story Version.
|
32
|
+
# Get a single story version.
|
33
|
+
#
|
34
|
+
# ==== Parameters
|
35
|
+
# slug:: (String) -- It's the string identifier generated by Mints.
|
36
|
+
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
37
|
+
#
|
38
|
+
# ==== First Example
|
39
|
+
# @data = @mints_pub.get_story_version('story_slug')
|
40
|
+
#
|
41
|
+
# ==== Second Example
|
42
|
+
# @data = @mints_pub.get_story_version('story_slug', options)
|
43
|
+
def get_story_version(slug, options = nil)
|
44
|
+
@client.raw('get', "/content/story-versions/#{slug}", options)
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Locations
|
4
|
+
##
|
5
|
+
# === Get Locations.
|
6
|
+
# Get all locations.
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
10
|
+
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
11
|
+
#
|
12
|
+
# ==== First Example
|
13
|
+
# @data = @mints_pub.get_locations
|
14
|
+
#
|
15
|
+
# ==== Second Example
|
16
|
+
# options = { fields: "title" }
|
17
|
+
# @data = @mints_pub.get_locations(options)
|
18
|
+
#
|
19
|
+
# ==== Third Example
|
20
|
+
# options = { fields: "title" }
|
21
|
+
# @data = @mints_pub.get_locations(options, false)
|
22
|
+
def get_locations(options = nil, use_post = true)
|
23
|
+
get_query_results('/ecommerce/locations', options, use_post)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Orders
|
4
|
+
##
|
5
|
+
# === Get My Shopping Cart.
|
6
|
+
# Get a collection of items in the shopping cart.
|
7
|
+
#
|
8
|
+
# ==== Example
|
9
|
+
# @data = @mints_ pub.get_my_shopping_cart
|
10
|
+
def get_my_shopping_cart(options = nil)
|
11
|
+
@client.raw('get', '/ecommerce/my-shopping-cart', options, nil)
|
12
|
+
end
|
13
|
+
|
14
|
+
##
|
15
|
+
# === Add Item To Shopping Cart.
|
16
|
+
# Add an item into a shopping cart.
|
17
|
+
#
|
18
|
+
# ==== Parameters
|
19
|
+
# data:: (Hash) -- Data to be submitted.
|
20
|
+
#
|
21
|
+
# ==== Example
|
22
|
+
# data = {
|
23
|
+
# quantity: 1,
|
24
|
+
# sku_id: 1,
|
25
|
+
# price_list_id: 1
|
26
|
+
# }
|
27
|
+
# @data = @mints_ pub.add_item_to_shopping_cart(data)
|
28
|
+
def add_item_to_shopping_cart(data, options = nil)
|
29
|
+
@client.raw('post', '/ecommerce/shopping-cart', options, data_transform(data))
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Products
|
4
|
+
##
|
5
|
+
# === Get Products.
|
6
|
+
# Get a collection of products.
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
10
|
+
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
11
|
+
#
|
12
|
+
# ==== First Example
|
13
|
+
# @data = @mints_pub.get_products
|
14
|
+
#
|
15
|
+
# ==== Second Example
|
16
|
+
# options = { fields: "title" }
|
17
|
+
# @data = @mints_pub.get_products(options)
|
18
|
+
#
|
19
|
+
# ==== Third Example
|
20
|
+
# options = { fields: "title" }
|
21
|
+
# @data = @mints_pub.get_products(options, false)
|
22
|
+
def get_products(options = nil, use_post = true)
|
23
|
+
get_query_results('/ecommerce/products', options, use_post)
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# === Get Product.
|
28
|
+
# Get a single product.
|
29
|
+
#
|
30
|
+
# ==== Parameters
|
31
|
+
# slug:: (String) -- It's the string identifier generated by Mints.
|
32
|
+
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
33
|
+
#
|
34
|
+
# ==== First Example
|
35
|
+
# @data = @mints_pub.get_product("product_slug")
|
36
|
+
#
|
37
|
+
# ==== Second Example
|
38
|
+
# options = {
|
39
|
+
# fields: 'id, slug'
|
40
|
+
# }
|
41
|
+
# @data = @mints_pub.get_product("lego-set", options)
|
42
|
+
def get_product(slug, options = nil)
|
43
|
+
@client.raw('get', "/ecommerce/products/#{slug}", options)
|
44
|
+
end
|
45
|
+
end
|
data/lib/pub.rb
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
require 'yaml'
|
4
4
|
require_relative './client'
|
5
5
|
require_relative './mints/helpers/mints_helper'
|
6
|
+
require_relative './pub/content/content'
|
7
|
+
require_relative './pub/ecommerce/ecommerce'
|
8
|
+
require_relative './pub/config/config'
|
6
9
|
|
7
10
|
module Mints
|
8
11
|
##
|
@@ -61,6 +64,9 @@ module Mints
|
|
61
64
|
attr_reader :client
|
62
65
|
|
63
66
|
include MintsHelper
|
67
|
+
include Content
|
68
|
+
include Ecommerce
|
69
|
+
include Config
|
64
70
|
|
65
71
|
##
|
66
72
|
# === Initialize.
|
@@ -118,433 +124,6 @@ module Mints
|
|
118
124
|
@client.raw('get', "/register-visit-timer?visit=#{visit}&time=#{time}")
|
119
125
|
end
|
120
126
|
|
121
|
-
### V1/CONTENT ###
|
122
|
-
|
123
|
-
##
|
124
|
-
# === Get Asset Info.
|
125
|
-
# Get a description of an Asset.
|
126
|
-
#
|
127
|
-
# ==== Parameters
|
128
|
-
# slug:: (String) -- It's the string identifier of the asset.
|
129
|
-
#
|
130
|
-
# ==== Example
|
131
|
-
# @data = @mints_pub.get_asset_info("asset_slug")
|
132
|
-
def get_asset_info(slug)
|
133
|
-
@client.raw('get', "/content/asset-info/#{slug}")
|
134
|
-
end
|
135
|
-
|
136
|
-
##
|
137
|
-
# === Get Stories.
|
138
|
-
# Get a collection of stories.
|
139
|
-
#
|
140
|
-
# ==== Parameters
|
141
|
-
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
142
|
-
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
143
|
-
#
|
144
|
-
# ==== First Example
|
145
|
-
# @data = @mints_pub.get_stories
|
146
|
-
#
|
147
|
-
# ==== Second Example
|
148
|
-
# options = { fields: 'id, slug' }
|
149
|
-
# @data = @mints_pub.get_stories(options)
|
150
|
-
#
|
151
|
-
# ==== Third Example
|
152
|
-
# options = {
|
153
|
-
# fields: 'id, slug'
|
154
|
-
# }
|
155
|
-
# @data = @mints_pub.get_stories(options, false)
|
156
|
-
def get_stories(options = nil, use_post = true)
|
157
|
-
get_query_results('/content/stories', options, use_post)
|
158
|
-
end
|
159
|
-
|
160
|
-
##
|
161
|
-
# === Get Story.
|
162
|
-
# Get a single story.
|
163
|
-
#
|
164
|
-
# ==== Parameters
|
165
|
-
# slug:: (String) -- It's the string identifier generated by Mints.
|
166
|
-
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
167
|
-
#
|
168
|
-
# ==== First Example
|
169
|
-
# @data = @mints_pub.get_story("story_slug")
|
170
|
-
#
|
171
|
-
# ==== Second Example
|
172
|
-
# @data = @mints_pub.get_story("story_slug", options.to_json)
|
173
|
-
def get_story(slug, options = nil)
|
174
|
-
@client.raw('get', "/content/stories/#{slug}", options)
|
175
|
-
end
|
176
|
-
|
177
|
-
##
|
178
|
-
# === Get Story Versions.
|
179
|
-
# Get a collection of story version.
|
180
|
-
#
|
181
|
-
# ==== Parameters
|
182
|
-
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
183
|
-
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
184
|
-
#
|
185
|
-
# ==== First Example
|
186
|
-
# @data = @mints_pub.get_story_versions
|
187
|
-
#
|
188
|
-
# ==== Second Example
|
189
|
-
# options = {
|
190
|
-
# fields: 'id, title'
|
191
|
-
# }
|
192
|
-
# @data = @mints_pub.get_story_versions(options)
|
193
|
-
#
|
194
|
-
# ==== Third Example
|
195
|
-
# options = {
|
196
|
-
# fields: 'id, title'
|
197
|
-
# }
|
198
|
-
# @data = @mints_pub.get_story_versions(options, false)
|
199
|
-
def get_story_versions(options = nil, use_post = true)
|
200
|
-
get_query_results('/content/story-versions', options, use_post)
|
201
|
-
end
|
202
|
-
|
203
|
-
##
|
204
|
-
# === Get Story Version.
|
205
|
-
# Get a single story version.
|
206
|
-
#
|
207
|
-
# ==== Parameters
|
208
|
-
# slug:: (String) -- It's the string identifier generated by Mints.
|
209
|
-
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
210
|
-
#
|
211
|
-
# ==== First Example
|
212
|
-
# @data = @mints_pub.get_story_version("story_slug")
|
213
|
-
#
|
214
|
-
# ==== Second Example
|
215
|
-
# @data = @mints_pub.get_story_version("story_slug", options.to_json)
|
216
|
-
def get_story_version(slug, options = nil)
|
217
|
-
@client.raw('get', "/content/story-versions/#{slug}", options)
|
218
|
-
end
|
219
|
-
|
220
|
-
##
|
221
|
-
# === Get Forms.
|
222
|
-
# Get a collection of forms.
|
223
|
-
#
|
224
|
-
# ==== Example
|
225
|
-
# @data = @mints_pub.get_forms
|
226
|
-
def get_forms(options = nil)
|
227
|
-
@client.raw('get', '/content/forms', options)
|
228
|
-
end
|
229
|
-
|
230
|
-
##
|
231
|
-
# === Get Form.
|
232
|
-
# Get a single form.
|
233
|
-
#
|
234
|
-
# ==== Parameters
|
235
|
-
# slug:: (String) -- It's the string identifier generated by Mints.
|
236
|
-
#
|
237
|
-
# ==== Example
|
238
|
-
# @data = @mints_pub.get_form("form_slug")
|
239
|
-
def get_form(slug, options = nil)
|
240
|
-
@client.raw('get', "/content/forms/#{slug}", options)
|
241
|
-
end
|
242
|
-
|
243
|
-
##
|
244
|
-
# === Submit Form.
|
245
|
-
# Submit a form with data.
|
246
|
-
#
|
247
|
-
# ==== Parameters
|
248
|
-
# data:: (Hash) -- Data to be submitted.
|
249
|
-
#
|
250
|
-
# ==== Example
|
251
|
-
# data = {
|
252
|
-
# 'form_slug': 'form_slug',
|
253
|
-
# 'email': 'email@example.com',
|
254
|
-
# 'given_name': 'given_name',
|
255
|
-
# 'f1': 'Field 1 answer',
|
256
|
-
# 'f2': 'Field 2 answer',
|
257
|
-
# 'f3': 'Field 3 answer'
|
258
|
-
# }
|
259
|
-
# @data = @mints_pub.submit_form(data)
|
260
|
-
def submit_form(data)
|
261
|
-
@client.raw('post', '/content/forms/submit', nil, data_transform(data))
|
262
|
-
end
|
263
|
-
|
264
|
-
##
|
265
|
-
# === Get Content Instances.
|
266
|
-
# Get a collection of content instances. _Note:_ Options must be specified.
|
267
|
-
#
|
268
|
-
# ==== Parameters
|
269
|
-
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
270
|
-
#
|
271
|
-
# ==== First Example
|
272
|
-
# options = {
|
273
|
-
# "template": "content_instance_template_slug"
|
274
|
-
# }
|
275
|
-
# @data = @mints_pub.get_content_instances(options)
|
276
|
-
#
|
277
|
-
# ==== Second Example
|
278
|
-
# options = {
|
279
|
-
# "template": "content_instance_template_slug",
|
280
|
-
# sort: "-id"
|
281
|
-
# }
|
282
|
-
# @data = @mints_pub.get_content_instances(options)
|
283
|
-
def get_content_instances(options = nil)
|
284
|
-
@client.raw('get', '/content/content-instances', options)
|
285
|
-
end
|
286
|
-
|
287
|
-
##
|
288
|
-
# === Get Content Instance.
|
289
|
-
# Get a single content instance.
|
290
|
-
#
|
291
|
-
# ==== Parameters
|
292
|
-
# slug:: (String) -- It's the string identifier generated by Mints.
|
293
|
-
#
|
294
|
-
# ==== Example
|
295
|
-
# @data = @mints_pub.get_content_instance("content_instance_slug")
|
296
|
-
def get_content_instance(slug)
|
297
|
-
@client.raw('get', "/content/content-instances/#{slug}")
|
298
|
-
end
|
299
|
-
|
300
|
-
##
|
301
|
-
# === Get Content Pages.
|
302
|
-
# Get all content pages.
|
303
|
-
#
|
304
|
-
# ==== Parameters
|
305
|
-
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
306
|
-
def get_content_bundles(options = nil)
|
307
|
-
@client.raw('get', '/content/content-bundles', options)
|
308
|
-
end
|
309
|
-
|
310
|
-
##
|
311
|
-
# === Get Content Page.
|
312
|
-
# Get a single content page.
|
313
|
-
#
|
314
|
-
# ==== Parameters
|
315
|
-
# slug:: (String) -- It's the string identifier generated by Mints.
|
316
|
-
#
|
317
|
-
# ==== Example
|
318
|
-
# @data = @mints_pub.get_content_page("test-page")
|
319
|
-
def get_content_page(slug, options = nil)
|
320
|
-
warn '[DEPRECATED] The get_content_page method is deprecated and will be removed in the future, use get_content_bundle instead'
|
321
|
-
@client.raw('get', "/content/content-pages/#{slug}", options)
|
322
|
-
end
|
323
|
-
|
324
|
-
##
|
325
|
-
# === Get Content Bundle.
|
326
|
-
# Get a single content bundle.
|
327
|
-
#
|
328
|
-
# ==== Parameters
|
329
|
-
# slug:: (String) -- It's the string identifier generated by Mints.
|
330
|
-
#
|
331
|
-
# ==== Example
|
332
|
-
# @data = @mints_pub.get_content_bundle("test-page")
|
333
|
-
def get_content_bundle(slug, options = nil)
|
334
|
-
@client.raw('get', "/content/content-bundles/#{slug}", options)
|
335
|
-
end
|
336
|
-
|
337
|
-
### V1/ECOMMERCE ###
|
338
|
-
|
339
|
-
##
|
340
|
-
# === Get Locations.
|
341
|
-
# Get all locations.
|
342
|
-
#
|
343
|
-
# ==== Parameters
|
344
|
-
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
345
|
-
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
346
|
-
#
|
347
|
-
# ==== First Example
|
348
|
-
# @data = @mints_pub.get_locations
|
349
|
-
#
|
350
|
-
# ==== Second Example
|
351
|
-
# options = { fields: "title" }
|
352
|
-
# @data = @mints_pub.get_locations(options)
|
353
|
-
#
|
354
|
-
# ==== Third Example
|
355
|
-
# options = { fields: "title" }
|
356
|
-
# @data = @mints_pub.get_locations(options, false)
|
357
|
-
def get_locations(options = nil, use_post = true)
|
358
|
-
get_query_results('/ecommerce/locations', options, use_post)
|
359
|
-
end
|
360
|
-
|
361
|
-
##
|
362
|
-
# === Get Products.
|
363
|
-
# Get a collection of products.
|
364
|
-
#
|
365
|
-
# ==== Parameters
|
366
|
-
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
367
|
-
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
368
|
-
#
|
369
|
-
# ==== First Example
|
370
|
-
# @data = @mints_pub.get_products
|
371
|
-
#
|
372
|
-
# ==== Second Example
|
373
|
-
# options = { fields: "title" }
|
374
|
-
# @data = @mints_pub.get_products(options)
|
375
|
-
#
|
376
|
-
# ==== Third Example
|
377
|
-
# options = { fields: "title" }
|
378
|
-
# @data = @mints_pub.get_products(options, false)
|
379
|
-
def get_products(options = nil, use_post = true)
|
380
|
-
get_query_results('/ecommerce/products', options, use_post)
|
381
|
-
end
|
382
|
-
|
383
|
-
##
|
384
|
-
# === Get Product.
|
385
|
-
# Get a single product.
|
386
|
-
#
|
387
|
-
# ==== Parameters
|
388
|
-
# slug:: (String) -- It's the string identifier generated by Mints.
|
389
|
-
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
390
|
-
#
|
391
|
-
# ==== First Example
|
392
|
-
# @data = @mints_pub.get_product("product_slug")
|
393
|
-
#
|
394
|
-
# ==== Second Example
|
395
|
-
# options = {
|
396
|
-
# fields: 'id, slug'
|
397
|
-
# }
|
398
|
-
# @data = @mints_pub.get_product("lego-set", options)
|
399
|
-
def get_product(slug, options = nil)
|
400
|
-
@client.raw('get', "/ecommerce/products/#{slug}", options)
|
401
|
-
end
|
402
|
-
|
403
|
-
### V1/CONFIG ###
|
404
|
-
|
405
|
-
##
|
406
|
-
# === Get Public Folders.
|
407
|
-
# Get a collection of public folders.
|
408
|
-
#
|
409
|
-
# ==== Parameters
|
410
|
-
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
411
|
-
#
|
412
|
-
# ==== First Example
|
413
|
-
# options = {
|
414
|
-
# object_type: "products"
|
415
|
-
# }
|
416
|
-
# @data = @mints_pub.get_public_folders(options)
|
417
|
-
#
|
418
|
-
# ==== Second Example
|
419
|
-
# options = {
|
420
|
-
# object_type: "products",
|
421
|
-
# fields: "id",
|
422
|
-
# sort: "-id"
|
423
|
-
# }
|
424
|
-
# @data = @mints_pub.get_public_folders(options)
|
425
|
-
def get_public_folders(options = nil)
|
426
|
-
@client.raw('get', '/config/public-folders', options)
|
427
|
-
end
|
428
|
-
|
429
|
-
##
|
430
|
-
# === Get Public Folder.
|
431
|
-
# Get a public folder info.
|
432
|
-
#
|
433
|
-
# ==== Parameters
|
434
|
-
# slug:: (String) -- It's the string identifier generated by Mints.
|
435
|
-
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
436
|
-
#
|
437
|
-
# ==== First Example
|
438
|
-
# options = {
|
439
|
-
# object_type: "products"
|
440
|
-
# }
|
441
|
-
# @data = @mints_pub.get_public_folder('yellow', options)
|
442
|
-
#
|
443
|
-
# ==== Second Example
|
444
|
-
# options = {
|
445
|
-
# object_type: "products",
|
446
|
-
# fields: 'id, title'
|
447
|
-
# }
|
448
|
-
# @data = @mints_pub.get_public_folder('yellow', options)
|
449
|
-
def get_public_folder(slug, options)
|
450
|
-
@client.raw('get', "/config/public-folders/#{slug}", options)
|
451
|
-
end
|
452
|
-
|
453
|
-
##
|
454
|
-
# === Get Tags.
|
455
|
-
# Get a collection of tags.
|
456
|
-
#
|
457
|
-
# ==== Parameters
|
458
|
-
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
459
|
-
#
|
460
|
-
# ==== First Example
|
461
|
-
# @data = @mints_pub.get_tags
|
462
|
-
#
|
463
|
-
# ==== Second Example
|
464
|
-
# options = {
|
465
|
-
# fields: "id, tag"
|
466
|
-
# }
|
467
|
-
# @data = @mints_pub.get_tags(options)
|
468
|
-
def get_tags(options = nil)
|
469
|
-
@client.raw('get', '/config/tags', options)
|
470
|
-
end
|
471
|
-
|
472
|
-
##
|
473
|
-
# === Get Tag.
|
474
|
-
# Get a single tag.
|
475
|
-
#
|
476
|
-
# ==== Parameters
|
477
|
-
# slug:: (String) -- It's the string identifier generated by Mints.
|
478
|
-
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
479
|
-
#
|
480
|
-
# ==== First Example
|
481
|
-
# @data = @mints_pub.get_tag("tag_slug")
|
482
|
-
#
|
483
|
-
# ==== Second Example
|
484
|
-
# options = {
|
485
|
-
# fields: "id, tag"
|
486
|
-
# }
|
487
|
-
# @data = @mints_pub.get_tag("tag-example", options)
|
488
|
-
def get_tag(slug, options = nil)
|
489
|
-
@client.raw('get', "/config/tags/#{slug}", options)
|
490
|
-
end
|
491
|
-
|
492
|
-
##
|
493
|
-
# === Get Taxonomies.
|
494
|
-
# Get a collection of taxonomies.
|
495
|
-
#
|
496
|
-
# ==== Parameters
|
497
|
-
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
498
|
-
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
499
|
-
#
|
500
|
-
# ==== First Example
|
501
|
-
# @data = @mints_pub.get_taxonomies
|
502
|
-
#
|
503
|
-
# ==== Second Example
|
504
|
-
# options = {
|
505
|
-
# fields: 'id, title'
|
506
|
-
# }
|
507
|
-
# @data = @mints_pub.get_taxonomies(options)
|
508
|
-
#
|
509
|
-
# ==== Third Example
|
510
|
-
# options = {
|
511
|
-
# fields: 'id, title'
|
512
|
-
# }
|
513
|
-
# @data = @mints_pub.get_taxonomies(options, false)
|
514
|
-
def get_taxonomies(options = nil, use_post = true)
|
515
|
-
get_query_results('/config/taxonomies', options, use_post)
|
516
|
-
end
|
517
|
-
|
518
|
-
##
|
519
|
-
# === Get Taxonomy.
|
520
|
-
# Get a single taxonomy.
|
521
|
-
#
|
522
|
-
# ==== Parameters
|
523
|
-
# slug:: (String) -- It's the string identifier generated by Mints.
|
524
|
-
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
525
|
-
#
|
526
|
-
# ==== First Example
|
527
|
-
# @data = @mints_pub.get_taxonomy('taxonomy_slug')
|
528
|
-
#
|
529
|
-
# ==== Second Example
|
530
|
-
# options = {
|
531
|
-
# fields: 'title'
|
532
|
-
# }
|
533
|
-
# @data = @mints_pub.get_taxonomy('taxonomy_slug', options)
|
534
|
-
def get_taxonomy(slug, options = nil)
|
535
|
-
@client.raw('get', "/config/taxonomies/#{slug}", options)
|
536
|
-
end
|
537
|
-
|
538
|
-
##
|
539
|
-
# === Get Attributes.
|
540
|
-
# Get a collection of attributes.
|
541
|
-
#
|
542
|
-
# ==== Example
|
543
|
-
# @data = @mints_pub.get_attributes
|
544
|
-
def get_attributes
|
545
|
-
@client.raw('get', '/config/attributes')
|
546
|
-
end
|
547
|
-
|
548
127
|
def send_user_magic_link(email_or_phone, template_slug, redirect_url = '', life_time = 1440, max_visits = nil, driver = 'email')
|
549
128
|
data = {
|
550
129
|
driver: driver,
|
@@ -13,6 +13,7 @@ require_relative './skus'
|
|
13
13
|
require_relative './taxes'
|
14
14
|
require_relative './variant_options'
|
15
15
|
require_relative './variant_values'
|
16
|
+
require_relative './vouchers'
|
16
17
|
|
17
18
|
module Ecommerce
|
18
19
|
include ItemPrices
|
@@ -28,4 +29,5 @@ module Ecommerce
|
|
28
29
|
include Taxes
|
29
30
|
include VariantOptions
|
30
31
|
include VariantValues
|
32
|
+
include Vouchers
|
31
33
|
end
|
@@ -31,8 +31,8 @@ module Locations
|
|
31
31
|
#
|
32
32
|
# ==== Example
|
33
33
|
# @data = @mints_user.get_location(2)
|
34
|
-
def get_location(id)
|
35
|
-
@client.raw('get', "/ecommerce/locations/#{id}")
|
34
|
+
def get_location(id, options = nil)
|
35
|
+
@client.raw('get', "/ecommerce/locations/#{id}", options)
|
36
36
|
end
|
37
37
|
|
38
38
|
# === Create location.
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Vouchers
|
4
|
+
##
|
5
|
+
# === Get vouchers.
|
6
|
+
# Get a collection of vouchers.
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
10
|
+
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
11
|
+
#
|
12
|
+
# ==== First Example
|
13
|
+
#
|
14
|
+
# @data = @mints_user.get_vouchers
|
15
|
+
# ==== Second Example
|
16
|
+
#
|
17
|
+
# options = { fields: 'id,title' }
|
18
|
+
# @data = @mints_user.get_vouchers(options)
|
19
|
+
# ==== Third Example
|
20
|
+
#
|
21
|
+
# options = { fields: 'id,title' }
|
22
|
+
# @data = @mints_user.get_vouchers(options, true)
|
23
|
+
#
|
24
|
+
def get_vouchers(options = nil, use_post = true)
|
25
|
+
get_query_results('/ecommerce/vouchers', options, use_post)
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# === Get vouchers.
|
30
|
+
# Get a specific voucher.
|
31
|
+
#
|
32
|
+
# ==== Parameters
|
33
|
+
# id:: (Integer) -- Voucher id.
|
34
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
35
|
+
#
|
36
|
+
# ==== First Example
|
37
|
+
#
|
38
|
+
# @data = @mints_user.get_voucher(1)
|
39
|
+
# ==== Second Example
|
40
|
+
#
|
41
|
+
# options = { fields: 'id,title' }
|
42
|
+
# @data = @mints_user.get_voucher(1, options)
|
43
|
+
def get_voucher(id, options = nil)
|
44
|
+
@client.raw('get', "/ecommerce/vouchers/#{id}", options)
|
45
|
+
end
|
46
|
+
|
47
|
+
##
|
48
|
+
# === Create voucher.
|
49
|
+
# Create voucher code.
|
50
|
+
#
|
51
|
+
# ==== Parameters
|
52
|
+
# data:: (Hash) -- Data to be submitted.
|
53
|
+
#
|
54
|
+
# ==== Example
|
55
|
+
# data = {
|
56
|
+
# title: 'Voucher title',
|
57
|
+
# voucher_code: 'XAZWQ12MP',
|
58
|
+
# amount: 100,
|
59
|
+
# start_date: '2023-03-28T10:20:00-06:00',
|
60
|
+
# end_date: '2023-03-31T10:20:00-06:00',
|
61
|
+
# is_redeemed: false
|
62
|
+
# }
|
63
|
+
#
|
64
|
+
# @data = @mints_user.create_voucher(data)
|
65
|
+
def create_voucher(data)
|
66
|
+
@client.raw('post', '/ecommerce/vouchers', nil, data_transform(data))
|
67
|
+
end
|
68
|
+
|
69
|
+
##
|
70
|
+
# === Update voucher.
|
71
|
+
# Update voucher code.
|
72
|
+
#
|
73
|
+
# ==== Parameters
|
74
|
+
# id:: (Integer) -- Voucher id.
|
75
|
+
# data:: (Hash) -- Data to be submitted.
|
76
|
+
#
|
77
|
+
# ==== Example
|
78
|
+
# data = {
|
79
|
+
# title: 'New voucher title',
|
80
|
+
# voucher_code: 'XAZWQ12MP2',
|
81
|
+
# amount: 250,
|
82
|
+
# start_date: '2023-03-27T10:20:00-06:00',
|
83
|
+
# end_date: '2023-03-30T10:20:00-06:00'
|
84
|
+
# }
|
85
|
+
#
|
86
|
+
# @data = @mints_user.update_voucher(1, data)
|
87
|
+
def update_voucher(id, data)
|
88
|
+
@client.raw('put', "/ecommerce/vouchers/#{id}", nil, data_transform(data))
|
89
|
+
end
|
90
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mints
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruben Gomez Garcia, Omar Mora, Luis Payan, Oscar Castillo, Fabian Garcia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- lib/contact/ecommerce/order_items.rb
|
123
123
|
- lib/contact/ecommerce/order_items_groups.rb
|
124
124
|
- lib/contact/ecommerce/orders.rb
|
125
|
+
- lib/contact/ecommerce/vouchers.rb
|
125
126
|
- lib/errors.rb
|
126
127
|
- lib/generators/mints_assets_controller.rb
|
127
128
|
- lib/generators/mints_config.yml.erb
|
@@ -145,6 +146,23 @@ files:
|
|
145
146
|
- lib/mints/helpers/proxy_controllers_methods.rb
|
146
147
|
- lib/mints/helpers/user_auth_helper.rb
|
147
148
|
- lib/pub.rb
|
149
|
+
- lib/pub/config/attributes.rb
|
150
|
+
- lib/pub/config/config.rb
|
151
|
+
- lib/pub/config/public_folders.rb
|
152
|
+
- lib/pub/config/tags.rb
|
153
|
+
- lib/pub/config/taxonomies.rb
|
154
|
+
- lib/pub/content/assets.rb
|
155
|
+
- lib/pub/content/content.rb
|
156
|
+
- lib/pub/content/content_bundles.rb
|
157
|
+
- lib/pub/content/content_instance_versions.rb
|
158
|
+
- lib/pub/content/content_instances.rb
|
159
|
+
- lib/pub/content/forms.rb
|
160
|
+
- lib/pub/content/stories.rb
|
161
|
+
- lib/pub/content/story_versions.rb
|
162
|
+
- lib/pub/ecommerce/ecommerce.rb
|
163
|
+
- lib/pub/ecommerce/locations.rb
|
164
|
+
- lib/pub/ecommerce/orders.rb
|
165
|
+
- lib/pub/ecommerce/products.rb
|
148
166
|
- lib/user.rb
|
149
167
|
- lib/user/config/api_keys.rb
|
150
168
|
- lib/user/config/appointments.rb
|
@@ -199,6 +217,7 @@ files:
|
|
199
217
|
- lib/user/ecommerce/taxes.rb
|
200
218
|
- lib/user/ecommerce/variant_options.rb
|
201
219
|
- lib/user/ecommerce/variant_values.rb
|
220
|
+
- lib/user/ecommerce/vouchers.rb
|
202
221
|
- lib/user/helpers/helpers.rb
|
203
222
|
- lib/user/helpers/object_activities.rb
|
204
223
|
- lib/user/helpers/object_folders.rb
|