weather_API_Assignment 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.
Files changed (30) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +187 -0
  4. data/lib/weather_api_assignment.rb +46 -0
  5. data/lib/weather_api_assignment/api_helper.rb +275 -0
  6. data/lib/weather_api_assignment/configuration.rb +24 -0
  7. data/lib/weather_api_assignment/controllers/base_controller.rb +51 -0
  8. data/lib/weather_api_assignment/controllers/weather_ap_is_controller.rb +121 -0
  9. data/lib/weather_api_assignment/exceptions/api_exception.rb +20 -0
  10. data/lib/weather_api_assignment/http/auth/custom_query_auth.rb +16 -0
  11. data/lib/weather_api_assignment/http/faraday_client.rb +64 -0
  12. data/lib/weather_api_assignment/http/http_call_back.rb +24 -0
  13. data/lib/weather_api_assignment/http/http_client.rb +104 -0
  14. data/lib/weather_api_assignment/http/http_context.rb +20 -0
  15. data/lib/weather_api_assignment/http/http_method_enum.rb +13 -0
  16. data/lib/weather_api_assignment/http/http_request.rb +50 -0
  17. data/lib/weather_api_assignment/http/http_response.rb +23 -0
  18. data/lib/weather_api_assignment/models/base_model.rb +36 -0
  19. data/lib/weather_api_assignment/models/clouds.rb +35 -0
  20. data/lib/weather_api_assignment/models/coord.rb +44 -0
  21. data/lib/weather_api_assignment/models/lang_enum.rb +20 -0
  22. data/lib/weather_api_assignment/models/main.rb +98 -0
  23. data/lib/weather_api_assignment/models/mode_enum.rb +20 -0
  24. data/lib/weather_api_assignment/models/sys.rb +80 -0
  25. data/lib/weather_api_assignment/models/units_enum.rb +20 -0
  26. data/lib/weather_api_assignment/models/weather.rb +62 -0
  27. data/lib/weather_api_assignment/models/weather_api_response.rb +150 -0
  28. data/lib/weather_api_assignment/models/wind.rb +44 -0
  29. data/lib/weather_api_assignment/weather_api_assignment_client.rb +27 -0
  30. metadata +167 -0
