Domain_Handler 0.0.19 → 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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eafae423377fd8e4367435f28b140c9c60cbf758e0bb51f58858cfcc3a7cc127
|
4
|
+
data.tar.gz: 0ac7bec4989672e2b7df7caee14044965d379e91ac75c3f55727617b62182754
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffff81029c69b635641b999547eb2717d2dc9a483d6e55e5faec27ae93cc07be29fbb406e7eb2814ecd1fb2fd02687686be0ccc121dcee128002b3b85b40d45f
|
7
|
+
data.tar.gz: eb032066f4d4832a87d75f1f38c6bfacf96d69d9d6a5b7f4b3d76cdbbbf35bb3c51a198ce1b32a1134e2604d7c7ce9472abe7f055d8cae9fdf0d26b2e702ec33
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module DomainHandler
|
2
|
+
|
3
|
+
class DomainController < ApplicationController
|
4
|
+
include ShopifyApp::WebhookVerification
|
5
|
+
before_action :set_shop, except: [:theme_publish, :theme_update]
|
6
|
+
|
7
|
+
def domains_create(params, shop_id)
|
8
|
+
return if Domain.where(domain_id: params[:id]).exists?
|
9
|
+
|
10
|
+
Domain.new(
|
11
|
+
domain_id: params[:id],
|
12
|
+
host: params[:host],
|
13
|
+
ssl_enabled: params[:ssl_enabled],
|
14
|
+
localization: params[:localization].to_json,
|
15
|
+
market_web_presence: params[:marketWebPresence].to_json,
|
16
|
+
url: params[:url],
|
17
|
+
shop_id: shop_id
|
18
|
+
).save
|
19
|
+
end
|
20
|
+
|
21
|
+
def domains_update(params)
|
22
|
+
puts "DOMAIN IS UPDATING"
|
23
|
+
# domain = Domain.find_by(domain_id: params[:id])
|
24
|
+
# return if domain.nil?
|
25
|
+
|
26
|
+
# domain.update(
|
27
|
+
# host: params[:host],
|
28
|
+
# ssl_enabled: params[:ssl_enabled],
|
29
|
+
# localization: params[:localization].to_json
|
30
|
+
# )
|
31
|
+
end
|
32
|
+
|
33
|
+
def domains_delete(params)
|
34
|
+
Domain.delete(params[:id])
|
35
|
+
end
|
36
|
+
|
37
|
+
def test
|
38
|
+
puts "This is test"
|
39
|
+
head :ok
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Domain_Handler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arun Sahu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -30,7 +30,9 @@ executables: []
|
|
30
30
|
extensions: []
|
31
31
|
extra_rdoc_files: []
|
32
32
|
files:
|
33
|
-
- lib/domain_handler.rb
|
33
|
+
- lib/domain_handler/app/controllers/domain_controller.rb
|
34
|
+
- lib/domain_handler/config/initializers/domain_handler.rb
|
35
|
+
- lib/domain_handler/engine.rb
|
34
36
|
homepage: https://rubygems.org
|
35
37
|
licenses:
|
36
38
|
- MIT
|
data/lib/domain_handler.rb
DELETED
@@ -1,115 +0,0 @@
|
|
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
|
-
|
71
|
-
def self.create_migration
|
72
|
-
migration_name = 'create_domains'
|
73
|
-
|
74
|
-
# Generate a timestamp to use as the migration version
|
75
|
-
timestamp = Time.now.strftime('%Y%m%d%H%M%S')
|
76
|
-
|
77
|
-
# Generate the migration file name
|
78
|
-
migration_file_name = "#{timestamp}_#{migration_name}.rb"
|
79
|
-
|
80
|
-
# Specify the migration class name
|
81
|
-
migration_class_name = migration_name.camelize
|
82
|
-
|
83
|
-
# Specify the migration file path
|
84
|
-
migration_file_path = Rails.root.join('db', 'migrate', migration_file_name)
|
85
|
-
# Create the migration file
|
86
|
-
File.open(migration_file_path, 'w') do |file|
|
87
|
-
file.write("class #{migration_class_name} < ActiveRecord::Migration[6.1]\n")
|
88
|
-
file.write(" def change\n")
|
89
|
-
file.write(" create_table :domains, id: false, primary_key: :domain_id do |t|\n")
|
90
|
-
file.write(" # Define your table columns here\n")
|
91
|
-
file.write(" t.references :shop, foreign_key: true\n")
|
92
|
-
file.write(" t.string :host, null: false, default: ''\n")
|
93
|
-
file.write(" t.string :localization\n")
|
94
|
-
file.write(" t.string :market_web_presence\n")
|
95
|
-
file.write(" t.boolean :ssl_enabled, null: false\n")
|
96
|
-
file.write(" t.string :url\n")
|
97
|
-
file.write(" t.string :domain_id\n")
|
98
|
-
file.write(" t.index :domain_id, unique: true\n")
|
99
|
-
file.write(" t.timestamps\n")
|
100
|
-
file.write(" end\n")
|
101
|
-
file.write(" end\n")
|
102
|
-
file.write("end\n")
|
103
|
-
end
|
104
|
-
|
105
|
-
model_name = 'domain.rb'
|
106
|
-
model_file_path = Rails.root.join('app', 'models', model_name)
|
107
|
-
File.open(model_file_path, 'w') do |file|
|
108
|
-
file.write("class Domain < ApplicationRecord \n")
|
109
|
-
file.write(" self.primary_key = :domain_id \n")
|
110
|
-
file.write(" belongs_to :shop \n")
|
111
|
-
file.write(" belongs_to :shop \n")
|
112
|
-
file.write("end \n")
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|