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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9c4e1950d918c943ea439283852bdedbc277fa08ccf9805148fd37ee7fa11ca
4
- data.tar.gz: 33f633052bc842e7f82834af08ee0963bd5a90a1a2d43567416c75bb0a8e92f3
3
+ metadata.gz: 0a907b04190f30ca644d2940b3e1e3e308b62443eb1f9e86fbc96ba0325d26d5
4
+ data.tar.gz: dc6f7fca4ceb86aaec2019647e285b2ff5c3851598c7d5a61feff7ece43e5da6
5
5
  SHA512:
6
- metadata.gz: cf72d5f0295090bf84031a74b765ea2f788f0216099af6f9b1af5ea18b46ccd491e3957f38c6eeaa4d9a6811a96926e52f7f2d5d15d4ae4db0f19bad1e33ca8a
7
- data.tar.gz: b10fd6db11f46e3a96e20d1a85a3f350bd8279900616f49d50fae0edba216d9673af5fe94ab5e68f678a97fc531559830b8e89ad84526a2e31b4282c471b5604
6
+ metadata.gz: 57e9e5688d548bdb9db6867e93a7684a61e73c572738818612957ce7486f39bab27d0276ba1ff326dcb302971f3cb38a16b422c87d7efb1223587293c2e8e986
7
+ data.tar.gz: 4e680e8d5981156568b94587cdcc66d68b2d38276b1f7363341cc925625c808602c724d2e6abc264416191112746dfb16862a4f559229896ebfc8235e6a76836
@@ -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
- parsed_response { self.class.get(api_url_for(url), headers: api_headers) }
14
+ get(api_url_for(url), headers: api_headers)
13
15
  when :post
14
- parsed_response { self.class.post(api_url_for(url), body: body.to_json, headers: api_headers) }
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,4 +1,4 @@
1
- require "active_support"
1
+ # frozen_string_literal: true
2
2
 
3
3
  module AngieCoreApi
4
4
  class Configuration
@@ -6,5 +6,6 @@ module AngieCoreApi
6
6
 
7
7
  config_accessor(:url)
8
8
  config_accessor(:token)
9
+ config_accessor(:activemq)
9
10
  end
10
11
  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&.body&.raw_source
15
+ html: mail.html_part ? mail.html_part.body&.raw_source : mail.body.raw_source
14
16
  )
15
17
  end
16
18
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module AngieCoreApi
2
4
  class Flight
3
5
  def self.info(default_airport, airline, flight_number, date)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module AngieCoreApi
2
4
  class Map
3
5
  def self.travel_time(origin, location, radius, unit, size, zoom, locale)
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AngieCoreApi
4
+ module Message
5
+ autoload :Client, "angie-core-api/message/client"
6
+ autoload :Queue, "angie-core-api/message/queue"
7
+ end
8
+ end
@@ -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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module AngieCoreApi
2
4
  class Notification
3
5
  def self.email(options)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module AngieCoreApi
2
4
  class Railtie < Rails::Railtie
3
5
  initializer "angie_core_api.add_delivery_method" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module AngieCoreApi
2
4
  class Weather
3
5
  def self.info(latitude, longitude, unit, date, locale)
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.2.2
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
- - Hussein Choroomi
7
+ - Angie Hospitality
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-10 00:00:00.000000000 Z
11
+ date: 2020-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: httparty
14
+ name: actioncable
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.18.1
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.18.1
26
+ version: '6.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: activesupport
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: actionmailer
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
- - info@angie.ai
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