clever-ruby 1.2.1 → 1.2.2

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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/Gemfile.lock +4 -4
  4. data/README.md +19 -18
  5. data/clever-ruby.gemspec +4 -3
  6. data/docs/DataApi.md +2 -2
  7. data/docs/StudentContactsForStudentResponse.md +8 -0
  8. data/lib/clever-ruby.rb +20 -18
  9. data/lib/clever-ruby/api/data_api.rb +97 -34
  10. data/lib/clever-ruby/api/events_api.rb +19 -6
  11. data/lib/clever-ruby/api_error.rb +1 -0
  12. data/lib/clever-ruby/configuration.rb +7 -0
  13. data/lib/clever-ruby/models/bad_request.rb +1 -0
  14. data/lib/clever-ruby/models/credentials.rb +1 -0
  15. data/lib/clever-ruby/models/district.rb +1 -0
  16. data/lib/clever-ruby/models/district_admin.rb +1 -0
  17. data/lib/clever-ruby/models/district_admin_response.rb +1 -0
  18. data/lib/clever-ruby/models/district_admins_response.rb +1 -0
  19. data/lib/clever-ruby/models/district_object.rb +1 -0
  20. data/lib/clever-ruby/models/district_response.rb +1 -0
  21. data/lib/clever-ruby/models/district_status.rb +1 -0
  22. data/lib/clever-ruby/models/district_status_response.rb +1 -0
  23. data/lib/clever-ruby/models/district_status_responses.rb +1 -0
  24. data/lib/clever-ruby/models/districts_response.rb +1 -0
  25. data/lib/clever-ruby/models/event.rb +1 -0
  26. data/lib/clever-ruby/models/event_response.rb +1 -0
  27. data/lib/clever-ruby/models/events_response.rb +1 -0
  28. data/lib/clever-ruby/models/grade_levels_response.rb +1 -0
  29. data/lib/clever-ruby/models/internal_error.rb +1 -0
  30. data/lib/clever-ruby/models/location.rb +1 -0
  31. data/lib/clever-ruby/models/name.rb +1 -0
  32. data/lib/clever-ruby/models/not_found.rb +1 -0
  33. data/lib/clever-ruby/models/principal.rb +1 -0
  34. data/lib/clever-ruby/models/school.rb +1 -0
  35. data/lib/clever-ruby/models/school_admin.rb +1 -0
  36. data/lib/clever-ruby/models/school_admin_object.rb +1 -0
  37. data/lib/clever-ruby/models/school_admin_response.rb +1 -0
  38. data/lib/clever-ruby/models/school_admins_response.rb +1 -0
  39. data/lib/clever-ruby/models/school_object.rb +1 -0
  40. data/lib/clever-ruby/models/school_response.rb +1 -0
  41. data/lib/clever-ruby/models/schools_response.rb +1 -0
  42. data/lib/clever-ruby/models/section.rb +1 -0
  43. data/lib/clever-ruby/models/section_object.rb +1 -0
  44. data/lib/clever-ruby/models/section_response.rb +1 -0
  45. data/lib/clever-ruby/models/sections_response.rb +1 -0
  46. data/lib/clever-ruby/models/student.rb +1 -0
  47. data/lib/clever-ruby/models/student_contact.rb +1 -0
  48. data/lib/clever-ruby/models/student_contact_object.rb +1 -0
  49. data/lib/clever-ruby/models/student_contact_response.rb +1 -0
  50. data/lib/clever-ruby/models/student_contacts_for_student_response.rb +190 -0
  51. data/lib/clever-ruby/models/student_contacts_response.rb +1 -0
  52. data/lib/clever-ruby/models/student_object.rb +1 -0
  53. data/lib/clever-ruby/models/student_response.rb +1 -0
  54. data/lib/clever-ruby/models/students_created.rb +12 -0
  55. data/lib/clever-ruby/models/students_response.rb +1 -0
  56. data/lib/clever-ruby/models/teacher.rb +1 -0
  57. data/lib/clever-ruby/models/teacher_object.rb +1 -0
  58. data/lib/clever-ruby/models/teacher_response.rb +1 -0
  59. data/lib/clever-ruby/models/teachers_response.rb +1 -0
  60. data/lib/clever-ruby/models/term.rb +1 -0
  61. data/lib/clever-ruby/version.rb +2 -1
  62. data/override/models/students_created.rb +12 -0
  63. data/override/override.sh +4 -2
  64. data/spec/data_api_spec.rb +32 -0
  65. data/spec/events.json +46 -49
  66. data/spec/events_api_spec.rb +10 -2
  67. data/test.json +6 -0
  68. data/test.rb +10 -2
  69. metadata +17 -12
