dmtd_vbmapp_data 1.0.2 → 1.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9618795492ef685583687baee0ce2fbb3acdc0a1
4
- data.tar.gz: f1349008bd09c3e3b5126de94591bfb8f4b240f2
3
+ metadata.gz: 93d6ded3058b25dcdddf63fdf9772d4ae2b39225
4
+ data.tar.gz: 92a1f20afb9d0a0420287a1c6d227e86a592b450
5
5
  SHA512:
6
- metadata.gz: 9e488f5adcb9479715f9b30e5fa2c0b6f43bf6d560a0518aba61d8035272a9135f4a05b941dabb4049f1d8c84ad5db450e7b084db9dcfae56320f01c1f7d655a
7
- data.tar.gz: b49afb5f8cd3b56ce191a198736ed63bfa7c3d85ba2a0e0faf1571310762e5fb8cbf758482a4ace439fbf522e203878674fc68bbbc8558db84ec7a0e675c6a5e
6
+ metadata.gz: 1fdc047a929060b5fcf19b6b5e6d09738eba0ecdfae67ccc2e4eae217dfefafd224a27e2e937852265ffdd94c9f4cc8c7726516fe88937c83fe3f5032b809832
7
+ data.tar.gz: c100ae97c161b3f3ccb8a640eabcdbffc3487249e9b053eacf8568cc80edb7d0d8cd3c929f48e53ae209e2a63b05ee0ddd92f01a41db5004cbd021417d0a7dcc
@@ -52,4 +52,6 @@ module DmtdVbmappData
52
52
  @config
53
53
  end
54
54
 
55
+ AVAILABLE_LANGUAGES=%w(en es)
56
+
55
57
  end
@@ -20,6 +20,9 @@ module DmtdVbmappData
20
20
  # The client for which the report will be generated
21
21
  attr_reader :client
22
22
 
23
+ # The language in which the report will be generated
24
+ attr_reader :language
25
+
23
26
  # Initializes the receiver with the given options:
24
27
  #
25
28
  # This method does *not* block, simply creates an accessor and returns
@@ -27,9 +30,11 @@ module DmtdVbmappData
27
30
  # Params:
28
31
  # +client+:: The client for which to run the report
29
32
  # +resolver+:: See +resolver+ above
33
+ # +language+:: the language to use (i.e. 'en', 'es' or may be nil)
30
34
  def initialize(opts, &resolver)
31
35
  @client = opts.fetch(:client)
32
36
  @resolver = resolver
37
+ @language = opts.fetch(:language, nil)
33
38
  end
34
39
 
35
40
  # Returns the JSON for the IEP report (see https://datamtd.atlassian.net/wiki/pages/viewpage.action?pageId=19267590) for the
@@ -95,7 +100,7 @@ module DmtdVbmappData
95
100
  end
96
101
 
97
102
  def retrieve_responses_json
98
- response = RequestHelpers::get_authorized(end_point: AssessmentReport::end_point, params: nil, client_id: @client.id, client_code: @client.code)
103
+ response = RequestHelpers::get_authorized(end_point: AssessmentReport::end_point, params: nil, client_id: @client.id, client_code: @client.code, language: language)
99
104
  proc_response = RequestHelpers::process_json_response(response)
100
105
  json = proc_response[:json]
101
106
  server_response_code = proc_response[:code]
@@ -18,6 +18,7 @@ module DmtdVbmappData
18
18
  attr_reader :created_at
19
19
  attr_reader :updated_at
20
20
  attr_reader :server_response_code
21
+ attr_reader :language
21
22
 
22
23
  # Creates a new client on the VB-MAPP Data Server
23
24
  #
@@ -31,6 +32,9 @@ module DmtdVbmappData
31
32
  # If +id+ is specified, then the instance will *not* be sent to the server, it is assumed to already be there.
32
33
  # Otherwise it will be sent to the server if is_valid_for_create? is true.
33
34
  #
35
+ # *NOTE:* language is *not* stored on the server along with the client information and thus, it must be
36
+ # specified each time the instance is created if a language other than the default is needed.
37
+ #
34
38
  # Params:
