angie-core-api 0.2.3 → 0.4.0

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: 3072be99380e09fb9937f810318090d787a3eb28f807cd67eccabf6b236b33f4
4
- data.tar.gz: 583cfdabe9771a3f3642b458674d4ff2eed4cb7888a46f6ee4f80dcc0985fe9b
3
+ metadata.gz: 6b4884c3195b5668cb61d7ed20fd97fa0c08209bc2b129ab45f9c776a5ce2ba0
4
+ data.tar.gz: ecb5fdcbfc17ddb640a9105f33802ba7ad49bc5341e1f815a9484ea06d085159
5
5
  SHA512:
6
- metadata.gz: 619955fcc6e98cd2063f1d91f29e56e37b333fe6b1be420fb137f8fb84e6eeaa17744f247fb896c4148536929d7d95932a09aa4f5019d5efed59f163f36da3fa
7
- data.tar.gz: 48700fbc57be4fc80413ea8c14687086dfe7abc386442852bc70823aed06337de7b8eb4425bc8bebba1828d755b5f6a85f1903d665f4c1b731a1b827161f914d
6
+ metadata.gz: 0bb6bc79455a2b6c82bdad9e375e1507762267d1d81a6e2d22faf51d950d6b49170d1161dcb0527c918ada83aadcdae4adb0de4053279682672fb5f96f6c9097
7
+ data.tar.gz: 2efd6d4c9a2de953368ab1a252c439e247dc0041b4cd5a74792e175656cdf12dc28c46f2f3beccb940e9c9f1ab59294433c6090f2d2600c347978ea113fdbd52
@@ -1,11 +1,15 @@
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"
4
6
  autoload :Flight, "angie-core-api/flight"
5
7
  autoload :Map, "angie-core-api/map"
6
8
  autoload :Notification, "angie-core-api/notification"
9
+ autoload :TV, "angie-core-api/tv"
7
10
  autoload :Weather, "angie-core-api/weather"
8
11
  autoload :DeliveryMethod, "angie-core-api/delivery_method"
12
+ autoload :Message, "angie-core-api/message"
9
13
 
10
14
  def self.configuration
11
15
  @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
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AngieCoreApi
4
+ class TV
5
+ def initialize(provider)
6
+ @provider = provider
7
+ end
8
+
9
+ def command(command)
10
+ Client.data(:post, "/tv", { provider: @provider, command: command})
11
+ end
12
+ end
13
+ end
@@ -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,57 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: angie-core-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Angie Hospitality
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-13 00:00:00.000000000 Z
11
+ date: 2021-03-18 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.1'
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.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: actionmailer
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '6.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '6.1'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: activesupport
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '6.0'
47
+ version: '6.1'
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '6.0'
54
+ version: '6.1'
41
55
  - !ruby/object:Gem::Dependency
42
- name: actionmailer
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
43
71
  requirement: !ruby/object:Gem::Requirement
44
72
  requirements:
45
73
  - - "~>"
46
74
  - !ruby/object:Gem::Version
47
- version: '6.0'
75
+ version: '1.4'
48
76
  type: :runtime
49
77
  prerelease: false
50
78
  version_requirements: !ruby/object:Gem::Requirement
51
79
  requirements:
52
80
  - - "~>"
53
81
  - !ruby/object:Gem::Version
54
- version: '6.0'
82
+ version: '1.4'
55
83
  description: Angie CoreAPI Ruby gem
56
84
  email:
57
85
  - rubygems@angie.ai
@@ -65,14 +93,18 @@ 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
101
+ - lib/angie-core-api/tv.rb
70
102
  - lib/angie-core-api/weather.rb
71
103
  homepage: https://angie.ai
72
104
  licenses: []
73
105
  metadata:
74
106
  homepage_uri: https://angie.ai
75
- post_install_message:
107
+ post_install_message:
76
108
  rdoc_options: []
77
109
  require_paths:
78
110
  - lib
@@ -87,8 +119,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
119
  - !ruby/object:Gem::Version
88
120
  version: '0'
89
121
  requirements: []
90
- rubygems_version: 3.0.3
91
- signing_key:
122
+ rubygems_version: 3.1.4
123
+ signing_key:
92
124
  specification_version: 4
93
125
  summary: Angie CoreAPI Ruby gem
94
126
  test_files: []