tagalys 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/tagalys.rb +122 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 789627b720188896e49bd6eb776097640c3050bb
4
+ data.tar.gz: c38f2da30aae1ab0f66603e3b59599fea5c8b1f3
5
+ SHA512:
6
+ metadata.gz: a8595b6a7f43b4713351c23e205604f08c083e6e74f92d7fc226d5341db0406e5c68b10ccdceb7d6169a2ea460764a723804b16c2b97e34585fbfdeeaa0af73b
7
+ data.tar.gz: 8366e14ce86df0e8121587af483f3cb1b69cb022fd0d36d5d06f6360b7b4f6e656416d9450a63e80ce07b4802751a103ccf17977b493ff04690284c5de36b468
data/lib/tagalys.rb ADDED
@@ -0,0 +1,122 @@
1
+ class Tagalys
2
+ class << self
3
+ require 'net/http'
4
+ require 'uri'
5
+ require 'json'
6
+
7
+ def search(query)
8
+ request_body = {
9
+ identification: identification,
10
+ q: query
11
+ }
12
+ search_response = request_tagalys('/search', request_body)
13
+ end
14
+
15
+ def create_store
16
+ request_body = {
17
+ identification: identification,
18
+ stores: [
19
+ {
20
+ id: "1",
21
+ label: "Store 1",
22
+ currencies: [
23
+ {
24
+ id: "INR",
25
+ label: "₹",
26
+ fractional_digits: 2,
27
+ rounding_mode: "round",
28
+ exchange_rate: 66.77,
29
+ default: false
30
+ }
31
+ ],
32
+ fields: [
33
+ {
34
+ name: "sale_price", # core fields like sku, price, sale_price etc. described in the next section don't have to be defined here, but they can be for the purpose of overriding labels or other options.
35
+ type: "float",
36
+ label: "Final Price",
37
+ currency: true,
38
+ filters: true,
39
+ search: false
40
+ },
41
+ {
42
+ name: "short_description",
43
+ type: "string",
44
+ label: "Short Description",
45
+ search: true
46
+ },
47
+ {
48
+ name: "name",
49
+ type: "string",
50
+ label: "Name",
51
+ search: true
52
+ }
53
+ ],
54
+ tag_sets: [
55
+ {
56
+ id: "apparel_type",
57
+ label: "Type",
58
+ filters: true,
59
+ search: true
60
+ },
61
+ {
62
+ id: "color",
63
+ label: "Color",
64
+ filters: true,
65
+ search: true
66
+ },
67
+ {
68
+ id: "gender",
69
+ label: "Gender",
70
+ filters: true,
71
+ search: true
72
+ },
73
+ {
74
+ id: "size",
75
+ label: "Size",
76
+ filters: true,
77
+ search: true
78
+ }
79
+ ],
80
+ sort_options: [
81
+ {
82
+ field: "name",
83
+ label: "Name"
84
+ },
85
+ {
86
+ field: "price",
87
+ label: "Price"
88
+ }
89
+ ],
90
+ locale: "en_US",
91
+ timezone: "India/Kolkata",
92
+ multi_currency_mode: "exchange_rate",
93
+ products_count: 21532
94
+ }
95
+ ]
96
+ }
97
+ create_response = request_tagalys('/configuration', request_body)
98
+ end
99
+
100
+ def request_tagalys(path, request_body)
101
+ uri = URI.parse("https://api-r1.tagalys.com/v1/" + path)
102
+ header = {'Content-Type': 'application/json'}
103
+ http = Net::HTTP.new(uri.host, uri.port)
104
+ http.use_ssl = true
105
+ request = Net::HTTP::Post.new(uri.request_uri, header)
106
+ puts request_body.to_json
107
+ request.body = request_body.to_json
108
+
109
+ # Send the request
110
+ response = http.request(request)
111
+ end
112
+
113
+ def identification
114
+ {
115
+ client_code: "ED8FFD720193B471",
116
+ store_id: "1",
117
+ api_key: "3a257e305b32e7b4fa70b5e999730d5a"
118
+ }
119
+ end
120
+
121
+ end
122
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tagalys
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Anbazhagan Palani
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-05-13 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This gem follows v1 of the Tagalys API endpoint.
14
+ email: anbu@commutatus.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/tagalys.rb
20
+ homepage: https://rubygems.org/gems/tagalys
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.6.13
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Tagalys gem is written for rails.
44
+ test_files: []