35
39
  # +date_of_birth+:: the date of birth of the client as a ruby Date object (may be nil)
36
40
  # +gender+:: the gender of the client, either +GENDER_MALE+ or +GENDER_FEMALE+ (may be nil)
@@ -40,6 +44,7 @@ module DmtdVbmappData
40
44
  # +first_name+:: the first name of the client (may be nil)
41
45
  # +last_name+:: the last name of the client (may be nil)
42
46
  # +settings+:: a string value that can be associated with the client (may be nil)
47
+ # +language+:: the language to use (i.e. 'en', 'es' or may be nil)
43
48
  def initialize(opts)
44
49
  @date_of_birth = opts.fetch(:date_of_birth, nil)
45
50
  @gender = opts.fetch(:gender, nil)
@@ -50,6 +55,7 @@ module DmtdVbmappData
50
55
  @last_name = opts.fetch(:last_name, nil)
51
56
  @settings = opts.fetch(:settings, nil)
52
57
  @server_response_code = opts.fetch(:server_response_code, 200)
58
+ @language = opts.fetch(:language, nil)
53
59
 
54
60
  date = Time.now.utc.to_date
55
61
  @created_at = opts.fetch(:created_at, date)
@@ -62,6 +68,10 @@ module DmtdVbmappData
62
68
  #
63
69
  # This operation blocks until it receives a response from the VB-MAPP Data Server.
64
70
  #
71
+ # Params:
72
+ # +organization_id+:: the organization identifier (may be nil, if so DmtdVbmappData.config['organization_id'] will be used)
73
+ # +language+:: the language to use (i.e. 'en', 'es' or may be nil)
74
+ #
65
75
  # Result:
66
76
  # Array of DmtdVbmappData::Client instances or server http response code (integer) if an error was received
67
77
  def self.retrieve_clients(opts = {})
@@ -70,12 +80,17 @@ module DmtdVbmappData
70
80
 
71
81
  # Retrieves the guide for the corresponding client instance
72
82
  def guide
73
- Guide.new(client: self)
83
+ Guide.new(client: self, language: language)
74
84
  end
75
85
 
76
86
  # Retrieves the vbmapp for the corresponding client instance
77
87
  def vbmapp
78
- Vbmapp.new(client: self)
88
+ Vbmapp.new(client: self, language: language)
89
+ end
90
+
91
+ # Retrieves the IEP report for the corresponding client instance
92
+ def iep_report(&resolver)
93
+ AssessmentReport.new(client: self, language: language, &resolver).iep
79
94
  end
80
95
 
81
96
  # Returns true if the receiver is parametrized correctly for creation on the server
@@ -105,13 +120,10 @@ module DmtdVbmappData
105
120
 
106
121
  def self.retrieve_server_clients(opts)
107
122
  result = nil
108
- id = opts.fetch(:id, nil)
109
- code = opts.fetch(:code, nil)
110
- organization_id = opts.fetch(:organization_id, 3)
111
-
112
- params = { organization_id: organization_id }
123
+ language = opts.fetch(:language, nil)
124
+ organization_id = opts.fetch(:organization_id, DmtdVbmappData.config[:organization_id])
113
125
 
114
- response = RequestHelpers::get_authorized(end_point: Client::end_point, params: params, client_id: id, client_code: code)
126
+ response = RequestHelpers::get_authorized(end_point: Client::end_point, params: {organization_id: organization_id}, language: language)
115
127
  proc_response = process_response(response)
116
128
  json_array = proc_response[:json]
117
129
  server_response_code = proc_response[:code]
@@ -40,7 +40,11 @@ module DmtdVbmappData
40
40
  # Note that this method calls +index+. See that method for
41
41
  # its blocking characteristics.
42
42
  def chapters
43
- index.map.with_index {|chapter_json, chapter_num| GuideChapter.new(client: client, chapter_num: chapter_num, chapter_index_json: chapter_json)}
43
+ @chapters = index.map.with_index do |chapter_json, chapter_num|
44
+ GuideChapter.new(client: client, chapter_num: chapter_num, chapter_index_json: chapter_json)
45
+ end if @chapters.nil?
46
+
47
+ @chapters
44
48
  end