@@ -0,0 +1,190 @@
1
+ =begin
2
+ #Clever API
3
+
4
+ #The Clever API
5
+
6
+ OpenAPI spec version: 1.2.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.2.3
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module Clever
16
+
17
+ class StudentContactsForStudentResponse
18
+ attr_accessor :data
19
+
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'data' => :'data'
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.swagger_types
30
+ {
31
+ :'data' => :'Array<StudentContact>'
32
+ }
33
+ end
34
+
35
+ # Initializes the object
36
+ # @param [Hash] attributes Model attributes in the form of hash
37
+ def initialize(attributes = {})
38
+ return unless attributes.is_a?(Hash)
39
+
40
+ # convert string to symbol for hash key
41
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
42
+
43
+ if attributes.has_key?(:'data')
44
+ if (value = attributes[:'data']).is_a?(Array)
45
+ self.data = value
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ # Show invalid properties with the reasons. Usually used together with valid?
52
+ # @return Array for valid properies with the reasons
53
+ def list_invalid_properties
54
+ invalid_properties = Array.new
55
+ return invalid_properties
56
+ end
57
+
58
+ # Check to see if the all the properties in the model are valid
59
+ # @return true if the model is valid
60
+ def valid?
61
+ return true
62
+ end
63
+
64
+ # Checks equality by comparing each attribute.
65
+ # @param [Object] Object to be compared
66
+ def ==(o)
67
+ return true if self.equal?(o)
68
+ self.class == o.class &&
69
+ data == o.data
70
+ end
71
+
72
+ # @see the `==` method
73
+ # @param [Object] Object to be compared
74
+ def eql?(o)
75
+ self == o
76
+ end
77
+
78
+ # Calculates hash code according to all attributes.
79
+ # @return [Fixnum] Hash code
80
+ def hash
81
+ [data].hash
82
+ end
83
+
84
+ # Builds the object from hash
85
+ # @param [Hash] attributes Model attributes in the form of hash
86
+ # @return [Object] Returns the model itself
87
+ def build_from_hash(attributes)
88
+ return nil unless attributes.is_a?(Hash)
89
+ self.class.swagger_types.each_pair do |key, type|
90
+ if type =~ /\AArray<(.*)>/i
91
+ # check to ensure the input is an array given that the the attribute
92
+ # is documented as an array but the input is not
93
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
94
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
95
+ end
96
+ elsif !attributes[self.class.attribute_map[key]].nil?
97
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
98
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
99
+ end
100
+
101
+ self
102
+ end
103
+
104
+ # Deserializes the data based on type
105
+ # @param string type Data type
106
+ # @param string value Value to be deserialized
107
+ # @return [Object] Deserialized data
108
+ def _deserialize(type, value)
109
+ case type.to_sym
110
+ when :DateTime
111
+ DateTime.parse(value)
112
+ when :Date
113
+ Date.parse(value)
114
+ when :String
115
+ value.to_s
116
+ when :Integer
117
+ value.to_i
118
+ when :Float
119
+ value.to_f
120
+ when :BOOLEAN
121
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
122
+ true
123
+ else
124
+ false
125
+ end
126
+ when :Object
127
+ # generic object (usually a Hash), return directly
128
+ value
129
+ when /\AArray<(?<inner_type>.+)>\z/
130
+ inner_type = Regexp.last_match[:inner_type]
131
+ value.map { |v| _deserialize(inner_type, v) }
132
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
133
+ k_type = Regexp.last_match[:k_type]
134
+ v_type = Regexp.last_match[:v_type]
135
+ {}.tap do |hash|
136
+ value.each do |k, v|
137
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
138
+ end
139
+ end
140
+ else # model
141
+ temp_model = Clever.const_get(type).new
142
+ temp_model.build_from_hash(value)
143
+ end
144
+ end
145
+
146
+ # Returns the string representation of the object
147
+ # @return [String] String presentation of the object
148
+ def to_s
149
+ to_hash.to_s
150
+ end
151
+
152
+ # to_body is an alias to to_hash (backward compatibility)
153
+ # @return [Hash] Returns the object in the form of hash
154
+ def to_body
155
+ to_hash
156
+ end
157
+
158
+ # Returns the object in the form of hash
159
+ # @return [Hash] Returns the object in the form of hash
160
+ def to_hash
161
+ hash = {}
162
+ self.class.attribute_map.each_pair do |attr, param|
163
+ value = self.send(attr)
164
+ next if value.nil?
165
+ hash[param] = _to_hash(value)
166
+ end
167
+ hash
168
+ end
169
+
170
+ # Outputs non-array value in the form of hash
171
+ # For object, use to_hash. Otherwise, just return the value
172
+ # @param [Object] value Any valid value
173
+ # @return [Hash] Returns the value in the form of hash
174
+ def _to_hash(value)
175
+ if value.is_a?(Array)
176
+ value.compact.map{ |v| _to_hash(v) }
177
+ elsif value.is_a?(Hash)
178
+ {}.tap do |hash|
179
+ value.each { |k, v| hash[k] = _to_hash(v) }
180
+ end
181
+ elsif value.respond_to? :to_hash
182
+ value.to_hash
183
+ else
184
+ value
185
+ end
186
+ end
187
+
188
+ end
189
+
190
+ end
@@ -6,6 +6,7 @@
6
6
  OpenAPI spec version: 1.2.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.2.3
