nature_remo_client 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cd77ce3fe2976d520c5dfbe7006a7382526cce067e8d1bb20da0000c6871444e
4
+ data.tar.gz: 1595e488ddd3e8d9715a4cbc292040ec270b06e8bcbfef7460116d62ac82faa3
5
+ SHA512:
6
+ metadata.gz: 043a57d085d2404115191045def20100935779b69de4cd027aae27fe91052abe074f5c9715721a39bf9cce75ce9a366789e4bf72a561c63062fbfcd16271441b
7
+ data.tar.gz: bd1f689566cadcfb173754a552a5686c3439fcc06ec588f36ba2f8e40df119842e4099da1b2c99211a303ad0596bb364b98ffe9dfbce2e6dd88b6bfaf8a5fa0d
data/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # nature_remo_client(Nature Remo API Client for Ruby)
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/nature_remo_client`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Install the gem and add to the application's Gemfile by executing:
10
+
11
+ $ bundle add nature_remo_client
12
+
13
+ If bundler is not being used to manage dependencies, install the gem by executing:
14
+
15
+ $ gem install nature_remo_client
16
+
17
+ ## Usage
18
+ ### Users
19
+
20
+ ```ruby
21
+ require 'nature_remo_client'
22
+
23
+ client = NatureRemo::Client.new(<token>)
24
+
25
+ # Get user info
26
+ client.user_me
27
+
28
+ # Update user nickname
29
+ client.update_user_me(nickname: <nickname>)
30
+ ```
31
+
32
+ ### Deices
33
+ ```ruby
34
+ require 'nature_remo_client'
35
+
36
+ client = NatureRemo::Client.new(<token>)
37
+
38
+ # Get Remos
39
+ client.devices
40
+
41
+ # Update Remo name
42
+ client.update_device(device_id: <device_id>, name: <name>)
43
+
44
+ # Delete Remo
45
+ client.delete_device(device_id: <device_id>)
46
+
47
+ # Update temperature offset
48
+ client.update_device_temperature_offset(device_id: <divice_id>, offset: <offset>)
49
+
50
+ # Update humidity offset
51
+ client.update_device_humidity_offset(device_id: <divice_id>, offset: <offset>)
52
+ ```
53
+
54
+ ### Appliances
55
+ ```ruby
56
+ require 'nature_remo_client'
57
+
58
+ client = NatureRemo::Client.new(<token>)
59
+
60
+ # get appliances
61
+ client.appliances
62
+
63
+ # Create a new appliance
64
+ client.create_appliance(device_id: <divice_id>, nickname: <nickname>, image: <image>, model: <model>, model_type: <model_type>)
65
+
66
+ # Reorder appliances
67
+ client.update_appliance_orders(appliance_ids: <appliance_ids>)
68
+
69
+ # Update appliance
70
+ client.update_appliance(appliance_id: <appliance_id>, nickname: <nickname>, image: <image>)
71
+
72
+ # Delete appliance
73
+ client.delete_appliance(appliance_id: <appliance_id>)
74
+
75
+ # Update air conditioner settings
76
+ client.update_aircon_settings(appliance_id: <appliance_id>, temperature: <temperature>)
77
+
78
+ # Update TV infrared signal
79
+ client.update_tv_state(appliance_id: <appliance_id>, button: <button>)
80
+
81
+ # Send light infrared signal
82
+ client.update_light_state(appliance_id: <appliance_id>, button: <button>)
83
+ ```
84
+
85
+ ### Signals
86
+ ```ruby
87
+ require 'nature_remo_client'
88
+
89
+ client = NatureRemo::Client.new(<token>)
90
+
91
+ # get signals
92
+ client.signals(appliance_id: <appliance_id>)
93
+
94
+ # Create a signal under this appliance
95
+ client.create_signal(appliance_id: <appliance_id>, name: <name>, image: <image>, message: <message>)
96
+
97
+ # Reorder signals under this appliance
98
+ client.update_signal_orders(appliance_ids: <appliance_ids>, signal_ids: <signal_ids>)
99
+
100
+ # Update infrared signal
101
+ client.update_signal(appliance_id: <appliance_id>, name: <name>, image: <image>)
102
+
103
+ # Delete signal
104
+ client.delete_signal(signal_id: <signal_id>)
105
+
106
+ # Send infrared signal
107
+ client.send_signal(signal_id: <signal_id>)
108
+ ```
109
+
110
+ ## Development
111
+
112
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
113
+
114
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
115
+
116
+ ## Contributing
117
+
118
+ Bug reports and pull requests are welcome on GitHub at https://github.com/craft-cat/nature_remo_client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/craft-cat/nature_remo_client/blob/main/CODE_OF_CONDUCT.md).
119
+
120
+ ## License
121
+
122
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
123
+
124
+ ## Code of Conduct
125
+
126
+ Everyone interacting in the NatureRemo project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/craft-cat/nature_remo_client/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'test'
8
+ t.libs << 'lib'
9
+ t.test_files = FileList['test/**/*_test.rb']
10
+ end
11
+
12
+ require 'rubocop/rake_task'
13
+
14
+ RuboCop::RakeTask.new
15
+
16
+ task default: %i[test rubocop]
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'endpoints'
4
+
5
+ module NatureRemo
6
+ # Client to send requests to Nature Remo cloud API
7
+ class Client
8
+ include NatureRemo::Endpoints
9
+
10
+ BASE_URL = 'https://api.nature.global/'
11
+ API_VERSION = '1'
12
+
13
+ def initialize(access_token)
14
+ raise ArgumentError, 'argument access_token must not be nil' if access_token.nil?
15
+
16
+ @client = Faraday.new(url: "#{BASE_URL}#{API_VERSION}/") do |conn|
17
+ conn.request :json
18
+ conn.response :json, content_type: /\bjson$/, parser_options: { symbolize_names: true }
19
+ conn.adapter Faraday.default_adapter
20
+ conn.use RaiseError
21
+ end
22
+ @client.headers['Authorization'] = "Bearer #{access_token}"
23
+ end
24
+
25
+ private
26
+
27
+ def get(path)
28
+ response = @client.get(path)
29
+
30
+ raise NatureRemo::Error, "request failed with status code #{response.status}, #{response.body}" unless response.success?
31
+
32
+ response.body
33
+ end
34
+
35
+ def post(path, params = nil)
36
+ response = @client.post(path) do |req|
37
+ req.body = params
38
+ end
39
+
40
+ raise NatureRemo::Error, "request failed with status code #{response.status}, #{response.body}" unless response.success?
41
+
42
+ response.body
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,115 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NatureRemo
4
+ module Endpoints
5
+ # Endpoints for user infomation
6
+ module Appliances
7
+ # Fetch the list of appliances.
8
+ # @return [String] The list of appliances.
9
+ # @raise [NatureRemo::ServerError] Raise error if resposonse status is NOT success.
10
+ #
11
+ # https://swagger.nature.global/#/default/get_1_appliances
12
+ def appliances
13
+ get('appliances')
14
+ end
15
+
16
+ # Create a new appliance.
17
+ # @param [String] device_id Device ID
18
+ # @param [String] nickname Appliance name.
19
+ # @param [String] image Basename of the image file included in the app. Ex: "ico_ac_1"
20
+ # @param [String] model ApplianceModel ID if the appliance we're trying to create is included in IRDB.
21
+ # @param [String] model_type Available values : AC, TV, LIGHT
22
+ # @return [String] Created an appliance.
23
+ # @raise [NatureRemo::ServerError] Raise error if resposonse status is NOT success.
24
+ #
25
+ # https://swagger.nature.global/#/default/post_1_appliances
26
+ def create_appliance(device_id:, nickname:, image:, model: nil, model_type: nil)
27
+ params = {
28
+ device: device_id,
29
+ nickname: nickname,
30
+ image: image
31
+ }
32
+ params[:model] = model if model
33
+ params[:model_type] = model_type if model_type
34
+
35
+ post('appliances', params)
36
+ end
37
+
38
+ # Reorder appliances.
39
+ # @param [String] appliance_ids List of all appliances' IDs comma separated
40
+ # @return [String] Reordered appliances
41
+ # @raise [NatureRemo::ServerError] Raise error if resposonse status is NOT success.
42
+ #
43
+ # https://swagger.nature.global/#/default/post_1_appliance_orders
44
+ def update_appliance_orders(appliance_ids:)
45
+ post('appliance_orders', { appliances: appliance_ids })
46
+ end
47
+
48
+ # Update appliance.
49
+ # @param [String] appliance_id Appliance ID.
50
+ # @param [String] nickname Appliance name
51
+ # @param [String] image Basename of the image file included in the app. Ex: "ico_ac_1"
52
+ # @return [String] Updated air conditioner settings.
53
+ # @raise [NatureRemo::ServerError] Raise error if resposonse status is NOT success.
54
+ #
55
+ # https://swagger.nature.global/#/default/post_1_appliances__appliance_
56
+ def update_appliance(appliance_id:, nickname:, image:)
57
+ post("appliances/#{appliance_id}", { nickname: nickname, image: image })
58
+ end
59
+
60
+ # Delete appliance.
61
+ # @param [String] appliance_id Appliance ID.
62
+ # @return [String] Deleted an appliance.
63
+ # @raise [NatureRemo::ServerError] Raise error if resposonse status is NOT success.
64
+ #
65
+ # https://swagger.nature.global/#/default/post_1_appliances__appliance__delete
66
+ def delete_appliance(appliance_id:)
67
+ post("appliances/#{appliance_id}/delete")
68
+ end
69
+
70
+ # Update air conditioner settings.
71
+ # @param [String] appliance_id Appliance ID.
72
+ # @param [String] button Button
73
+ # @param [String] temperature Temperature
74
+ # @param [String] operation_mode AC operation mode
75
+ # @param [String] air_volume AC air volume
76
+ # @param [String] air_direction AC air direction
77
+ # @return [String] Updated air conditioner settings
78
+ # @raise [NatureRemo::ServerError] Raise error if resposonse status is NOT success.
79
+ #
80
+ # https://swagger.nature.global/#/default/post_1_appliances__appliance__aircon_settings
81
+ def update_aircon_settings(appliance_id:, button: nil, temperature: nil, operation_mode: nil, air_volume: nil, air_direction: nil)
82
+ params = {}
83
+ params[:button] = button if button
84
+ params[:temperature] = temperature if temperature
85
+ params[:operation_mode] = operation_mode if operation_mode
86
+ params[:air_volume] = air_volume if air_volume
87
+ params[:air_direction] = air_direction if air_direction
88
+
89
+ post("appliances/#{appliance_id}/aircon_settings", params)
90
+ end
91
+
92
+ # Send tv infrared signal.
93
+ # @param [String] appliance_id Appliance ID.
94
+ # @param [String] button Button name
95
+ # @return [String] Updated tv state
96
+ # @raise [NatureRemo::ServerError] Raise error if resposonse status is NOT success.
97
+ #
98
+ # https://swagger.nature.global/#/default/post_1_appliances__appliance__tv
99
+ def update_tv_state(appliance_id:, button:)
100
+ post("appliances/#{appliance_id}/tv", { button: button })
101
+ end
102
+
103
+ # Send light infrared signal.
104
+ # @param [String] appliance_id Appliance ID.
105
+ # @param [String] button Button name
106
+ # @return [String] Updated light state
107
+ # @raise [NatureRemo::ServerError] Raise error if resposonse status is NOT success.
108
+ #
109
+ # https://swagger.nature.global/#/default/post_1_appliances__appliance__light
110
+ def update_light_state(appliance_id:, button:)
111
+ post("appliances/#{appliance_id}/light", { button: button })
112
+ end
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NatureRemo
4
+ module Endpoints
5
+ # Endpoints for Nature Remo devices
6
+ module Devices
7
+ # Fetch the list of Remo devices the user has access to.
8
+ # @return [String] The list of Remo devices.
9
+ # @raise [NatureRemo::ServerError] Raise error if resposonse status is NOT success.
10
+ #
11
+ # https://swagger.nature.global/#/default/get_1_devices
12
+ def devices
13
+ get('devices')
14
+ end
15
+
16
+ # Update Remo Name.
17
+ # @param [String] device_id Remo id.
18
+ # @param [String] name New Remo name.
19
+ # @return [String]
20
+ # @raise [NatureRemo::ServerError] Raise error if resposonse status is NOT success.
21
+ #
22
+ # https://swagger.nature.global/#/default/post_1_devices__device_
23
+ def update_device(device_id:, name:)
24
+ post("devices/#{device_id}", { name: name })
25
+ end
26
+
27
+ # Delete Remo.
28
+ # @param [String] device_id Remo id.
29
+ # @return [String] Deleted Remo.
30
+ # @raise [NatureRemo::ServerError] Raise error if resposonse status is NOT success.
31
+ #
32
+ # https://swagger.nature.global/#/default/post_1_devices__device__delete
33
+ def delete_device(device_id:)
34
+ post("devices/#{device_id}/delete")
35
+ end
36
+
37
+ # Update temperature offset.
38
+ # @param [String] device_id Remo id.
39
+ # @param [String] offset Temperature offset value added to the measured temperature.
40
+ # @return [String] Updated
41
+ # @raise [NatureRemo::ServerError] Raise error if resposonse status is NOT success.
42
+ #
43
+ # https://swagger.nature.global/#/default/post_1_devices__device__temperature_offset
44
+ def update_device_temperature_offset(device_id:, offset:)
45
+ post("devices/#{device_id}/temperature_offset", { offset: offset })
46
+ end
47
+
48
+ # Update humidity offset.
49
+ # @param [String] device_id Remo id.
50
+ # @param [String] offset Humidity offset value added to the measured humidity.
51
+ # @return [String] Updated
52
+ # @raise [NatureRemo::ServerError] Raise error if resposonse status is NOT success.
53
+ #
54
+ # https://swagger.nature.global/#/default/post_1_devices__device__humidity_offset
55
+ def update_device_humidity_offset(device_id:, offset:)
56
+ post("devices/#{device_id}/humidity_offset", { offset: offset })
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NatureRemo
4
+ module Endpoints
5
+ # Endpoints for user infomation
6
+ module Signals
7
+ # Fetch signals registered under this appliance.
8
+ # @param [String] appliance_id Appliance ID.
9
+ # @return [String] List of signals
10
+ # @raise [NatureRemo::ServerError] Raise error if resposonse status is NOT success.
11
+ #
12
+ # https://swagger.nature.global/#/default/get_1_appliances__appliance__signals
13
+ def signals(appliance_id:)
14
+ get("appliances/#{appliance_id}/signals")
15
+ end
16
+
17
+ # Create a signal under this appliance.
18
+ # @param [String] appliance_id Appliance ID.
19
+ # @param [String] message JSON serialized object describing infrared signals. Includes "data", "freq" and "format" keys.
20
+ # @param [String] image Basename of the image file included in the app. Ex: "ico_io"
21
+ # @param [String] name Signal name
22
+ # @return [String] Created signal
23
+ # @raise [NatureRemo::ServerError] Raise error if resposonse status is NOT success.
24
+ #
25
+ # https://swagger.nature.global/#/default/post_1_appliances__appliance__signals
26
+ def create_signal(appliance_id:, name:, image:, message:)
27
+ params = {
28
+ name: name,
29
+ image: image,
30
+ message: message
31
+ }
32
+
33
+ post("appliances/#{appliance_id}/signals", params)
34
+ end
35
+
36
+ # Reorder signals under this appliance.
37
+ # @param [String] appliance_id Appliance ID.
38
+ # @signal_ids [String] List of all signals' IDs comma separated
39
+ # @return [String] Reordered signals
40
+ # @raise [NatureRemo::ServerError] Raise error if resposonse status is NOT success.
41
+ #
42
+ # https://swagger.nature.global/#/default/post_1_appliances__appliance__signal_orders
43
+ def update_signal_orders(appliance_id:, signal_ids:)
44
+ post("appliances/#{appliance_id}/signal_orders", { signals: signal_ids })
45
+ end
46
+
47
+ # Update infrared signal.
48
+ # @param [String] signal_id Signal ID.
49
+ # @param [String] image Basename of the image file included in the app. Ex: "ico_io"
50
+ # @param [String] name Signal name
51
+ # @return [String] Updated infrared signal
52
+ # @raise [NatureRemo::ServerError] Raise error if resposonse status is NOT success.
53
+ #
54
+ # https://swagger.nature.global/#/default/post_1_signals__signal_
55
+ def update_signal(signal_id:, name:, image:)
56
+ post("signals/#{signal_id}", { name: name, image: image })
57
+ end
58
+
59
+ # Delete an infrared signal.
60
+ # @param [String] signal_id Signal ID.
61
+ # @return [String] Deleted a signal
62
+ # @raise [NatureRemo::ServerError] Raise error if resposonse status is NOT success.
63
+ #
64
+ # https://swagger.nature.global/#/default/post_1_signals__signal__delete
65
+ def delete_signal(signal_id:)
66
+ post("signals/#{signal_id}/delete")
67
+ end
68
+
69
+ # Send infrared signal.
70
+ # @param [String] signal_id Signal ID.
71
+ # @return [String] Successfully sent infrared signal
72
+ # @raise [NatureRemo::ServerError] Raise error if resposonse status is NOT success.
73
+ #
74
+ # https://swagger.nature.global/#/default/post_1_signals__signal__send
75
+ def send_signal(signal_id:)
76
+ post("signals/#{signal_id}/send")
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NatureRemo
4
+ module Endpoints
5
+ # Endpoints for user infomation
6
+ module Users
7
+ # Fetch the authenticated user's information.
8
+ # @return [String] User information.
9
+ # @raise [NatureRemo::ServerError] Raise error if resposonse status is NOT success.
10
+ #
11
+ # https://swagger.nature.global/#/default/get_1_users_me
12
+ def user_me
13
+ get('users/me')
14
+ end
15
+
16
+ # Update authenticated user nickname.
17
+ # @param [String] nickname New user's nickname.
18
+ # @return [String] Updated user information.
19
+ # @raise [NatureRemo::ServerError] Raise error if resposonse status is NOT success.
20
+ #
21
+ # https://swagger.nature.global/#/default/post_1_users_me
22
+ def update_user_me(nickname:)
23
+ post('users/me', { nickname: nickname })
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'endpoints/appliances'
4
+ require_relative 'endpoints/devices'
5
+ require_relative 'endpoints/signals'
6
+ require_relative 'endpoints/users'
7
+
8
+ module NatureRemo
9
+ # Endpoints of Nature Remo Cloud API
10
+ module Endpoints
11
+ include Appliances
12
+ include Devices
13
+ include Signals
14
+ include Users
15
+ end
16
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NatureRemo
4
+ # Error class for Nature Remo API
5
+ class Error < StandardError
6
+ attr_reader :env, :url, :status, :headers, :body, :error_code
7
+
8
+ # @param env Faraday::Env
9
+ def initialize(env:)
10
+ @env = env
11
+ @url = env.url
12
+ @status = env.status
13
+ @headers = env.response_headers
14
+ @body = env.body
15
+
16
+ msg = "request failed with status code #{@status}"
17
+ msg += ", #{@body}" if @body
18
+
19
+ super(msg)
20
+ end
21
+ end
22
+
23
+ # Raised on errors in the 400s status
24
+ class ClientError < Error; end
25
+ # Raised when Nature Remo API returns a 400 HTTP status code
26
+ class BadRequest < ClientError; end
27
+ # Raised when Nature Remo API returns a 401 HTTP status code
28
+ class Unauthorized < ClientError; end
29
+ # Raised when Nature Remo API returns a 403 HTTP status code
30
+ class Forbidden < ClientError; end
31
+ # Raised when Nature Remo API returns a 404 HTTP status code
32
+ class NotFound < ClientError; end
33
+ # Raised when Nature Remo API returns a 405 HTTP status code
34
+ class MethodNotAllowed < ClientError; end
35
+ # Raised when Nature Remo API returns a 413 HTTP status code
36
+ class PayloadTooLarge < ClientError; end
37
+ # Raised when Nature Remo API returns a 422 HTTP status code
38
+ class UnprocessableEntity < ClientError; end
39
+ # Raised when Nature Remo API returns a 429 HTTP status code
40
+ class TooManyRequests < ClientError; end
41
+
42
+ # Raised on errors iin the 500s status
43
+ class ServerError < Error; end
44
+ # Raised when Nature Remo API returns a 500 HTTP status code
45
+ class InternalServerError < ServerError; end
46
+ # Raised when Nature Remo API returns a 502 HTTP status code
47
+ class BadGateway < ServerError; end
48
+ # Raised when Nature Remo API returns a 503 HTTP status code
49
+ class ServiceUnavailable < ServerError; end
50
+ # Raised when Nature Remo API returns a 504 HTTP status code
51
+ class GatewayTimeout < ServerError; end
52
+
53
+ # Raised when Nature Remo API returns without HTTP status code
54
+ class NilStatusError < ServerError; end
55
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'errors'
4
+
5
+ module NatureRemo
6
+ # RaiseError is a Faraday response middleware that raises an error if NatureRemo returns non-2xx status codes.
7
+ class RaiseError < Faraday::Middleware
8
+ def on_complete(env) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
9
+ case env[:status]
10
+ when 400
11
+ raise NatureRemo::BadRequest.new(env: env)
12
+ when 401
13
+ raise NatureRemo::Unauthorized.new(env: env)
14
+ when 403
15
+ raise NatureRemo::Forbidden.new(env: env)
16
+ when 404
17
+ raise NatureRemo::NotFound.new(env: env)
18
+ when 405
19
+ raise NatureRemo::MethodNotAllowed.new(env: env)
20
+ when 413
21
+ raise NatureRemo::PayloadTooLarge.new(env: env)
22
+ when 422
23
+ raise NatureRemo::UnprocessableEntity.new(env: env)
24
+ when 429
25
+ raise NatureRemo::TooManyRequests.new(env: env)
26
+ when 400..499
27
+ raise NatureRemo::ClientError.new(env: env)
28
+ when 500
29
+ raise NatureRemo::InternalServerError.new(env: env)
30
+ when 502
31
+ raise NatureRemo::BadGateway.new(env: env)
32
+ when 503
33
+ raise NatureRemo::ServiceUnavailable.new(env: env)
34
+ when 504
35
+ raise NatureRemo::GatewayTimeout.new(env: env)
36
+ when 500..599
37
+ raise NatureRemo::ServerError.new(env: env)
38
+ when nil
39
+ raise NatureRemo::NilStatusError.new(env: env)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NatureRemo
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'faraday'
4
+
5
+ require_relative 'nature_remo/client'
6
+ require_relative 'nature_remo/endpoints'
7
+ require_relative 'nature_remo/errors'
8
+ require_relative 'nature_remo/raise_error'
9
+ require_relative 'nature_remo/version'
metadata ADDED
@@ -0,0 +1,170 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nature_remo_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Takumi Yoshida
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-10-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '13.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '13.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.22'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.22'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.6'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.6'
97
+ - !ruby/object:Gem::Dependency
98
+ name: steep
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.1'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.0'
125
+ description: Nature Remo API client for ruby.
126
+ email:
127
+ - umibooose@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - README.md
133
+ - Rakefile
134
+ - lib/nature_remo/client.rb
135
+ - lib/nature_remo/endpoints.rb
136
+ - lib/nature_remo/endpoints/appliances.rb
137
+ - lib/nature_remo/endpoints/devices.rb
138
+ - lib/nature_remo/endpoints/signals.rb
139
+ - lib/nature_remo/endpoints/users.rb
140
+ - lib/nature_remo/errors.rb
141
+ - lib/nature_remo/raise_error.rb
142
+ - lib/nature_remo/version.rb
143
+ - lib/nature_remo_client.rb
144
+ homepage: http://github.com/craftscat/nature_remo_client
145
+ licenses:
146
+ - MIT
147
+ metadata:
148
+ homepage_uri: http://github.com/craftscat/nature_remo_client
149
+ source_code_uri: http://github.com/craftscat/nature_remo_client
150
+ changelog_uri: http://github.com/craftscat/nature_remo_client/blob/main/CHANGELOG.md
151
+ post_install_message:
152
+ rdoc_options: []
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: 2.6.0
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ requirements: []
166
+ rubygems_version: 3.3.23
167
+ signing_key:
168
+ specification_version: 4
169
+ summary: Nature Remo API client for ruby.
170
+ test_files: []