@@ -0,0 +1,13 @@
1
+ # weather_api_assignment
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v2.0 ( https://apimatic.io ).
5
+
6
+ module WeatherApiAssignment
7
+ # HTTP Methods Enumeration.
8
+ class HttpMethodEnum
9
+ HTTPMETHODENUM = [GET = 'GET'.freeze, POST = 'POST'.freeze,
10
+ PUT = 'PUT'.freeze, PATCH = 'PATCH'.freeze,
11
+ DELETE = 'DELETE'.freeze, HEAD = 'HEAD'.freeze].freeze
12
+ end
13
+ end
@@ -0,0 +1,50 @@
1
+ # weather_api_assignment
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v2.0 ( https://apimatic.io ).
5
+
6
+ module WeatherApiAssignment
7
+ # Represents a single Http Request.
8
+ class HttpRequest
9
+ attr_accessor :http_method, :query_url, :headers,
10
+ :parameters, :username, :password
11
+
12
+ # The constructor.
13
+ # @param [HttpMethodEnum] The HTTP method.
14
+ # @param [String] The URL to send the request to.
15
+ # @param [Hash, Optional] The headers for the HTTP Request.
16
+ # @param [Hash, Optional] The parameters for the HTTP Request.
17
+ def initialize(http_method,
18
+ query_url,
19
+ headers: {},
20
+ parameters: {})
21
+ @http_method = http_method
22
+ @query_url = query_url
23
+ @headers = headers
24
+ @parameters = parameters
25
+ end
26
+
27
+ # Add a header to the HttpRequest.
28
+ # @param [String] The name of the header.
29
+ # @param [String] The value of the header.
30
+ def add_header(name, value)
31
+ @headers[name] = value
32
+ end
33
+
34
+ # Add a parameter to the HttpRequest.
35
+ # @param [String] The name of the parameter.
36
+ # @param [String] The value of the parameter.
37
+ def add_parameter(name, value)
38
+ @parameters[name] = value
39
+ end
40
+
41
+ # Add a query parameter to the HttpRequest.
42
+ # @param [String] The name of the query parameter.
43
+ # @param [String] The value of the query parameter.
44
+ def add_query_parameter(name, value)
45
+ @query_url = APIHelper.append_url_with_query_parameters(@query_url,
46
+ name => value)
47
+ @query_url = APIHelper.clean_url(@query_url)
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,23 @@
1
+ # weather_api_assignment
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v2.0 ( https://apimatic.io ).
5
+
6
+ module WeatherApiAssignment
7
+ # Http response received.
8
+ class HttpResponse
9
+ attr_accessor :status_code, :headers, :raw_body
10
+
11
+ # The constructor
12
+ # @param [Integer] The status code returned by the server.
13
+ # @param [Hash] The headers sent by the server in the response.
14
+ # @param [String] The raw body of the response.
15
+ def initialize(status_code,
16
+ headers,
17
+ raw_body)
18
+ @status_code = status_code
19
+ @headers = headers
20
+ @raw_body = raw_body
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,36 @@
1
+ # weather_api_assignment
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v2.0 ( https://apimatic.io ).
5
+
6
+ module WeatherApiAssignment
7
+ # Base model.
8
+ class BaseModel
9
+ # Returns a Hash representation of the current object.
10
+ def to_hash
11
+ hash = {}
12
+ instance_variables.each do |name|
13
+ value = instance_variable_get(name)
14
+ name = name[1..-1]
15
+ key = self.class.names.key?(name) ? self.class.names[name] : name
16
+ if value.instance_of? Array
17
+ hash[key] = value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v }
18
+ elsif value.instance_of? Hash
19
+ hash[key] = {}
20
+ value.each do |k, v|
21
+ hash[key][k] = v.is_a?(BaseModel) ? v.to_hash : v
22
+ end
23
+ else
24
+ hash[key] = value.is_a?(BaseModel) ? value.to_hash : value
25
+ end
26
+ end
27
+ hash
28
+ end
29
+
30
+ # Returns a JSON representation of the curent object.
31
+ def to_json(options = {})
32
+ hash = to_hash
33
+ hash.to_json(options)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,35 @@
1
+ # weather_api_assignment
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v2.0 ( https://apimatic.io ).
5
+
6
+ module WeatherApiAssignment
7
+ # This model contains the cloud information.
8
+ class Clouds < BaseModel
9
+ # This field contains overall stats information
10
+ # @return [Integer]
11
+ attr_accessor :all
12
+
13
+ # A mapping from model property names to API property names.
14
+ def self.names
15
+ @_hash = {} if @_hash.nil?
16
+ @_hash['all'] = 'all'
17
+ @_hash
18
+ end
19
+
20
+ def initialize(all = nil)
21
+ @all = all
22
+ end
23
+
24
+ # Creates an instance of the object from a hash.
25
+ def self.from_hash(hash)
26
+ return nil unless hash
27
+
28
+ # Extract variables from the hash.
29
+ all = hash['all']
30
+
31
+ # Create object from extracted values.
32
+ Clouds.new(all)
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,44 @@
1
+ # weather_api_assignment
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v2.0 ( https://apimatic.io ).
5
+
6
+ module WeatherApiAssignment
7
+ # This model contains the longitude and latitude
8
+ class Coord < BaseModel
9
+ # This field contains the longitude
10
+ # @return [Float]
11
+ attr_accessor :lon
12
+
13
+ # This field contains the latitude
14
+ # @return [Float]
15
+ attr_accessor :lat
16
+
17
+ # A mapping from model property names to API property names.
18
+ def self.names
19
+ @_hash = {} if @_hash.nil?
20
+ @_hash['lon'] = 'lon'
21
+ @_hash['lat'] = 'lat'
22
+ @_hash
23
+ end
24
+
25
+ def initialize(lon = nil,
26
+ lat = nil)
27
+ @lon = lon
28
+ @lat = lat
29
+ end
30
+
31
+ # Creates an instance of the object from a hash.
32
+ def self.from_hash(hash)
33
+ return nil unless hash
34
+
35
+ # Extract variables from the hash.
36
+ lon = hash['lon']
37
+ lat = hash['lat']
38
+
39
+ # Create object from extracted values.
40
+ Coord.new(lon,
41
+ lat)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,20 @@
1
+ # weather_api_assignment
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v2.0 ( https://apimatic.io ).
5
+
6
+ module WeatherApiAssignment
7
+ # This defines the language of response
8
+ class LANGEnum
9
+ LANG_ENUM = [
10
+ # Afrikaans
11
+ AF = 'af'.freeze,
12
+
13
+ # Danish
14
+ DA = 'da'.freeze,
15
+
16
+ # English
17
+ EN = 'en'.freeze
18
+ ].freeze
19
+ end
20
+ end
@@ -0,0 +1,98 @@
1
+ # weather_api_assignment
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v2.0 ( https://apimatic.io ).
5
+
6
+ module WeatherApiAssignment
7
+ # This model contains the digital values of weather.
8
+ class Main < BaseModel
9
+ # This field contains the current temperature
10
+ # @return [Float]
11
+ attr_accessor :temp
12
+
13
+ # This field contains the feels like attribute of temperature
14
+ # @return [Float]
15
+ attr_accessor :feels_like
16
+
17
+ # This field contains the pressure
18
+ # @return [Float]
19
+ attr_accessor :pressure
20
+
21
+ # This field contains the humidity
22
+ # @return [Float]
23
+ attr_accessor :humidity
24
+
25
+ # This field contains the minimum temperature
26
+ # @return [Float]
27
+ attr_accessor :temp_min
28
+
29
+ # This field contains the maximum temperature
30
+ # @return [Float]
31
+ attr_accessor :temp_max
32
+
33
+ # This field contains the information height with respect to sea level
34
+ # @return [Float]
35
+ attr_accessor :sea_level
36
+
37
+ # This field contains the information height with respect to ground level
38
+ # @return [Float]
39
+ attr_accessor :grnd_level
40
+
41
+ # A mapping from model property names to API property names.
42
+ def self.names
43
+ @_hash = {} if @_hash.nil?
44
+ @_hash['temp'] = 'temp'
45
+ @_hash['feels_like'] = 'feels_like'
46
+ @_hash['pressure'] = 'pressure'
47
+ @_hash['humidity'] = 'humidity'
48
+ @_hash['temp_min'] = 'temp_min'
49
+ @_hash['temp_max'] = 'temp_max'
50
+ @_hash['sea_level'] = 'sea_level'
51
+ @_hash['grnd_level'] = 'grnd_level'
52
+ @_hash
53
+ end
54
+
55
+ def initialize(temp = nil,
56
+ pressure = nil,
57
+ humidity = nil,
58
+ temp_min = nil,
59
+ temp_max = nil,
60
+ feels_like = nil,
61
+ sea_level = nil,
62
+ grnd_level = nil)
63
+ @temp = temp
64
+ @feels_like = feels_like
65
+ @pressure = pressure
66
+ @humidity = humidity
67
+ @temp_min = temp_min
68
+ @temp_max = temp_max
69
+ @sea_level = sea_level
70
+ @grnd_level = grnd_level
71
+ end
72
+
73
+ # Creates an instance of the object from a hash.
74
+ def self.from_hash(hash)
75
+ return nil unless hash
76
+
77
+ # Extract variables from the hash.
78
+ temp = hash['temp']
79
+ pressure = hash['pressure']
80
+ humidity = hash['humidity']
81
+ temp_min = hash['temp_min']
82
+ temp_max = hash['temp_max']
83
+ feels_like = hash['feels_like']
84
+ sea_level = hash['sea_level']
85
+ grnd_level = hash['grnd_level']
86
+
87
+ # Create object from extracted values.
88
+ Main.new(temp,
89
+ pressure,
90
+ humidity,
91
+ temp_min,
92
+ temp_max,
93
+ feels_like,
94
+ sea_level,
95
+ grnd_level)
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,20 @@
1
+ # weather_api_assignment
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v2.0 ( https://apimatic.io ).
5
+
6
+ module WeatherApiAssignment
7
+ # Define the mode sent in the request to get the response in provided format
8
+ class MODEEnum
9
+ MODE_ENUM = [
10
+ # This is XML mode
11
+ XML = 'XML'.freeze,
12
+
13
+ # This is HTML mode
14
+ HTML = 'HTML'.freeze,
15
+
16
+ # This is JSON mode
17
+ JSON = 'JSON'.freeze
18
+ ].freeze
19
+ end
20
+ end
@@ -0,0 +1,80 @@
1
+ # weather_api_assignment
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v2.0 ( https://apimatic.io ).
5
+
6
+ module WeatherApiAssignment
7
+ # This model contains the country, sunset and sunrise information.
8
+ class Sys < BaseModel
9
+ # This field contains the type of information
10
+ # @return [Integer]
11
+ attr_accessor :type
12
+
13
+ # This field contains the identifier
14
+ # @return [Integer]
15
+ attr_accessor :id
16
+
17
+ # This field contains the information message
18
+ # @return [Float]
19
+ attr_accessor :message
20
+
21
+ # This field contains the country code
22
+ # @return [String]
23
+ attr_accessor :country
24
+
25
+ # This field contains the information of sunrise in given city
26
+ # @return [Long]
27
+ attr_accessor :sunrise
28
+
29
+ # This field contains the information of sunset in given city
30
+ # @return [Long]
31
+ attr_accessor :sunset
32
+
33
+ # A mapping from model property names to API property names.
34
+ def self.names
35
+ @_hash = {} if @_hash.nil?
36
+ @_hash['type'] = 'type'
37
+ @_hash['id'] = 'id'
38
+ @_hash['message'] = 'message'
39
+ @_hash['country'] = 'country'
40
+ @_hash['sunrise'] = 'sunrise'
41
+ @_hash['sunset'] = 'sunset'
42
+ @_hash
43
+ end
44
+
45
+ def initialize(sunrise = nil,
46
+ sunset = nil,
47
+ type = nil,
48
+ id = nil,
49
+ message = nil,
50
+ country = nil)
51
+ @type = type
52
+ @id = id
53
+ @message = message
54
+ @country = country
55
+ @sunrise = sunrise
56
+ @sunset = sunset
57
+ end
58
+
59
+ # Creates an instance of the object from a hash.
60
+ def self.from_hash(hash)
61
+ return nil unless hash
62
+
63
+ # Extract variables from the hash.
64
+ sunrise = hash['sunrise']
65
+ sunset = hash['sunset']
66
+ type = hash['type']
67
+ id = hash['id']
68
+ message = hash['message']
69
+ country = hash['country']
70
+
71
+ # Create object from extracted values.
72
+ Sys.new(sunrise,
73
+ sunset,
74
+ type,
75
+ id,
76
+ message,
77
+ country)
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,20 @@
1
+ # weather_api_assignment
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v2.0 ( https://apimatic.io ).
5
+
6
+ module WeatherApiAssignment
7
+ # Defined the units sent in request
8
+ class UNITSEnum
9
+ UNITS_ENUM = [
10
+ # This is standard unit
11
+ STANDARD = 'standard'.freeze,
12
+
13
+ # This is metric unit
14
+ METRIC = 'metric'.freeze,
15
+
16
+ # This is imperial unit
17
+ IMPERIAL = 'imperial'.freeze
18
+ ].freeze
19
+ end
20
+ end