9
10
 
10
11
  =end
11
12
 
@@ -6,6 +6,7 @@
6
6
  OpenAPI spec version: 1.2.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.2.3
9
10
 
10
11
  =end
11
12
 
@@ -6,6 +6,7 @@
6
6
  OpenAPI spec version: 1.2.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.2.3
9
10
 
10
11
  =end
11
12
 
@@ -22,6 +22,8 @@ module Clever
22
22
  # Attribute mapping from ruby-style variable name to JSON key.
23
23
  def self.attribute_map
24
24
  {
25
+ :'type' => :'type',
26
+ :'id' => :'id',
25
27
  :'data' => :'data'
26
28
  }
27
29
  end
@@ -29,6 +31,8 @@ module Clever
29
31
  # Attribute type mapping.
30
32
  def self.swagger_types
31
33
  {
34
+ :'type' => :'String',
35
+ :'id' => :'String',
32
36
  :'data' => :'StudentObject'
33
37
  }
34
38
  end
@@ -41,6 +45,14 @@ module Clever
41
45
  # convert string to symbol for hash key
42
46
  attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
43
47
 
48
+ if attributes.has_key?(:'type')
49
+ self.type = attributes[:'type']
50
+ end
51
+
52
+ if attributes.has_key?(:'id')
53
+ self.id = attributes[:'id']
54
+ end
55
+
44
56
  if attributes.has_key?(:'data')
45
57
  self.data = attributes[:'data']
46
58
  end
@@ -6,6 +6,7 @@
6
6
  OpenAPI spec version: 1.2.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.2.3
9
10
 
10
11
  =end
11
12
 
@@ -6,6 +6,7 @@
6
6
  OpenAPI spec version: 1.2.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.2.3
9
10
 
10
11
  =end
11
12
 
@@ -6,6 +6,7 @@
6
6
  OpenAPI spec version: 1.2.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.2.3
9
10
 
10
11
  =end
11
12
 
@@ -6,6 +6,7 @@
6
6
  OpenAPI spec version: 1.2.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.2.3
9
10
 
10
11
  =end
11
12
 
@@ -6,6 +6,7 @@
6
6
  OpenAPI spec version: 1.2.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.2.3
9
10
 
10
11
  =end
11
12
 
@@ -6,6 +6,7 @@
6
6
  OpenAPI spec version: 1.2.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.2.3
9
10
 
10
11
  =end
11
12
 
@@ -6,9 +6,10 @@
6
6
  OpenAPI spec version: 1.2.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.2.3
9
10
 
10
11
  =end
11
12
 
12
13
  module Clever