45
49
 
46
50
  private
@@ -50,7 +54,7 @@ module DmtdVbmappData
50
54
  end
51
55
 
52
56
  def retrieve_guide_index
53
- response = RequestHelpers::get_authorized(end_point: Guide::end_point, params: nil, client_id: @client.id, client_code: @client.code)
57
+ response = RequestHelpers::get_authorized(end_point: Guide::end_point, params: nil, client_id: @client.id, client_code: @client.code, language: client.language)
54
58
  proc_response = RequestHelpers::process_json_response(response)
55
59
  json = proc_response[:json]
56
60
  server_response_code = proc_response[:code]
@@ -25,6 +25,7 @@ module DmtdVbmappData
25
25
  index_json = opts.fetch(:chapter_index_json)
26
26
  @chapter_title = index_json[:chapterTitle]
27
27
  @chapter_short_title = index_json[:chapterShortTitle]
28
+
28
29
  @sections_index = index_json[:sections]
29
30
  end
30
31
 
@@ -58,7 +59,7 @@ module DmtdVbmappData
58
59
  params = {
59
60
  chapter_num: chapter_num
60
61
  }
61
- response = RequestHelpers::get_authorized(end_point: GuideChapter::end_point, params: params, client_id: @client.id, client_code: @client.code)
62
+ response = RequestHelpers::get_authorized(end_point: GuideChapter::end_point, params: params, client_id: @client.id, client_code: @client.code, language:client.language)
62
63
  proc_response = RequestHelpers::process_json_response(response)
63
64
  json = proc_response[:json]
64
65
  server_response_code = proc_response[:code]
@@ -28,7 +28,7 @@ module DmtdVbmappData
28
28
  index_json = opts.fetch(:section_index_json)
29
29
  @section_title = index_json[:sectionTitle]
30
30
  @section_short_title = index_json[:sectionShortTitle]
31
- @subsection_count = index_json[:subsection_count]
31
+ @sub_sections_index = index_json[:subSections]
32
32
  end
33
33
 
34
34
  # Returns the content of the Guide's chapter section
@@ -42,9 +42,9 @@ module DmtdVbmappData
42
42
 
43
43
  # Returns the VB-MAPP Guide section's sub_sections
44
44
  def sub_sections
45
- @sub_sections = (0..@subsection_count-1).map { |sub_section_num|
46
- GuideSectionSubSection.new(client: client, chapter_num: chapter_num, section_num: section_num, sub_section_num: sub_section_num)
47
- } if @sub_sections.nil?
45
+ @sub_sections = @sub_sections_index.map.with_index do |sub_section_index_json, sub_section_num|
46
+ GuideSectionSubSection.new(client: client, chapter_num: chapter_num, section_num: section_num, sub_section_num: sub_section_num, sub_section_index_json: sub_section_index_json)
47
+ end if @sub_sections.nil?
48
48
 
49
49
  @sub_sections
50
50
  end
@@ -60,7 +60,7 @@ module DmtdVbmappData
60
60
  chapter_num: chapter_num,
61
61
  section_num: section_num
62
62
  }
63
- response = RequestHelpers::get_authorized(end_point: GuideChapterSection::end_point, params: params, client_id: @client.id, client_code: @client.code)
63
+ response = RequestHelpers::get_authorized(end_point: GuideChapterSection::end_point, params: params, client_id: @client.id, client_code: @client.code, language: client.language)
64
64
  proc_response = RequestHelpers::process_json_response(response)
65
65
  json = proc_response[:json]
66
66
  server_response_code = proc_response[:code]
@@ -9,6 +9,8 @@ module DmtdVbmappData
9
9
  attr_reader :chapter_num
10
10
  attr_reader :section_num
11
11
  attr_reader :sub_section_num
12
+ attr_reader :section_title
13
+ attr_reader :section_short_title
12
14
 
13
15
  # Creates an accessor for the VB-MAPP Guide Chapter Section on the VB-MAPP Data Server
14
16
  #
