Domain_Handler 0.0.20 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c53879f1c2f12ad82f245076a2528c5abaf26295186664a167db16c043b0c239
4
- data.tar.gz: fb2f7078d3a054cf77a35536f66212980cad252856f38c0af0ca86a6f3456fd9
3
+ metadata.gz: 540b0021130ca31b15ae11995d674d6e9fd09807fe67aba5a31367d29ddb937f
4
+ data.tar.gz: 7c5f11c91f8781e6a8d08f9d422e05ebb701b877b4700e5db7e56ab4bac0c2ed
5
5
  SHA512:
6
- metadata.gz: 38c94b6cf43d316e5e05f552c3dc99d70fdf635cedc4332b937491abf177ab6dc09de6cf33ce373d878e7ad58cad64813bf806dbbacd905179c9d81a48f1f6a1
7
- data.tar.gz: 93c6b2ec3ce6e0b2743db5f8876acd57f42d157d5c58bbd2bec3f0fbc87d02981cf1b0b7e048460786f1793a98855369699864f0926d17c662858f42cc0202d2
6
+ metadata.gz: 02e86ba246d561a5343a27d7c54bd131ecc86567597e1252c63c472691114c44685f0bcf70bbea5a7d7d452fe867d52fc10b7f8f460271a8839addc624d83c7d
7
+ data.tar.gz: 035a144a2b23223f5b9684b3729d63bc3b3ad24ba55ac5a14000329e69f88073c9a66a4edeab9644dae9208cac1923b119a66102cf86e5131172c57bfe34182f
@@ -0,0 +1,39 @@
1
+
2
+ class DomainController < ApplicationController
3
+ before_action :set_shop, except: [:theme_publish, :theme_update]
4
+
5
+ def domains_create(params, shop_id)
6
+ return if Domain.where(domain_id: params[:id]).exists?
7
+
8
+ Domain.new(
9
+ domain_id: params[:id],
10
+ host: params[:host],
11
+ ssl_enabled: params[:ssl_enabled],
12
+ localization: params[:localization].to_json,
13
+ market_web_presence: params[:marketWebPresence].to_json,
14
+ url: params[:url],
15
+ shop_id: shop_id
16
+ ).save
17
+ end
18
+
19
+ def domains_update(params)
20
+ puts "DOMAIN IS UPDATING"
21
+ # domain = Domain.find_by(domain_id: params[:id])
22
+ # return if domain.nil?
23
+
24
+ # domain.update(
25
+ # host: params[:host],
26
+ # ssl_enabled: params[:ssl_enabled],
27
+ # localization: params[:localization].to_json
28
+ # )
29
+ end
30
+
31
+ def domains_delete(params)
32
+ Domain.delete(params[:id])
33
+ end
34
+
35
+ def test
36
+ puts "This is test"
37
+ head :ok
38
+ end
39
+ end
@@ -0,0 +1,5 @@
1
+ Rails.application.config.to_prepare do
2
+ Dir.glob(File.join(File.dirname(__FILE__), '../../app/controllers/**/*.rb')).each do |c|
3
+ require_dependency(c)
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ DomainHandler::Engine.routes.draw do
2
+ get '*path', to: 'domain#test'
3
+ post '/domains-update', to: 'domain#domains_update'
4
+ post '/domain-handler/domains-update', to: 'domain#domains_update'
5
+ post '*path', to: 'domain#test'
6
+ end
7
+
@@ -0,0 +1,5 @@
1
+ class DomainHandler::Engine < Rails::Engine
2
+ isolate_namespace DomainHandler
3
+
4
+ end
5
+
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.20
4
+ version: 0.0.23
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-06 00:00:00.000000000 Z
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,10 @@ 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/config/routes.rb
36
+ - lib/domain_handler/engine.rb
34
37
  homepage: https://rubygems.org
35
38
  licenses:
36
39
  - MIT
@@ -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("end \n")
112
- end
113
- end
114
- end
115
-