domain_webhook_handler 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/domain_webhook_handler.rb +73 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3fcdd73cfc4f5e443ffd8264d5c6fcc01f56ef6209093a8c908a0347470c1e3f
|
4
|
+
data.tar.gz: aece8519a022f29ef083972bb2c830b2a54829948ad9213a3d15f3474067f828
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c83ceb6036273b39a830e95ccd20847fefc6865313fe0449d57d0cb9684fc3a3f4b665f5e96d5f9dc2445e9525e41c4a57dd166e7c9d6c1de1a417d2dace9822
|
7
|
+
data.tar.gz: 7b8bb6ada55cb5638207a38fa3988636e045f1c76db2c8e366676139930d84f3dade63bafb68acbbcba9064cb6ae8d58fbb706f1d38fa90ccb2a1416d31531ac
|
@@ -0,0 +1,73 @@
|
|
1
|
+
class DomainWebhookHandler
|
2
|
+
def self.domains_delete(params)
|
3
|
+
Domain.delete(params[:id])
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.domains_create(params, shop_id)
|
7
|
+
return if Domain.where(domain_id: params[:id]).exists?
|
8
|
+
|
9
|
+
Domain.new(
|
10
|
+
domain_id: params[:id],
|
11
|
+
host: params[:host],
|
12
|
+
ssl_enabled: params[:ssl_enabled],
|
13
|
+
localization: params[:localization].to_json,
|
14
|
+
market_web_presence: params[:marketWebPresence].to_json,
|
15
|
+
url: params[:url],
|
16
|
+
shop_id: shop_id
|
17
|
+
).save
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.domains_update(params)
|
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 self.add_domains(shop)
|
32
|
+
domain_query = "{
|
33
|
+
shop {
|
34
|
+
domains {
|
35
|
+
id
|
36
|
+
host
|
37
|
+
url
|
38
|
+
sslEnabled
|
39
|
+
localization { defaultLocale country alternateLocales}
|
40
|
+
marketWebPresence {rootUrls market}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}"
|
44
|
+
|
45
|
+
shop.with_shopify_session do
|
46
|
+
result = ShopifyGraphApi::Query.get(domain_query)
|
47
|
+
domains_data_arr = result.data.shop.domains
|
48
|
+
domains_data_arr.each do |domain|
|
49
|
+
# code to be executed for each element
|
50
|
+
data = domain.to_h
|
51
|
+
id = data['id'].split('Domain/').last
|
52
|
+
ssl_enabled = data['sslEnabled']
|
53
|
+
host = data['host']
|
54
|
+
url = data['url']
|
55
|
+
market_web_presence = data['marketWebPresence'].to_json
|
56
|
+
localization = data['localization'].to_json
|
57
|
+
if Domain.where(domain_id: id).exists?
|
58
|
+
next
|
59
|
+
end
|
60
|
+
|
61
|
+
Domain.new(
|
62
|
+
domain_id: id,
|
63
|
+
ssl_enabled: ssl_enabled,
|
64
|
+
localization: localization,
|
65
|
+
market_web_presence: market_web_presence,
|
66
|
+
host: host,
|
67
|
+
url: url,
|
68
|
+
shop_id: shop.id
|
69
|
+
).save
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: domain_webhook_handler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Arun
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-06-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Domain web hook handler
|
14
|
+
email: arun@starapps.studio
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/domain_webhook_handler.rb
|
20
|
+
homepage: https://rubygems.org/gems/hola
|
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
|
+
rubygems_version: 3.3.7
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: This is domain webhook handler
|
43
|
+
test_files: []
|