@@ -19,19 +21,16 @@ module DmtdVbmappData
19
21
  # +chapter_num+:: the number (index) of the chapter in the Guide's index array
20
22
  # +section_num+:: the number (index) of the section in the chapter's sections array
21
23
  # +sub_section_num+:: the number (index) of the sub_section in the range (0..subsection_count)
24
+ # +sub_section_index_json+:: the guide index json for the chapter
22
25
  def initialize(opts)
23
26
  @client = opts.fetch(:client)
24
27
  @chapter_num = opts.fetch(:chapter_num)
25
28
  @section_num = opts.fetch(:section_num)
26
29
  @sub_section_num = opts.fetch(:sub_section_num)
27
- end
28
-
29
- def section_title
30
- retrieve_guide_sub_section[:sectionTitle]
31
- end
32
30
 
33
- def section_short_title
34
- retrieve_guide_sub_section[:sectionShortTitle]
31
+ sub_section_index_json = opts.fetch(:sub_section_index_json)
32
+ @section_title = sub_section_index_json[:sectionTitle]
33
+ @section_short_title = sub_section_index_json[:sectionShortTitle]
35
34
  end
36
35
 
37
36
  # Returns the content of the Guide's chapter section
@@ -54,7 +53,7 @@ module DmtdVbmappData
54
53
  section_num: section_num,
55
54
  sub_section_num: sub_section_num
56
55
  }
57
- response = RequestHelpers::get_authorized(end_point: GuideSectionSubSection::end_point, params: params, client_id: @client.id, client_code: @client.code)
56
+ response = RequestHelpers::get_authorized(end_point: GuideSectionSubSection::end_point, params: params, client_id: @client.id, client_code: @client.code, language: client.language)
58
57
  proc_response = RequestHelpers::process_json_response(response)
59
58
  json = proc_response[:json]
60
59
  server_response_code = proc_response[:code]
@@ -11,14 +11,16 @@ module DmtdVbmappData
11
11
  # +end_point+:: The end point to post
12
12
  # +params+:: The parameters to send to the end point (may be nil)
13
13
  # +client_id+:: The client id under which to record the post (may be nil)
14
- # +client_code+:: The client code under which to record the post (maybe nil)
14
+ # +client_code+:: The client code under which to record the post (may be nil)
15
+ # +language+:: The language to fetch (may be nil)
15
16
  def self.get_authorized(opts = {})
16
17
  end_point = opts.fetch(:end_point)
17
18
  params = opts.fetch(:params, nil)
18
19
  client_id = opts.fetch(:client_id, nil)
19
20
  client_code = opts.fetch(:client_code, nil)
21
+ language = opts.fetch(:language, nil)
20
22
 
21
- get url(end_point), params, client_id, client_code
23
+ get url(end_point), params, client_id, client_code, language
22
24
  end
23
25
 
24
26
  # POST an authorized message to the vbmappdata server
@@ -27,7 +29,7 @@ module DmtdVbmappData
27
29
  # +end_point+:: The end point to post
28
30
  # +params+:: The parameters to send to the end point (may be nil)
29
31
  # +client_id+:: The client id under which to record the post (may be nil)
30
- # +client_code+:: The client code under which to record the post (maybe nil)
32
+ # +client_code+:: The client code under which to record the post (may be nil)
31
33
  def self.post_authorized(opts = {})
32
34
  end_point = opts.fetch(:end_point)
33
35
  params = opts.fetch(:params, nil)
@@ -55,10 +57,10 @@ module DmtdVbmappData
55
57
 
56
58
  private
57
59
 
58
- def self.get(uri, params, client_id, client_code)
60
+ def self.get(uri, params, client_id, client_code, language)
59
61
  http = Net::HTTP.new(uri.host, uri.port)
60
62
  request = Net::HTTP::Get.new(uri.request_uri)
61
- add_auth(request, client_id, client_code)
63
+ add_auth(request, client_id, client_code, language)
62
64
  request.set_form_data params unless params.nil?
63
65
 
64
66
  http.request(request)
@@ -67,7 +69,7 @@ module DmtdVbmappData
67
69
  def self.post(uri, params, client_id, client_code)
