reliefweb-api 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/README.md +163 -0
  4. data/Rakefile +8 -0
  5. data/config.json +8 -0
  6. data/docs/Category.md +9 -0
  7. data/docs/CountriesApi.md +202 -0
  8. data/docs/Country.md +12 -0
  9. data/docs/Date.md +10 -0
  10. data/docs/Disaster.md +20 -0
  11. data/docs/DisastersApi.md +202 -0
  12. data/docs/DiscoveryApi.md +88 -0
  13. data/docs/Error.md +9 -0
  14. data/docs/ErrorDefinition.md +7 -0
  15. data/docs/FacetsFieldPost.md +7 -0
  16. data/docs/FacetsFilterPost.md +7 -0
  17. data/docs/FacetsIntervalPost.md +7 -0
  18. data/docs/FacetsLimitPost.md +7 -0
  19. data/docs/FacetsNamePost.md +7 -0
  20. data/docs/FacetsSortPost.md +7 -0
  21. data/docs/FieldsExcludePost.md +7 -0
  22. data/docs/FieldsIncludePost.md +7 -0
  23. data/docs/File.md +12 -0
  24. data/docs/FilterConditionsPost.md +7 -0
  25. data/docs/FilterFieldPost.md +7 -0
  26. data/docs/FilterNegatePost.md +7 -0
  27. data/docs/FilterOperatorPost.md +7 -0
  28. data/docs/FilterValuePost.md +7 -0
  29. data/docs/Job.md +23 -0
  30. data/docs/JobsApi.md +202 -0
  31. data/docs/Language.md +10 -0
  32. data/docs/LimitPost.md +7 -0
  33. data/docs/Location.md +8 -0
  34. data/docs/OffsetPost.md +7 -0
  35. data/docs/PostParams.md +28 -0
  36. data/docs/PresetPost.md +7 -0
  37. data/docs/ProfilePost.md +7 -0
  38. data/docs/QueryFieldsPost.md +7 -0
  39. data/docs/QueryOperatorPost.md +7 -0
  40. data/docs/QueryValuePost.md +7 -0
  41. data/docs/Report.md +19 -0
  42. data/docs/ReportsApi.md +202 -0
  43. data/docs/SortPost.md +7 -0
  44. data/docs/Source.md +14 -0
  45. data/docs/SourcesApi.md +202 -0
  46. data/docs/Training.md +23 -0
  47. data/docs/TrainingApi.md +202 -0
  48. data/git_push.sh +55 -0
  49. data/lib/reliefweb-api.rb +81 -0
  50. data/lib/reliefweb-api/api/countries_api.rb +277 -0
  51. data/lib/reliefweb-api/api/disasters_api.rb +277 -0
  52. data/lib/reliefweb-api/api/discovery_api.rb +113 -0
  53. data/lib/reliefweb-api/api/jobs_api.rb +277 -0
  54. data/lib/reliefweb-api/api/reports_api.rb +277 -0
  55. data/lib/reliefweb-api/api/sources_api.rb +277 -0
  56. data/lib/reliefweb-api/api/training_api.rb +277 -0
  57. data/lib/reliefweb-api/api_client.rb +388 -0
  58. data/lib/reliefweb-api/api_error.rb +38 -0
  59. data/lib/reliefweb-api/configuration.rb +202 -0
  60. data/lib/reliefweb-api/models/category.rb +192 -0
  61. data/lib/reliefweb-api/models/country.rb +220 -0
  62. data/lib/reliefweb-api/models/date.rb +202 -0
  63. data/lib/reliefweb-api/models/disaster.rb +299 -0
  64. data/lib/reliefweb-api/models/error.rb +192 -0
  65. data/lib/reliefweb-api/models/error_definition.rb +174 -0
  66. data/lib/reliefweb-api/models/facets_field_post.rb +175 -0
  67. data/lib/reliefweb-api/models/facets_filter_post.rb +175 -0
  68. data/lib/reliefweb-api/models/facets_interval_post.rb +32 -0
  69. data/lib/reliefweb-api/models/facets_limit_post.rb +175 -0
  70. data/lib/reliefweb-api/models/facets_name_post.rb +175 -0
  71. data/lib/reliefweb-api/models/facets_sort_post.rb +175 -0
  72. data/lib/reliefweb-api/models/fields_exclude_post.rb +175 -0
  73. data/lib/reliefweb-api/models/fields_include_post.rb +175 -0
  74. data/lib/reliefweb-api/models/file.rb +219 -0
  75. data/lib/reliefweb-api/models/filter_conditions_post.rb +175 -0
  76. data/lib/reliefweb-api/models/filter_field_post.rb +175 -0
  77. data/lib/reliefweb-api/models/filter_negate_post.rb +175 -0
  78. data/lib/reliefweb-api/models/filter_operator_post.rb +30 -0
  79. data/lib/reliefweb-api/models/filter_value_post.rb +175 -0
  80. data/lib/reliefweb-api/models/job.rb +330 -0
  81. data/lib/reliefweb-api/models/language.rb +201 -0
  82. data/lib/reliefweb-api/models/limit_post.rb +175 -0
  83. data/lib/reliefweb-api/models/location.rb +183 -0
  84. data/lib/reliefweb-api/models/offset_post.rb +175 -0
  85. data/lib/reliefweb-api/models/post_params.rb +363 -0
  86. data/lib/reliefweb-api/models/preset_post.rb +31 -0
  87. data/lib/reliefweb-api/models/profile_post.rb +31 -0
  88. data/lib/reliefweb-api/models/query_fields_post.rb +175 -0
  89. data/lib/reliefweb-api/models/query_operator_post.rb +30 -0
  90. data/lib/reliefweb-api/models/query_value_post.rb +175 -0
  91. data/lib/reliefweb-api/models/report.rb +293 -0
  92. data/lib/reliefweb-api/models/sort_post.rb +175 -0
  93. data/lib/reliefweb-api/models/source.rb +237 -0
  94. data/lib/reliefweb-api/models/training.rb +330 -0
  95. data/lib/reliefweb-api/version.rb +15 -0
  96. data/reliefweb-api.gemspec +45 -0
  97. data/spec/api/countries_api_spec.rb +94 -0
  98. data/spec/api/disasters_api_spec.rb +94 -0
  99. data/spec/api/discovery_api_spec.rb +55 -0
  100. data/spec/api/jobs_api_spec.rb +94 -0
  101. data/spec/api/reports_api_spec.rb +94 -0
  102. data/spec/api/sources_api_spec.rb +94 -0
  103. data/spec/api/training_api_spec.rb +94 -0
  104. data/spec/api_client_spec.rb +226 -0
  105. data/spec/configuration_spec.rb +42 -0
  106. data/spec/models/category_spec.rb +47 -0
  107. data/spec/models/country_spec.rb +65 -0
  108. data/spec/models/date_spec.rb +53 -0
  109. data/spec/models/disaster_spec.rb +113 -0
  110. data/spec/models/error_definition_spec.rb +35 -0
  111. data/spec/models/error_spec.rb +47 -0
  112. data/spec/models/facets_field_post_spec.rb +35 -0
  113. data/spec/models/facets_filter_post_spec.rb +35 -0
  114. data/spec/models/facets_interval_post_spec.rb +35 -0
  115. data/spec/models/facets_limit_post_spec.rb +35 -0
  116. data/spec/models/facets_name_post_spec.rb +35 -0
  117. data/spec/models/facets_sort_post_spec.rb +35 -0
  118. data/spec/models/fields_exclude_post_spec.rb +35 -0
  119. data/spec/models/fields_include_post_spec.rb +35 -0
  120. data/spec/models/file_spec.rb +65 -0
  121. data/spec/models/filter_conditions_post_spec.rb +35 -0
  122. data/spec/models/filter_field_post_spec.rb +35 -0
  123. data/spec/models/filter_negate_post_spec.rb +35 -0
  124. data/spec/models/filter_operator_post_spec.rb +35 -0
  125. data/spec/models/filter_value_post_spec.rb +35 -0
  126. data/spec/models/job_spec.rb +131 -0
  127. data/spec/models/language_spec.rb +53 -0
  128. data/spec/models/limit_post_spec.rb +35 -0
  129. data/spec/models/location_spec.rb +41 -0
  130. data/spec/models/offset_post_spec.rb +35 -0
  131. data/spec/models/post_params_spec.rb +161 -0
  132. data/spec/models/preset_post_spec.rb +35 -0
  133. data/spec/models/profile_post_spec.rb +35 -0
  134. data/spec/models/query_fields_post_spec.rb +35 -0
  135. data/spec/models/query_operator_post_spec.rb +35 -0
  136. data/spec/models/query_value_post_spec.rb +35 -0
  137. data/spec/models/report_spec.rb +107 -0
  138. data/spec/models/sort_post_spec.rb +35 -0
  139. data/spec/models/source_spec.rb +77 -0
  140. data/spec/models/training_spec.rb +131 -0
  141. data/spec/spec_helper.rb +111 -0
  142. metadata +416 -0
