angie-core-api 0.2.2 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/angie-core-api.rb +3 -0
- data/lib/angie-core-api/client.rb +4 -7
- data/lib/angie-core-api/configuration.rb +2 -1
- data/lib/angie-core-api/delivery_method.rb +4 -2
- data/lib/angie-core-api/flight.rb +2 -0
- data/lib/angie-core-api/map.rb +2 -0
- data/lib/angie-core-api/message.rb +8 -0
- data/lib/angie-core-api/message/client.rb +25 -0
- data/lib/angie-core-api/message/queue.rb +30 -0
- data/lib/angie-core-api/notification.rb +2 -0
- data/lib/angie-core-api/railtie.rb +2 -0
- data/lib/angie-core-api/weather.rb +2 -0
- metadata +40 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a907b04190f30ca644d2940b3e1e3e308b62443eb1f9e86fbc96ba0325d26d5
|
4
|
+
data.tar.gz: dc6f7fca4ceb86aaec2019647e285b2ff5c3851598c7d5a61feff7ece43e5da6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57e9e5688d548bdb9db6867e93a7684a61e73c572738818612957ce7486f39bab27d0276ba1ff326dcb302971f3cb38a16b422c87d7efb1223587293c2e8e986
|
7
|
+
data.tar.gz: 4e680e8d5981156568b94587cdcc66d68b2d38276b1f7363341cc925625c808602c724d2e6abc264416191112746dfb16862a4f559229896ebfc8235e6a76836
|
data/lib/angie-core-api.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module AngieCoreApi
|
2
4
|
autoload :Configuration, "angie-core-api/configuration"
|
3
5
|
autoload :Client, "angie-core-api/client"
|
@@ -6,6 +8,7 @@ module AngieCoreApi
|
|
6
8
|
autoload :Notification, "angie-core-api/notification"
|
7
9
|
autoload :Weather, "angie-core-api/weather"
|
8
10
|
autoload :DeliveryMethod, "angie-core-api/delivery_method"
|
11
|
+
autoload :Message, "angie-core-api/message"
|
9
12
|
|
10
13
|
def self.configuration
|
11
14
|
@configuration ||= Configuration.new
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "httparty"
|
2
4
|
|
3
5
|
module AngieCoreApi
|
@@ -9,9 +11,9 @@ module AngieCoreApi
|
|
9
11
|
def data(http_method, url, body = {})
|
10
12
|
case http_method
|
11
13
|
when :get
|
12
|
-
|
14
|
+
get(api_url_for(url), headers: api_headers)
|
13
15
|
when :post
|
14
|
-
|
16
|
+
post(api_url_for(url), body: body.to_json, headers: api_headers)
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
@@ -36,11 +38,6 @@ module AngieCoreApi
|
|
36
38
|
self.class.default_options[:timeout] || self.class.default_options[:read_timeout]
|
37
39
|
end
|
38
40
|
|
39
|
-
def parsed_response
|
40
|
-
response = yield
|
41
|
-
response.code == 200 ? response.parsed_response : nil
|
42
|
-
end
|
43
|
-
|
44
41
|
def get(url, headers: api_headers, timeout: default_timeout)
|
45
42
|
request(:get, url, headers: headers, timeout: timeout)
|
46
43
|
end
|
@@ -1,16 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module AngieCoreApi
|
2
4
|
class DeliveryMethod
|
3
5
|
def initialize(mail) end
|
4
6
|
|
5
7
|
def deliver!(mail)
|
6
8
|
Notification.email(
|
7
|
-
from: mail.from,
|
9
|
+
from: mail.from.first,
|
8
10
|
to: mail.to,
|
9
11
|
cc: mail.cc,
|
10
12
|
bcc: mail.bcc,
|
11
13
|
subject: mail.subject,
|
12
14
|
text: mail.text_part ? mail.text_part.body&.raw_source : mail.body.raw_source,
|
13
|
-
html: mail.html_part
|
15
|
+
html: mail.html_part ? mail.html_part.body&.raw_source : mail.body.raw_source
|
14
16
|
)
|
15
17
|
end
|
16
18
|
end
|
data/lib/angie-core-api/map.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "stomp"
|
4
|
+
|
5
|
+
module AngieCoreApi
|
6
|
+
module Message
|
7
|
+
class Client
|
8
|
+
include Concurrent::Async
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
config = HashWithIndifferentAccess.new(AngieCoreApi.configuration.activemq)
|
12
|
+
@client = Stomp::Client.new(config)
|
13
|
+
end
|
14
|
+
|
15
|
+
def publish(queue, data)
|
16
|
+
@client.publish(queue, data.to_json)
|
17
|
+
@client.close
|
18
|
+
end
|
19
|
+
|
20
|
+
def subscribe(queue)
|
21
|
+
@client.subscribe(queue) { |msg| yield JSON.parse(msg.body) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AngieCoreApi
|
4
|
+
module Message
|
5
|
+
class Queue
|
6
|
+
def self.classes
|
7
|
+
Dir["app/queues/*.rb"].
|
8
|
+
map { |file| File.basename(file, ".rb") }.
|
9
|
+
select { |type| type != "application_queue" }.
|
10
|
+
map(&:camelize).
|
11
|
+
map(&:constantize)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.queue
|
15
|
+
path = name.underscore.sub("_queue", "")
|
16
|
+
"/queue/#{path}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.publish(message)
|
20
|
+
Client.new.async.publish(queue, message)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.subscribe
|
24
|
+
Client.new.async.subscribe(queue) do |message|
|
25
|
+
self.new.receive(message)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: angie-core-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Angie Hospitality
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: actioncable
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0
|
19
|
+
version: '6.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0
|
26
|
+
version: '6.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: actionmailer
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '6.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: activesupport
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
@@ -52,9 +52,37 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '6.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: httparty
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.18.1
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.18.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: stomp
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.4'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.4'
|
55
83
|
description: Angie CoreAPI Ruby gem
|
56
84
|
email:
|
57
|
-
-
|
85
|
+
- rubygems@angie.ai
|
58
86
|
executables: []
|
59
87
|
extensions: []
|
60
88
|
extra_rdoc_files: []
|
@@ -65,6 +93,9 @@ files:
|
|
65
93
|
- lib/angie-core-api/delivery_method.rb
|
66
94
|
- lib/angie-core-api/flight.rb
|
67
95
|
- lib/angie-core-api/map.rb
|
96
|
+
- lib/angie-core-api/message.rb
|
97
|
+
- lib/angie-core-api/message/client.rb
|
98
|
+
- lib/angie-core-api/message/queue.rb
|
68
99
|
- lib/angie-core-api/notification.rb
|
69
100
|
- lib/angie-core-api/railtie.rb
|
70
101
|
- lib/angie-core-api/weather.rb
|