68
70
  http = Net::HTTP.new(uri.host, uri.port)
69
71
  request = Net::HTTP::Post.new(uri.request_uri)
70
- add_auth(request, client_id, client_code)
72
+ add_auth(request, client_id, client_code, nil)
71
73
  request.body = JSON(params)
72
74
 
73
75
  http.request(request)
@@ -77,7 +79,7 @@ module DmtdVbmappData
77
79
  URI.parse("#{DmtdVbmappData.config[:server_url]}/#{end_point}")
78
80
  end
79
81
 
80
- def self.add_auth(request, client_id = nil, client_code = nil)
82
+ def self.add_auth(request, client_id = nil, client_code = nil, language)
81
83
  session_token = DmtdVbmappData.config[:auth_token]
82
84
 
83
85
  request['Authorization'] = "Token token=\"#{session_token}\""
@@ -86,6 +88,7 @@ module DmtdVbmappData
86
88
  request['X-ClientId'] = client_id unless client_id.nil?
87
89
  request['X-ClientCode'] = client_code unless client_code.nil?
88
90
  request['X-DocType'] = DmtdVbmappData.config[:document_type].downcase unless DmtdVbmappData.config[:document_type].nil?
91
+ request['Accept-Language'] = language unless language.nil?
89
92
  end
90
93
  end
91
94
  end
@@ -52,7 +52,7 @@ module DmtdVbmappData
52
52
  end
53
53
 
54
54
  def retrieve_vbmapp_index
55
- response = RequestHelpers::get_authorized(end_point: Vbmapp::end_point, params: nil, client_id: @client.id, client_code: @client.code)
55
+ response = RequestHelpers::get_authorized(end_point: Vbmapp::end_point, params: nil, client_id: @client.id, client_code: @client.code, languge: client.language)
56
56
  proc_response = RequestHelpers::process_json_response(response)
57
57
  json = proc_response[:json]
58
58
  server_response_code = proc_response[:code]
@@ -57,7 +57,7 @@ module DmtdVbmappData
57
57
  params = {
58
58
  area: area
59
59
  }
60
- response = RequestHelpers::get_authorized(end_point: VbmappArea::end_point, params: params, client_id: @client.id, client_code: @client.code)
60
+ response = RequestHelpers::get_authorized(end_point: VbmappArea::end_point, params: params, client_id: @client.id, client_code: @client.code, language: client.language)
61
61
  proc_response = RequestHelpers::process_json_response(response)
62
62
  json = proc_response[:json]
63
63
  server_response_code = proc_response[:code]
@@ -36,9 +36,9 @@ module DmtdVbmappData
36
36
  level_name = opts.fetch(:level, nil)
37
37
 
38
38
  if @questions.nil?
39
- question_json = retrieve_question_json
39
+ questions_json = retrieve_questions_json
40
40
 
41
- @questions = question_json.map {|question_json|
41
+ @questions = questions_json.map {|question_json|
42
42
  VbmappAreaQuestion.new(client: client, area: area, group: group, question_json: question_json)
43
43
  }
44
44
  end
@@ -71,12 +71,12 @@ module DmtdVbmappData
71
71
  '1/vbmapp/area_question'
72
72
  end
73
73
 
74
- def retrieve_question_json
74
+ def retrieve_questions_json
75
75
  params = {
76
76
  area: area,
77
77
  group: group
78
78
  }
79
- response = RequestHelpers::get_authorized(end_point: VbmappAreaGroup::end_point, params: params, client_id: @client.id, client_code: @client.code)
79
+ response = RequestHelpers::get_authorized(end_point: VbmappAreaGroup::end_point, params: params, client_id: @client.id, client_code: @client.code, language: client.language)
80
80
  proc_response = RequestHelpers::process_json_response(response)
81
81
  json = proc_response[:json]
82
82
  server_response_code = proc_response[:code]
@@ -1,3 +1,3 @@
1
1
  module DmtdVbmappData
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dmtd_vbmapp_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Hunt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-05-05 00:00:00.000000000 Z
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: psych