13
- VERSION = "1.2.1"
14
+ VERSION = "1.2.2"
14
15
  end
@@ -22,6 +22,8 @@ module Clever
22
22
  # Attribute mapping from ruby-style variable name to JSON key.
23
23
  def self.attribute_map
24
24
  {
25
+ :'type' => :'type',
26
+ :'id' => :'id',
25
27
  :'data' => :'data'
26
28
  }
27
29
  end
@@ -29,6 +31,8 @@ module Clever
29
31
  # Attribute type mapping.
30
32
  def self.swagger_types
31
33
  {
34
+ :'type' => :'String',
35
+ :'id' => :'String',
32
36
  :'data' => :'StudentObject'
33
37
  }
34
38
  end
@@ -41,6 +45,14 @@ module Clever
41
45
  # convert string to symbol for hash key
42
46
  attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
43
47
 
48
+ if attributes.has_key?(:'type')
49
+ self.type = attributes[:'type']
50
+ end
51
+
52
+ if attributes.has_key?(:'id')
53
+ self.id = attributes[:'id']
54
+ end
55
+
44
56
  if attributes.has_key?(:'data')
45
57
  self.data = attributes[:'data']
46
58
  end
data/override/override.sh CHANGED
@@ -5,8 +5,10 @@ cp models/* ../lib/clever-ruby/models/
5
5
  # Override the parsing library with one that's aware of the inheritence
6
6
  cp api_client.rb ../lib/clever-ruby/
7
7
 
8
- # The tests don't do anything so let's remove them
9
- rm -r ../spec || true
8
+ # The generated tests don't do anything so let's remove them
9
+ rm -r ../spec/api || true
10
+ rm -r ../spec/models || true
11
+ rm -r ../spec/api_client_spec.rb || true
10
12
 
11
13
  # Add the extension to the readme if it's not already there
12
14
  if ! grep -q -i '## Previous Versions' ../README.md; then
@@ -0,0 +1,32 @@
1
+ require "clever-ruby"
2
+ require 'webmock/rspec'
3
+
4
+ describe Clever::DataApi do
5
+ before(:each) do
6
+ WebMock.allow_net_connect!
7
+ @api_instance = Clever::DataApi.new
8
+ Clever.configure do |config|
9
+ config.access_token = 'DEMO_TOKEN'
10
+ end
11
+ end
12
+
13
+ describe ".get_contacts_for_student" do
14
+ it "returns array of StudentContacts" do
15
+ student_id = "530e5961049e75a9262cffe4"
16
+ contacts = @api_instance.get_contacts_for_student(student_id).data
17
+ expect(contacts.length).to eq(1)
18
+ expect(contacts.first.class).to eq(Clever::StudentContact)
19
+ expect(contacts.first.id).not_to be nil
20
+ end
21
+ end
22
+
23
+ describe ".get_contacts" do
24
+ it "returns array of StudentContactResponses" do
25
+ contacts = @api_instance.get_contacts.data
26
+ expect(contacts).not_to be_empty
27
+ expect(contacts.first.class).to eq(Clever::StudentContactResponse)
28
+ expect(contacts.first.data.class).to eq(Clever::StudentContact)
29
+ expect(contacts.first.data.id).not_to be nil
30
+ end
31
+ end
32
+ end
data/spec/events.json CHANGED
@@ -129,87 +129,84 @@
129
129
  },
130
130
  {
131
131
  "data": {
132
- "created": "2017-06-15T21:54:10.030Z",
132
+ "created": "2017-07-13T16:28:38.377Z",
133
133
  "data": {
134
134
  "object": {
135
- "district": "56e07f73944b620100000175",
136
- "ell_status": "N",
137
- "id": "58c81dcea3627927150003f0"
138
- },
139
- "previous_attributes": {
140
- "created": "2017-03-14T16:43:58.153Z",
135
+ "created": "2017-07-11T16:05:51.740Z",
141
136
  "credentials": {
142
- "district_username": "evalynb40"
137
+ "district_username": "marthag20marthag20marthag20marthag20marthag20martha"
143
138
  },
144
- "dob": "8/10/2006",
145
- "email": "b_evalyn@example.org",
139
+ "district": "58da8a43cc70ab00017a1a87",
140
+ "dob": "4/2/1998",
141
+ "email": "g_martha@example.org",
146
142
  "gender": "F",
147
- "grade": "1",
143
+ "grade": "9",
148
144
  "hispanic_ethnicity": "N",
145
+ "id": "59496080827927905b00076d",
146
+ "last_modified": "2017-07-11T16:05:51.740Z",
149
147
  "location": {
150
- "zip": "10029"
148
+ "zip": "11694"
151
149
  },
152
150
  "name": {
153
- "first": "Evalyn",
154
- "last": "Bradtke",
155
- "middle": "J"
151
+ "first": "Martha",
152
+ "last": "Greenholt",
153
+ "middle": "T"
156
154
  },
157
- "race": "Black or African American",
158
- "school": "58c81db226d0809114000007",
155
+ "race": "Asian",
156
+ "school": "58da8c58155b940248000006",
159
157
  "schools": [
160
- "58c81db226d0809114000007"
158
+ "58da8c58155b940248000006",
159
+ "58da8c58155b940248000007"
161
160
  ],
162
- "sis_id": "106091540",
163
- "state_id": "552729322",
164
- "student_number": "106091540"
161
+ "sis_id": "9131139200",
162
+ "state_id": "975729843",
163
+ "student_number": "913113920"
165
164
  }
166
165
  },
167
- "id": "594301ff7f264e3ca45e568e",
168
- "type": "students.updated"
166
+ "id": "59679fb5893d055bc095ede7",
167
+ "type": "students.deleted"
169
168
  },
170
- "uri": "/v1.2/events/594301ff7f264e3ca45e568e"
169
+ "uri": "/v1.2/events/59679fb5893d055bc095ede7"
171
170
  },
172
171
  {
173
172
  "data": {
174
- "created": "2017-06-15T21:54:10.031Z",
173
+ "created": "2017-06-27T21:58:00.811Z",
175
174
  "data": {
176
175
  "object": {
177
- "district": "56e07f73944b620100000175",
178
- "ell_status": "Y",
179
- "id": "58c81dcea3627927150003f1"
180
- },
181
- "previous_attributes": {
182
- "created": "2017-03-14T16:43:58.154Z",
176
+ "created": "2017-03-28T16:16:35.369Z",
183
177
  "credentials": {
184
- "district_username": "coryt00"
178
+ "district_username": "mial61"
185
179
  },
186
- "dob": "7/21/1997",
187
- "email": "cory_t@example.net",
188
- "gender": "M",
189
- "grade": "10",
190
- "hispanic_ethnicity": "Y",
180
+ "district": "58da8a43cc70ab00017a1a87",
181
+ "dob": "11/10/2002",
182
+ "email": "l_mia@example.org",
183
+ "gender": "F",
184
+ "grade": "5",
185
+ "hispanic_ethnicity": "N",
186
+ "id": "58da8c63d7dc0ca068000450",
187
+ "last_modified": "2017-03-28T16:16:35.369Z",
191
188
  "location": {
192
- "zip": "10038"
189
+ "zip": "10002"
193
190
  },
194
191
  "name": {
195
- "first": "Cory",
196
- "last": "Thompson",
197
- "middle": "V"
192
+ "first": "Mia",
193
+ "last": "Lindgren",
194
+ "middle": "J"
198
195
  },
199
196
  "race": "Black or African American",
200
- "school": "58c81db226d0809114000006",
197
+ "school": "58da8c58155b940248000007",
201
198
  "schools": [
202
- "58c81db226d0809114000006"
199
+ "58da8c58155b940248000007"
203
200
  ],
204
- "sis_id": "106867300",
205
- "state_id": "863433981",
206
- "student_number": "106867300"
201
+ "sis_id": "189492161",
202
+ "state_id": "661166974",
203
+ "student_number": "189492161"
207
204
  }
208
205
  },
209
- "id": "594301ff7f264e3ca45e568f",
210
- "type": "students.updated"
206
+ "id": "5952d4e3ed859521b85c6283",
207
+ "type": "students.created"
211
208
  },
212
- "uri": "/v1.2/events/594301ff7f264e3ca45e568f"
209
+ "uri": "/v1.2/events/5952d4e3ed859521b85c6283"
213
210
  }
214
211
  ],
215
212
  "links": [