@@ -0,0 +1,31 @@
1
+ =begin
2
+ #The ReliefWeb API
3
+
4
+ #Interactive API documentation for the data API of Reliefweb.int. ReliefWeb is a leading source of information on global crises and disasters.<br><br> Our continuous coverage and archive going back to the 1970s makes ReliefWeb an unparalleled resource for both current and historical data on humanitarian response.<br><br> The vast majority of content on ReliefWeb has been contributed by humanitarian partners. We owe it to the community to make data more accessible and reusable, so that developers can build tools that increase exposure for valuable content and facilitate analysis for better decisions.
5
+
6
+ OpenAPI spec version: v1
7
+ Contact: api@reliefweb.int
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.12
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module ReliefWebAPI
16
+ class PresetPost
17
+
18
+ ANALYSIS = 'analysis'.freeze
19
+ LATEST = 'latest'.freeze
20
+ MINIMAL = 'minimal'.freeze
21
+
22
+ # Builds the enum from string
23
+ # @param [String] The enum value in the form of the string
24
+ # @return [String] The enum value
25
+ def build_from_hash(value)
26
+ constantValues = PresetPost.constants.select { |c| PresetPost::const_get(c) == value }
27
+ raise "Invalid ENUM value #{value} for class #PresetPost" if constantValues.empty?
28
+ value
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ =begin
2
+ #The ReliefWeb API
3
+
4
+ #Interactive API documentation for the data API of Reliefweb.int. ReliefWeb is a leading source of information on global crises and disasters.<br><br> Our continuous coverage and archive going back to the 1970s makes ReliefWeb an unparalleled resource for both current and historical data on humanitarian response.<br><br> The vast majority of content on ReliefWeb has been contributed by humanitarian partners. We owe it to the community to make data more accessible and reusable, so that developers can build tools that increase exposure for valuable content and facilitate analysis for better decisions.
5
+
6
+ OpenAPI spec version: v1
7
+ Contact: api@reliefweb.int
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.12
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module ReliefWebAPI
16
+ class ProfilePost
17
+
18
+ FULL = 'full'.freeze
19
+ LIST = 'list'.freeze
20
+ MINIMAL = 'minimal'.freeze
21
+
22
+ # Builds the enum from string
23
+ # @param [String] The enum value in the form of the string
24
+ # @return [String] The enum value
25
+ def build_from_hash(value)
26
+ constantValues = ProfilePost.constants.select { |c| ProfilePost::const_get(c) == value }
27
+ raise "Invalid ENUM value #{value} for class #ProfilePost" if constantValues.empty?
28
+ value
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,175 @@
1
+ =begin
2
+ #The ReliefWeb API
3
+
4
+ #Interactive API documentation for the data API of Reliefweb.int. ReliefWeb is a leading source of information on global crises and disasters.<br><br> Our continuous coverage and archive going back to the 1970s makes ReliefWeb an unparalleled resource for both current and historical data on humanitarian response.<br><br> The vast majority of content on ReliefWeb has been contributed by humanitarian partners. We owe it to the community to make data more accessible and reusable, so that developers can build tools that increase exposure for valuable content and facilitate analysis for better decisions.
5
+
6
+ OpenAPI spec version: v1
7
+ Contact: api@reliefweb.int
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.12
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module ReliefWebAPI
16
+ # Specify which fields to target with your search. You may use boost syntax here, see the Advanced API Usage documentation.
17
+ class QueryFieldsPost
18
+ # Attribute mapping from ruby-style variable name to JSON key.
19
+ def self.attribute_map
20
+ {
21
+ }
22
+ end
23
+
24
+ # Attribute type mapping.
25
+ def self.swagger_types
26
+ {
27
+ }
28
+ end
29
+
30
+ # Initializes the object
31
+ # @param [Hash] attributes Model attributes in the form of hash
32
+ def initialize(attributes = {})
33
+ return unless attributes.is_a?(Hash)
34
+
35
+ # convert string to symbol for hash key
36
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
37
+ end
38
+
39
+ # Show invalid properties with the reasons. Usually used together with valid?
40
+ # @return Array for valid properties with the reasons
41
+ def list_invalid_properties
42
+ invalid_properties = Array.new
43
+ invalid_properties
44
+ end
45
+
46
+ # Check to see if the all the properties in the model are valid
47
+ # @return true if the model is valid
48
+ def valid?
49
+ true
50
+ end
51
+
52
+ # Checks equality by comparing each attribute.
53
+ # @param [Object] Object to be compared
54
+ def ==(o)
55
+ return true if self.equal?(o)
56
+ self.class == o.class
57
+ end
58
+
59
+ # @see the `==` method
60
+ # @param [Object] Object to be compared
61
+ def eql?(o)
62
+ self == o
63
+ end
64
+
65
+ # Calculates hash code according to all attributes.
66
+ # @return [Fixnum] Hash code
67
+ def hash
68
+ [].hash
69
+ end
70
+
71
+ # Builds the object from hash
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ # @return [Object] Returns the model itself
74
+ def build_from_hash(attributes)
75
+ return nil unless attributes.is_a?(Hash)
76
+ self.class.swagger_types.each_pair do |key, type|
77
+ if type =~ /\AArray<(.*)>/i
78
+ # check to ensure the input is an array given that the the attribute
79
+ # is documented as an array but the input is not
80
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
81
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
82
+ end
83
+ elsif !attributes[self.class.attribute_map[key]].nil?
84
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
85
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
86
+ end
87
+
88
+ self
89
+ end
90
+
91
+ # Deserializes the data based on type
92
+ # @param string type Data type
93
+ # @param string value Value to be deserialized
94
+ # @return [Object] Deserialized data
95
+ def _deserialize(type, value)
96
+ case type.to_sym
97
+ when :DateTime
98
+ DateTime.parse(value)
99
+ when :Date
100
+ Date.parse(value)
101
+ when :String
102
+ value.to_s
103
+ when :Integer
104
+ value.to_i
105
+ when :Float
106
+ value.to_f
107
+ when :BOOLEAN
108
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
109
+ true
110
+ else
111
+ false
112
+ end
113
+ when :Object
114
+ # generic object (usually a Hash), return directly
115
+ value
116
+ when /\AArray<(?<inner_type>.+)>\z/
117
+ inner_type = Regexp.last_match[:inner_type]
118
+ value.map { |v| _deserialize(inner_type, v) }
119
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
120
+ k_type = Regexp.last_match[:k_type]
121
+ v_type = Regexp.last_match[:v_type]
122
+ {}.tap do |hash|
123
+ value.each do |k, v|
124
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
125
+ end
126
+ end
127
+ else # model
128
+ temp_model = ReliefWebAPI.const_get(type).new
129
+ temp_model.build_from_hash(value)
130
+ end
131
+ end
132
+
133
+ # Returns the string representation of the object
134
+ # @return [String] String presentation of the object
135
+ def to_s
136
+ to_hash.to_s
137
+ end
138
+
139
+ # to_body is an alias to to_hash (backward compatibility)
140
+ # @return [Hash] Returns the object in the form of hash
141
+ def to_body
142
+ to_hash
143
+ end
144
+
145
+ # Returns the object in the form of hash
146
+ # @return [Hash] Returns the object in the form of hash
147
+ def to_hash
148
+ hash = {}
149
+ self.class.attribute_map.each_pair do |attr, param|
150
+ value = self.send(attr)
151
+ next if value.nil?
152
+ hash[param] = _to_hash(value)
153
+ end
154
+ hash
155
+ end
156
+
157
+ # Outputs non-array value in the form of hash
158
+ # For object, use to_hash. Otherwise, just return the value
159
+ # @param [Object] value Any valid value
160
+ # @return [Hash] Returns the value in the form of hash
161
+ def _to_hash(value)
162
+ if value.is_a?(Array)
163
+ value.compact.map { |v| _to_hash(v) }
164
+ elsif value.is_a?(Hash)
165
+ {}.tap do |hash|
166
+ value.each { |k, v| hash[k] = _to_hash(v) }
167
+ end
168
+ elsif value.respond_to? :to_hash
169
+ value.to_hash
170
+ else
171
+ value
172
+ end
173
+ end
174
+ end
175
+ end
@@ -0,0 +1,30 @@
1
+ =begin
2
+ #The ReliefWeb API
3
+
4
+ #Interactive API documentation for the data API of Reliefweb.int. ReliefWeb is a leading source of information on global crises and disasters.<br><br> Our continuous coverage and archive going back to the 1970s makes ReliefWeb an unparalleled resource for both current and historical data on humanitarian response.<br><br> The vast majority of content on ReliefWeb has been contributed by humanitarian partners. We owe it to the community to make data more accessible and reusable, so that developers can build tools that increase exposure for valuable content and facilitate analysis for better decisions.
5
+
6
+ OpenAPI spec version: v1
7
+ Contact: api@reliefweb.int
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.12
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module ReliefWebAPI
16
+ class QueryOperatorPost
17
+
18
+ AND = 'AND'.freeze
19
+ OR = 'OR'.freeze
20
+
21
+ # Builds the enum from string
22
+ # @param [String] The enum value in the form of the string
23
+ # @return [String] The enum value
24
+ def build_from_hash(value)
25
+ constantValues = QueryOperatorPost.constants.select { |c| QueryOperatorPost::const_get(c) == value }
26
+ raise "Invalid ENUM value #{value} for class #QueryOperatorPost" if constantValues.empty?
27
+ value
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,175 @@
1
+ =begin
2
+ #The ReliefWeb API
3
+
4
+ #Interactive API documentation for the data API of Reliefweb.int. ReliefWeb is a leading source of information on global crises and disasters.<br><br> Our continuous coverage and archive going back to the 1970s makes ReliefWeb an unparalleled resource for both current and historical data on humanitarian response.<br><br> The vast majority of content on ReliefWeb has been contributed by humanitarian partners. We owe it to the community to make data more accessible and reusable, so that developers can build tools that increase exposure for valuable content and facilitate analysis for better decisions.
5
+
6
+ OpenAPI spec version: v1
7
+ Contact: api@reliefweb.int
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.12
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module ReliefWebAPI
16
+ # Specify the terms of your fuzzy search. The default is no query.
17
+ class QueryValuePost
18
+ # Attribute mapping from ruby-style variable name to JSON key.
19
+ def self.attribute_map
20
+ {
21
+ }
22
+ end
23
+
24
+ # Attribute type mapping.
25
+ def self.swagger_types
26
+ {
27
+ }
28
+ end
29
+
30
+ # Initializes the object
31
+ # @param [Hash] attributes Model attributes in the form of hash
32
+ def initialize(attributes = {})
33
+ return unless attributes.is_a?(Hash)
34
+
35
+ # convert string to symbol for hash key
36
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
37
+ end
38
+
39
+ # Show invalid properties with the reasons. Usually used together with valid?
40
+ # @return Array for valid properties with the reasons
41
+ def list_invalid_properties
42
+ invalid_properties = Array.new
43
+ invalid_properties
44
+ end
45
+
46
+ # Check to see if the all the properties in the model are valid
47
+ # @return true if the model is valid
48
+ def valid?
49
+ true
50
+ end
51
+
52
+ # Checks equality by comparing each attribute.
53
+ # @param [Object] Object to be compared
54
+ def ==(o)
55
+ return true if self.equal?(o)
56
+ self.class == o.class
57
+ end
58
+
59
+ # @see the `==` method
60
+ # @param [Object] Object to be compared
61
+ def eql?(o)
62
+ self == o
63
+ end
64
+
65
+ # Calculates hash code according to all attributes.
66
+ # @return [Fixnum] Hash code
67
+ def hash
68
+ [].hash
69
+ end
70
+
71
+ # Builds the object from hash
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ # @return [Object] Returns the model itself
74
+ def build_from_hash(attributes)
75
+ return nil unless attributes.is_a?(Hash)
76
+ self.class.swagger_types.each_pair do |key, type|
77
+ if type =~ /\AArray<(.*)>/i
78
+ # check to ensure the input is an array given that the the attribute
79
+ # is documented as an array but the input is not
80
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
81
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
82
+ end
83
+ elsif !attributes[self.class.attribute_map[key]].nil?
84
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
85
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
86
+ end
87
+
88
+ self
89
+ end
90
+
91
+ # Deserializes the data based on type
92
+ # @param string type Data type
93
+ # @param string value Value to be deserialized
94
+ # @return [Object] Deserialized data
95
+ def _deserialize(type, value)
96
+ case type.to_sym
97
+ when :DateTime
98
+ DateTime.parse(value)
99
+ when :Date
100
+ Date.parse(value)
101
+ when :String
102
+ value.to_s
103
+ when :Integer
104
+ value.to_i
105
+ when :Float
106
+ value.to_f
107
+ when :BOOLEAN
108
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
109
+ true
110
+ else
111
+ false
112
+ end
113
+ when :Object
114
+ # generic object (usually a Hash), return directly
115
+ value
116
+ when /\AArray<(?<inner_type>.+)>\z/
117
+ inner_type = Regexp.last_match[:inner_type]
118
+ value.map { |v| _deserialize(inner_type, v) }
119
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
120
+ k_type = Regexp.last_match[:k_type]
121
+ v_type = Regexp.last_match[:v_type]
122
+ {}.tap do |hash|
123
+ value.each do |k, v|
124
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
125
+ end
126
+ end
127
+ else # model
128
+ temp_model = ReliefWebAPI.const_get(type).new
129
+ temp_model.build_from_hash(value)
130
+ end
131
+ end
132
+
133
+ # Returns the string representation of the object
134
+ # @return [String] String presentation of the object
135
+ def to_s
136
+ to_hash.to_s
137
+ end
138
+
139
+ # to_body is an alias to to_hash (backward compatibility)
140
+ # @return [Hash] Returns the object in the form of hash
141
+ def to_body
142
+ to_hash
143
+ end
144
+
145
+ # Returns the object in the form of hash
146
+ # @return [Hash] Returns the object in the form of hash
147
+ def to_hash
148
+ hash = {}
149
+ self.class.attribute_map.each_pair do |attr, param|
150
+ value = self.send(attr)
151
+ next if value.nil?
152
+ hash[param] = _to_hash(value)
153
+ end
154
+ hash
155
+ end
156
+
157
+ # Outputs non-array value in the form of hash
158
+ # For object, use to_hash. Otherwise, just return the value
159
+ # @param [Object] value Any valid value
160
+ # @return [Hash] Returns the value in the form of hash
161
+ def _to_hash(value)
162
+ if value.is_a?(Array)
163
+ value.compact.map { |v| _to_hash(v) }
164
+ elsif value.is_a?(Hash)
165
+ {}.tap do |hash|
166
+ value.each { |k, v| hash[k] = _to_hash(v) }
167
+ end
168
+ elsif value.respond_to? :to_hash
169
+ value.to_hash
170
+ else
171
+ value
172
+ end
173
+ end
174
+ end
175
+ end
@@ -0,0 +1,293 @@
1
+ =begin
2
+ #The ReliefWeb API
3
+
4
+ #Interactive API documentation for the data API of Reliefweb.int. ReliefWeb is a leading source of information on global crises and disasters.<br><br> Our continuous coverage and archive going back to the 1970s makes ReliefWeb an unparalleled resource for both current and historical data on humanitarian response.<br><br> The vast majority of content on ReliefWeb has been contributed by humanitarian partners. We owe it to the community to make data more accessible and reusable, so that developers can build tools that increase exposure for valuable content and facilitate analysis for better decisions.
5
+
6
+ OpenAPI spec version: v1
7
+ Contact: api@reliefweb.int
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.12
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module ReliefWebAPI
16
+ class Report
17
+ attr_accessor :body
18
+
19
+ attr_accessor :country
20
+
21
+ attr_accessor :date
22
+
23
+ # Format of report.
24
+ attr_accessor :format
25
+
26
+ attr_accessor :id
27
+
28
+ attr_accessor :language
29
+
30
+ attr_accessor :primary_country
31
+
32
+ # Report production and coordination bodies.
33
+ attr_accessor :source
34
+
35
+ attr_accessor :status
36
+
37
+ # Category of information contained in the report.
38
+ attr_accessor :theme
39
+
40
+ attr_accessor :title
41
+
42
+ attr_accessor :type
43
+
44
+ # Attribute mapping from ruby-style variable name to JSON key.
45
+ def self.attribute_map
46
+ {
47
+ :'body' => :'body',
48
+ :'country' => :'country',
49
+ :'date' => :'date',
50
+ :'format' => :'format',
51
+ :'id' => :'id',
52
+ :'language' => :'language',
53
+ :'primary_country' => :'primary_country',
54
+ :'source' => :'source',
55
+ :'status' => :'status',
56
+ :'theme' => :'theme',
57
+ :'title' => :'title',
58
+ :'type' => :'type'
59
+ }
60
+ end
61
+
62
+ # Attribute type mapping.
63
+ def self.swagger_types
64
+ {
65
+ :'body' => :'String',
66
+ :'country' => :'Array<Country>',
67
+ :'date' => :'Date',
68
+ :'format' => :'Array<Category>',
69
+ :'id' => :'Integer',
70
+ :'language' => :'Language',
71
+ :'primary_country' => :'Country',
72
+ :'source' => :'Array<Source>',
73
+ :'status' => :'BOOLEAN',
74
+ :'theme' => :'Array<Category>',
75
+ :'title' => :'String',
76
+ :'type' => :'String'
77
+ }
78
+ end
79
+
80
+ # Initializes the object
81
+ # @param [Hash] attributes Model attributes in the form of hash
82
+ def initialize(attributes = {})
83
+ return unless attributes.is_a?(Hash)
84
+
85
+ # convert string to symbol for hash key
86
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
87
+
88
+ if attributes.has_key?(:'body')
89
+ self.body = attributes[:'body']
90
+ end
91
+
92
+ if attributes.has_key?(:'country')
93
+ if (value = attributes[:'country']).is_a?(Array)
94
+ self.country = value
95
+ end
96
+ end
97
+
98
+ if attributes.has_key?(:'date')
99
+ self.date = attributes[:'date']
100
+ end
101
+
102
+ if attributes.has_key?(:'format')
103
+ if (value = attributes[:'format']).is_a?(Array)
104
+ self.format = value
105
+ end
106
+ end
107
+
108
+ if attributes.has_key?(:'id')
109
+ self.id = attributes[:'id']
110
+ end
111
+
112
+ if attributes.has_key?(:'language')
113
+ self.language = attributes[:'language']
114
+ end
115
+
116
+ if attributes.has_key?(:'primary_country')
117
+ self.primary_country = attributes[:'primary_country']
118
+ end
119
+
120
+ if attributes.has_key?(:'source')
121
+ if (value = attributes[:'source']).is_a?(Array)
122
+ self.source = value
123
+ end
124
+ end
125
+
126
+ if attributes.has_key?(:'status')
127
+ self.status = attributes[:'status']
128
+ end
129
+
130
+ if attributes.has_key?(:'theme')
131
+ if (value = attributes[:'theme']).is_a?(Array)
132
+ self.theme = value
133
+ end
134
+ end
135
+
136
+ if attributes.has_key?(:'title')
137
+ self.title = attributes[:'title']
138
+ end
139
+
140
+ if attributes.has_key?(:'type')
141
+ self.type = attributes[:'type']
142
+ end
143
+ end
144
+
145
+ # Show invalid properties with the reasons. Usually used together with valid?
146
+ # @return Array for valid properties with the reasons
147
+ def list_invalid_properties
148
+ invalid_properties = Array.new
149
+ invalid_properties
150
+ end
151
+
152
+ # Check to see if the all the properties in the model are valid
153
+ # @return true if the model is valid
154
+ def valid?
155
+ true
156
+ end
157
+
158
+ # Checks equality by comparing each attribute.
159
+ # @param [Object] Object to be compared
160
+ def ==(o)
161
+ return true if self.equal?(o)
162
+ self.class == o.class &&
163
+ body == o.body &&
164
+ country == o.country &&
165
+ date == o.date &&
166
+ format == o.format &&
167
+ id == o.id &&
168
+ language == o.language &&
169
+ primary_country == o.primary_country &&
170
+ source == o.source &&
171
+ status == o.status &&
172
+ theme == o.theme &&
173
+ title == o.title &&
174
+ type == o.type
175
+ end
176
+
177
+ # @see the `==` method
178
+ # @param [Object] Object to be compared
179
+ def eql?(o)
180
+ self == o
181
+ end
182
+
183
+ # Calculates hash code according to all attributes.
184
+ # @return [Fixnum] Hash code
185
+ def hash
186
+ [body, country, date, format, id, language, primary_country, source, status, theme, title, type].hash
187
+ end
188
+
189
+ # Builds the object from hash
190
+ # @param [Hash] attributes Model attributes in the form of hash
191
+ # @return [Object] Returns the model itself
192
+ def build_from_hash(attributes)
193
+ return nil unless attributes.is_a?(Hash)
194
+ self.class.swagger_types.each_pair do |key, type|
195
+ if type =~ /\AArray<(.*)>/i
196
+ # check to ensure the input is an array given that the the attribute
197
+ # is documented as an array but the input is not
198
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
199
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
200
+ end
201
+ elsif !attributes[self.class.attribute_map[key]].nil?
202
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
203
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
204
+ end
205
+
206
+ self
207
+ end
208
+
209
+ # Deserializes the data based on type
210
+ # @param string type Data type
211
+ # @param string value Value to be deserialized
212
+ # @return [Object] Deserialized data
213
+ def _deserialize(type, value)
214
+ case type.to_sym
215
+ when :DateTime
216
+ DateTime.parse(value)
217
+ when :Date
218
+ Date.parse(value)
219
+ when :String
220
+ value.to_s
221
+ when :Integer
222
+ value.to_i
223
+ when :Float
224
+ value.to_f
225
+ when :BOOLEAN
226
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
227
+ true
228
+ else
229
+ false
230
+ end
231
+ when :Object
232
+ # generic object (usually a Hash), return directly
233
+ value
234
+ when /\AArray<(?<inner_type>.+)>\z/
235
+ inner_type = Regexp.last_match[:inner_type]
236
+ value.map { |v| _deserialize(inner_type, v) }
237
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
238
+ k_type = Regexp.last_match[:k_type]
239
+ v_type = Regexp.last_match[:v_type]
240
+ {}.tap do |hash|
241
+ value.each do |k, v|
242
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
243
+ end
244
+ end
245
+ else # model
246
+ temp_model = ReliefWebAPI.const_get(type).new
247
+ temp_model.build_from_hash(value)
248
+ end
249
+ end
250
+
251
+ # Returns the string representation of the object
252
+ # @return [String] String presentation of the object
253
+ def to_s
254
+ to_hash.to_s
255
+ end
256
+
257
+ # to_body is an alias to to_hash (backward compatibility)
258
+ # @return [Hash] Returns the object in the form of hash
259
+ def to_body
260
+ to_hash
261
+ end
262
+
263
+ # Returns the object in the form of hash
264
+ # @return [Hash] Returns the object in the form of hash
265
+ def to_hash
266
+ hash = {}
267
+ self.class.attribute_map.each_pair do |attr, param|
268
+ value = self.send(attr)
269
+ next if value.nil?
270
+ hash[param] = _to_hash(value)
271
+ end
272
+ hash
273
+ end
274
+
275
+ # Outputs non-array value in the form of hash
276
+ # For object, use to_hash. Otherwise, just return the value
277
+ # @param [Object] value Any valid value
278
+ # @return [Hash] Returns the value in the form of hash
279
+ def _to_hash(value)
280
+ if value.is_a?(Array)
281
+ value.compact.map { |v| _to_hash(v) }
282
+ elsif value.is_a?(Hash)
283
+ {}.tap do |hash|
284
+ value.each { |k, v| hash[k] = _to_hash(v) }
285
+ end
286
+ elsif value.respond_to? :to_hash
287
+ value.to_hash
288
+ else
289
+ value
290
+ end
291
+ end
292
+ end
293
+ end