Domain_Handler 0.0.0

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/domain_handler.rb +70 -0
  3. metadata +57 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bb08676edffe0c9c0528486f6fd5f102389a13839bd375c043f2148cb8d13e17
4
+ data.tar.gz: 74702588f5958e59af985cfe05656f73e9f720f6ea9c7b24ac5298b1652c9cd5
5
+ SHA512:
6
+ metadata.gz: 63a663239cf426653c17cb94d15a40fd7d4c3dd17885441701a95058a096c96e10109300f9967ce16035ce5d7db64a630844c0a61dec39deb2b4d9ee2c7bbf0f
7
+ data.tar.gz: 0cff9f77e4ba719dce03d9a71730a276571f56e39f5ac692e9a4572fbc59c18ef991221e0cd03c37581249863538ddf8a7d591995b4ae1259da9fbe5aba9b1b3
@@ -0,0 +1,70 @@
1
+ class DomainHandler
2
+ def self.add_domains(shop)
3
+ domain_query = "{
4
+ shop {
5
+ domains {
6
+ id
7
+ host
8
+ url
9
+ sslEnabled
10
+ localization { defaultLocale country alternateLocales}
11
+ marketWebPresence {rootUrls market}
12
+ }
13
+ }
14
+ }"
15
+ shop.with_shopify_session do
16
+ result = ShopifyGraphApi::Query.get(domain_query)
17
+ domains_data_arr = result.data.shop.domains
18
+ domains_data_arr.each do |domain|
19
+ data = domain.to_h
20
+ id = data['id'].split('Domain/').last
21
+ ssl_enabled = data['sslEnabled']
22
+ host = data['host']
23
+ url = data['url']
24
+ market_web_presence = data['marketWebPresence'].to_json
25
+ localization = data['localization'].to_json
26
+ if Domain.where(domain_id: id).exists?
27
+ next
28
+ end
29
+ Domain.new(
30
+ domain_id: id,
31
+ ssl_enabled: ssl_enabled,
32
+ localization: localization,
33
+ market_web_presence: market_web_presence,
34
+ host: host,
35
+ url: url,
36
+ shop_id: shop.id
37
+ ).save
38
+ end
39
+ end
40
+ end
41
+
42
+ def self.domains_create(params, shop_id)
43
+ return if Domain.where(domain_id: params[:id]).exists?
44
+
45
+ Domain.new(
46
+ domain_id: params[:id],
47
+ host: params[:host],
48
+ ssl_enabled: params[:ssl_enabled],
49
+ localization: params[:localization].to_json,
50
+ market_web_presence: params[:marketWebPresence].to_json,
51
+ url: params[:url],
52
+ shop_id: shop_id
53
+ ).save
54
+ end
55
+
56
+ def self.domains_delete(params)
57
+ Domain.delete(params[:id])
58
+ end
59
+
60
+ def self.domains_update(params)
61
+ domain = Domain.find_by(domain_id: params[:id])
62
+ return if domain.nil?
63
+
64
+ domain.update(
65
+ host: params[:host],
66
+ ssl_enabled: params[:ssl_enabled],
67
+ localization: params[:localization].to_json
68
+ )
69
+ end
70
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Domain_Handler
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Arun Sahu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-06-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '5.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '5.0'
27
+ description: This is domain handler gem
28
+ email: arun@starapps.studio
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/domain_handler.rb
34
+ homepage: https://rubygems.org/gems/hola
35
+ licenses:
36
+ - MIT
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubygems_version: 3.3.7
54
+ signing_key:
55
+ specification_version: 4
56
+ summary: Domain Dandler Gem
57
+ test_files: []