nexosis_api 2.0.1 → 2.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 (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nexosis_api.rb +11 -11
  3. data/lib/nexosis_api/algorithm.rb +22 -22
  4. data/lib/nexosis_api/algorithm_contestant.rb +43 -43
  5. data/lib/nexosis_api/anomaly_scores.rb +19 -0
  6. data/lib/nexosis_api/calendar_jointarget.rb +35 -35
  7. data/lib/nexosis_api/classifier_result.rb +25 -25
  8. data/lib/nexosis_api/classifier_scores.rb +26 -0
  9. data/lib/nexosis_api/client.rb +120 -118
  10. data/lib/nexosis_api/client/contest.rb +66 -66
  11. data/lib/nexosis_api/client/datasets.rb +155 -155
  12. data/lib/nexosis_api/client/imports.rb +141 -141
  13. data/lib/nexosis_api/client/models.rb +121 -108
  14. data/lib/nexosis_api/client/sessions.rb +308 -213
  15. data/lib/nexosis_api/client/views.rb +105 -105
  16. data/lib/nexosis_api/column.rb +50 -50
  17. data/lib/nexosis_api/column_options.rb +38 -38
  18. data/lib/nexosis_api/column_role.rb +19 -19
  19. data/lib/nexosis_api/column_type.rb +23 -23
  20. data/lib/nexosis_api/dataset_data.rb +22 -22
  21. data/lib/nexosis_api/dataset_jointarget.rb +18 -18
  22. data/lib/nexosis_api/dataset_model.rb +26 -26
  23. data/lib/nexosis_api/dataset_summary.rb +33 -33
  24. data/lib/nexosis_api/http_exception.rb +28 -28
  25. data/lib/nexosis_api/impact_metric.rb +22 -22
  26. data/lib/nexosis_api/imports_response.rb +74 -74
  27. data/lib/nexosis_api/join.rb +63 -63
  28. data/lib/nexosis_api/link.rb +18 -18
  29. data/lib/nexosis_api/message.rb +19 -19
  30. data/lib/nexosis_api/metric.rb +16 -16
  31. data/lib/nexosis_api/model_summary.rb +66 -66
  32. data/lib/nexosis_api/paged_array.rb +35 -35
  33. data/lib/nexosis_api/predict_response.rb +35 -35
  34. data/lib/nexosis_api/session.rb +122 -118
  35. data/lib/nexosis_api/session_contest.rb +30 -30
  36. data/lib/nexosis_api/session_response.rb +29 -33
  37. data/lib/nexosis_api/session_result.rb +27 -27
  38. data/lib/nexosis_api/session_selection_metrics.rb +20 -20
  39. data/lib/nexosis_api/time_interval.rb +15 -15
  40. data/lib/nexosis_api/view_data.rb +14 -14
  41. data/lib/nexosis_api/view_definition.rb +64 -64
  42. data/nexosisapi.gemspec +20 -20
  43. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05b7aebc636b47c645dc8ca1d8440dde6c26f523
4
- data.tar.gz: 29acd4e727fe0e346fa7fcf4d55ad51a45c3de41
3
+ metadata.gz: c12a9dee350193af3df27068feb8161999a7d085
4
+ data.tar.gz: c2f3cd6d4b24c211a4eab0c5bd2ed07dd4e6b132
5
5
  SHA512:
6
- metadata.gz: 3dfd4f118c8a030fb867d370b3262f995d3e2ef516d8e887dc3d9e4d6a964780e40dba3e08bd399dc04613e82ca923b12f078f57dd2775bb89246f6b8f26732c
7
- data.tar.gz: e81a1e499369c1a61e603ed0ce35da9f846718d91646cecd4bd95e0eaf3d6c346f5f558703128c92f9a8f805130db1987893302cd776e132b07595b978011290
6
+ metadata.gz: 59e8f973c4aa67adb891ef177deeb8571ed99413a8efb6fc826e46058d286e9a308e1d87c014294ce9a4ae2e8b756402f0b592dbb1b31ba0cebfc9686360a17f
7
+ data.tar.gz: b3952c5b3d130305511310e4b77f028ada6832e90ecf1d113f8c842ece1ee2a82754553863d3766998c8c61da6fca998b4afda20de84b11042fd65ecff07ea74
@@ -1,12 +1,12 @@
1
- require 'httparty'
2
- require 'nexosis_api/client'
3
-
4
- # The container for the Nexosis API Client
5
- module NexosisApi
6
- class << self
7
- def client options = {}
8
- return @client if defined?(@client)
9
- @client = NexosisApi::Client.new(options)
10
- end
11
- end
1
+ require 'httparty'
2
+ require 'nexosis_api/client'
3
+
4
+ # The container for the Nexosis API Client
5
+ module NexosisApi
6
+ class << self
7
+ def client options = {}
8
+ return @client if defined?(@client)
9
+ @client = NexosisApi::Client.new(options)
10
+ end
11
+ end
12
12
  end
@@ -1,22 +1,22 @@
1
- module NexosisApi
2
- # Class to parse an individual algorithm
3
- class Algorithm
4
- def initialize(algo_hash)
5
- algo_hash.each do |k, v|
6
- instance_variable_set("@#{k}", v) unless v.nil?
7
- end
8
- end
9
-
10
- # A unique identififer for the algorithm
11
- # @return [String]
12
- attr_accessor :key
13
-
14
- # A friendly name for the algorithm
15
- # @return [String]
16
- attr_accessor :name
17
-
18
- # Descriptive explanation of the algorithm implementation
19
- # @return [String]
20
- attr_accessor :description
21
- end
22
- end
1
+ module NexosisApi
2
+ # Class to parse an individual algorithm
3
+ class Algorithm
4
+ def initialize(algo_hash)
5
+ algo_hash.each do |k, v|
6
+ instance_variable_set("@#{k}", v) unless v.nil?
7
+ end
8
+ end
9
+
10
+ # A unique identififer for the algorithm
11
+ # @return [String]
12
+ attr_accessor :key
13
+
14
+ # A friendly name for the algorithm
15
+ # @return [String]
16
+ attr_accessor :name
17
+
18
+ # Descriptive explanation of the algorithm implementation
19
+ # @return [String]
20
+ attr_accessor :description
21
+ end
22
+ end
@@ -1,43 +1,43 @@
1
- module NexosisApi
2
- # Class to parse results of an algorithm run
3
- # @since 2.0.0
4
- class AlgorithmContestant
5
- def initialize(contestant_hash)
6
- contestant_hash.each do |k, v|
7
- if k.to_s == 'links'
8
- instance_variable_set("@#{k}", v.map { |l| NexosisApi::Link.new(l) unless l.nil? })
9
- elsif k.to_s == 'dataSourceProperties'
10
- @datasource_properties = v
11
- elsif k.to_s == 'algorithm'
12
- instance_variable_set("@#{k}", NexosisApi::Algorithm.new(v)) unless v.nil?
13
- else
14
- instance_variable_set("@#{k}", v)
15
- end
16
- end
17
- end
18
-
19
- # Unique identifier for this contestant
20
- attr_reader :id
21
-
22
- # Identifier of algorithm run
23
- # @return [NexosisApi::Algorithm]
24
- attr_accessor :algorithm
25
-
26
- # Name and value for metrics calculated for this algorithm
27
- # @return [Hash]
28
- attr_accessor :metrics
29
-
30
- # Relevant hypermedia as {NexosisApi::Link}
31
- # @return [Array]
32
- attr_accessor :links
33
-
34
- # Operations performed on datasource prior to run
35
- # @return [Array]
36
- attr_reader :datasource_properties
37
-
38
- # The test dataset used to score the algo
39
- # @return [Array of Hash] columnname: value hash of each observation row in test set
40
- # @note - may be nil when reviewing contestant lists
41
- attr_reader :data
42
- end
43
- end
1
+ module NexosisApi
2
+ # Class to parse results of an algorithm run
3
+ # @since 2.0.0
4
+ class AlgorithmContestant
5
+ def initialize(contestant_hash)
6
+ contestant_hash.each do |k, v|
7
+ if k.to_s == 'links'
8
+ instance_variable_set("@#{k}", v.map { |l| NexosisApi::Link.new(l) unless l.nil? })
9
+ elsif k.to_s == 'dataSourceProperties'
10
+ @datasource_properties = v
11
+ elsif k.to_s == 'algorithm'
12
+ instance_variable_set("@#{k}", NexosisApi::Algorithm.new(v)) unless v.nil?
13
+ else
14
+ instance_variable_set("@#{k}", v)
15
+ end
16
+ end
17
+ end
18
+
19
+ # Unique identifier for this contestant
20
+ attr_reader :id
21
+
22
+ # Identifier of algorithm run
23
+ # @return [NexosisApi::Algorithm]
24
+ attr_accessor :algorithm
25
+
26
+ # Name and value for metrics calculated for this algorithm
27
+ # @return [Hash]
28
+ attr_accessor :metrics
29
+
30
+ # Relevant hypermedia as {NexosisApi::Link}
31
+ # @return [Array]
32
+ attr_accessor :links
33
+
34
+ # Operations performed on datasource prior to run
35
+ # @return [Array]
36
+ attr_reader :datasource_properties
37
+
38
+ # The test dataset used to score the algo
39
+ # @return [Array of Hash] columnname: value hash of each observation row in test set
40
+ # @note - may be nil when reviewing contestant lists
41
+ attr_reader :data
42
+ end
43
+ end
@@ -0,0 +1,19 @@
1
+ require 'nexosis_api/session_response'
2
+ module NexosisApi
3
+ # class to hold the parsed results of an anomalyScores request
4
+ # @since 2.1.0
5
+ class AnomalyScores < SessionResponse
6
+ def initialize(result_hash)
7
+ @data = NexosisApi::PagedArray.new(result_hash, result_hash['data'])
8
+ @percent_anomalies = result_hash['metrics']['percentAnomalies'] unless result_hash['metrics'].nil?
9
+ super(result_hash.reject { |k, _v| k.to_s == 'data' || k.to_s == 'metrics' })
10
+ end
11
+
12
+ # The anomalies found while building your model.
13
+ # @return [NexosisApi::PagedArray] per observation feature scores of the form {"target_col": "0.3882", "col_1" : "0.828", "target_col:actual" : "0.402"}
14
+ attr_reader :data
15
+
16
+ # The percent of observations found to be anomalous in the training data set
17
+ attr_reader :percent_anomalies
18
+ end
19
+ end
@@ -1,35 +1,35 @@
1
- module NexosisApi
2
- # Specifies the details of a calendar data source to join to
3
- # @see http://docs.nexosis.com/guides/calendars
4
- # @since 1.2.3
5
- class CalendarJoinTarget
6
- def initialize(cal_join_hash)
7
- @url = cal_join_hash['url'] unless cal_join_hash.nil?
8
- @name = cal_join_hash['name'] unless cal_join_hash.nil?
9
- @timezone = cal_join_hash['timeZone'] unless cal_join_hash.nil?
10
- end
11
-
12
- # The location of a public iCal to download as the datasource
13
- # @return [String]
14
- attr_accessor :url
15
-
16
- # The name of a well-known Nexosis calendar.
17
- # @return [String]
18
- # @see http://docs.nexosis.com/guides/datasources
19
- attr_accessor :name
20
-
21
- # tz-db string name of the timezone of the calendar
22
- # @return [String]
23
- # @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
24
- attr_accessor :timezone
25
-
26
- # custom hash to match with api requests
27
- def to_hash
28
- hash = { 'calendar' => {} }
29
- hash['calendar'].store 'url', url unless url.nil?
30
- hash['calendar'].store 'name', name unless name.nil?
31
- hash['calendar'].store 'timeZone', name unless timezone.nil?
32
- hash
33
- end
34
- end
35
- end
1
+ module NexosisApi
2
+ # Specifies the details of a calendar data source to join to
3
+ # @see http://docs.nexosis.com/guides/calendars
4
+ # @since 1.2.3
5
+ class CalendarJoinTarget
6
+ def initialize(cal_join_hash)
7
+ @url = cal_join_hash['url'] unless cal_join_hash.nil?
8
+ @name = cal_join_hash['name'] unless cal_join_hash.nil?
9
+ @timezone = cal_join_hash['timeZone'] unless cal_join_hash.nil?
10
+ end
11
+
12
+ # The location of a public iCal to download as the datasource
13
+ # @return [String]
14
+ attr_accessor :url
15
+
16
+ # The name of a well-known Nexosis calendar.
17
+ # @return [String]
18
+ # @see http://docs.nexosis.com/guides/datasources
19
+ attr_accessor :name
20
+
21
+ # tz-db string name of the timezone of the calendar
22
+ # @return [String]
23
+ # @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
24
+ attr_accessor :timezone
25
+
26
+ # custom hash to match with api requests
27
+ def to_hash
28
+ hash = { 'calendar' => {} }
29
+ hash['calendar'].store 'url', url unless url.nil?
30
+ hash['calendar'].store 'name', name unless name.nil?
31
+ hash['calendar'].store 'timeZone', name unless timezone.nil?
32
+ hash
33
+ end
34
+ end
35
+ end
@@ -1,25 +1,25 @@
1
- require 'nexosis_api/session'
2
- module NexosisApi
3
- # class to hold parsed results of confusion matrix request
4
- # @since 1.4.1
5
- class ClassifierResult < Session
6
- def initialize(classify_result)
7
- classify_result.each do |k, v|
8
- if (k.to_s == 'confusionMatrix')
9
- @confusion_matrix = v
10
- elsif (k.to_s == 'classes')
11
- @classes = v
12
- end
13
- end
14
- super(classify_result)
15
- end
16
-
17
- # array of arrays to form confusion matrix results
18
- # @return [Array of Array of Int] - the class counts for expected to predicted
19
- attr_accessor :confusion_matrix
20
-
21
- # Class labels in index order of matrix arrays
22
- # @return [Array]
23
- attr_accessor :classes
24
- end
25
- end
1
+ require 'nexosis_api/session'
2
+ module NexosisApi
3
+ # class to hold parsed results of confusion matrix request
4
+ # @since 1.4.1
5
+ class ClassifierResult < Session
6
+ def initialize(classify_result)
7
+ classify_result.each do |k, v|
8
+ if (k.to_s == 'confusionMatrix')
9
+ @confusion_matrix = v
10
+ elsif (k.to_s == 'classes')
11
+ @classes = v
12
+ end
13
+ end
14
+ super(classify_result)
15
+ end
16
+
17
+ # array of arrays to form confusion matrix results
18
+ # @return [Array of Array of Int] - the class counts for expected to predicted
19
+ attr_accessor :confusion_matrix
20
+
21
+ # Class labels in index order of matrix arrays
22
+ # @return [Array]
23
+ attr_accessor :classes
24
+ end
25
+ end
@@ -0,0 +1,26 @@
1
+ require 'nexosis_api/session_response'
2
+ module NexosisApi
3
+ # class to hold parsed results of classifier scores request
4
+ # @since 2.1.0
5
+ class ClassifierScores < SessionResponse
6
+ def initialize(classify_scores)
7
+ props = %w[data metrics classes]
8
+ classify_scores.select { |k, _v| props.include? k }.each { |k, v| instance_variable_set("@#{k}", v) }
9
+ @data = NexosisApi::PagedArray.new(classify_scores, classify_scores['data'])
10
+ super(classify_scores.reject { |k, _v| props.include? k })
11
+ end
12
+
13
+ # array of hashes with each class and its scored result
14
+ # @return [NexosisApi::PagedArray] - the class result along with scores for each candidate class
15
+ # @note the hash takes the form {"target": "class2", "target:class1": "3.21545", "target:class2":"4.2654", "feature1": "value", "target:actual": "class2"}
16
+ attr_reader :data
17
+
18
+ # Class labels represented in the data
19
+ # @return [Array]
20
+ attr_reader :classes
21
+
22
+ # metrics of the classification model building session
23
+ # @return [Hash] name value pairs of metrics
24
+ attr_reader :metrics
25
+ end
26
+ end
@@ -1,118 +1,120 @@
1
- require 'nexosis_api/algorithm_contestant'
2
- require 'nexosis_api/algorithm'
3
- require 'nexosis_api/calendar_jointarget'
4
- require 'nexosis_api/classifier_result'
5
- require 'nexosis_api/column'
6
- require 'nexosis_api/column_options'
7
- require 'nexosis_api/column_role'
8
- require 'nexosis_api/column_type'
9
- require 'nexosis_api/dataset_data'
10
- require 'nexosis_api/dataset_jointarget'
11
- require 'nexosis_api/dataset_model'
12
- require 'nexosis_api/dataset_summary'
13
- require 'nexosis_api/http_exception'
14
- require 'nexosis_api/impact_metric'
15
- require 'nexosis_api/imports_response'
16
- require 'nexosis_api/join'
17
- require 'nexosis_api/link'
18
- require 'nexosis_api/message'
19
- require 'nexosis_api/metric'
20
- require 'nexosis_api/model_summary'
21
- require 'nexosis_api/paged_array'
22
- require 'nexosis_api/predict_response'
23
- require 'nexosis_api/session_contest'
24
- require 'nexosis_api/session_response'
25
- require 'nexosis_api/session_result'
26
- require 'nexosis_api/session_selection_metrics'
27
- require 'nexosis_api/session'
28
- require 'nexosis_api/time_interval'
29
- require 'nexosis_api/view_definition'
30
- require 'nexosis_api/view_data'
31
- require 'nexosis_api/client/contest'
32
- require 'nexosis_api/client/sessions'
33
- require 'nexosis_api/client/datasets'
34
- require 'nexosis_api/client/imports'
35
- require 'nexosis_api/client/views'
36
- require 'nexosis_api/client/models'
37
-
38
- module NexosisApi
39
- # Primary entry point to working with Nexosis API
40
- class Client
41
- include HTTParty
42
- base_uri 'https://ml.nexosis.com/v1'
43
- include Client::Sessions
44
- include Client::Datasets
45
- include Client::Imports
46
- include Client::Views
47
- include Client::Models
48
- include Client::Contest
49
-
50
- def initialize(options = {})
51
- raise ArgumentError, 'api_key was not defined' unless options[:api_key].nil? == false
52
- @api_key = options[:api_key]
53
- self.class.base_uri options[:base_uri] unless options[:base_uri].nil?
54
- @headers = { 'api-key' => @api_key, 'Content-Type' => 'application/json',
55
- 'User-Agent' => 'Nexosis-Ruby-API-Client/1.2' }
56
- @options = { headers: @headers, format: :json }
57
- end
58
-
59
- # Gets the quota stats for the account
60
- #
61
- # @return [Hash] a hash of quota values and current values
62
- def get_account_quotas()
63
- session_url = '/sessions?page=0&pageSize=1'
64
- response = self.class.get(session_url, @options)
65
- response.headers.select { |k, _v| k.to_s.start_with? 'nexosis-account' }
66
- end
67
-
68
- # Provide access to read or modify the api key
69
- # @return [String]
70
- # @since 2.0.0
71
- def api_key(value)
72
- @api_key = value unless value.nil?
73
- @headers['api-key'] = @api_key
74
- @api_key
75
- end
76
-
77
- private
78
-
79
- # @private
80
- def process_csv_to_s csv
81
- content = ''
82
- if(csv.is_a?(CSV))
83
- csv.each do |row|
84
- if(csv.headers.nil?)
85
- # not using row.to_csv because it uses non-compliant '\n' newline
86
- content.concat(row.join(',')).concat("\r\n")
87
- else
88
- content.concat(row.fields.join(',')).concat("\r\n")
89
- end
90
- end
91
- if(csv.headers.nil? == false)
92
- content.prepend(csv.headers.join(',').concat("\r\n")) unless csv.headers.nil?
93
- end
94
- else
95
- content = csv
96
- end
97
- content
98
- end
99
-
100
- # @private
101
- def create_query(page_number, page_size, options = {})
102
- options.store(:page_number, page_number)
103
- options.store(:page_size, page_size)
104
- query = {
105
- 'page' => [page_number],
106
- 'pageSize' => [page_size]
107
- }
108
- query['startDate'] = [options[:start_date].iso8601.gsub(/\+/,'%2B')] unless options[:start_date].nil?
109
- query['endDate'] = [options[:end_date].iso8601.gsub(/\+/,'%2B')] unless options[:end_date].nil?
110
- query['include'] = options[:include] unless options[:include].nil?
111
- query
112
- end
113
-
114
- def array_query_normalizer(query_set)
115
- query_set.map { |key, value| value.map { |v| "#{key}=#{v}" } }.join('&')
116
- end
117
- end
118
- end
1
+ require 'nexosis_api/algorithm_contestant'
2
+ require 'nexosis_api/algorithm'
3
+ require 'nexosis_api/anomaly_scores'
4
+ require 'nexosis_api/calendar_jointarget'
5
+ require 'nexosis_api/classifier_result'
6
+ require 'nexosis_api/classifier_scores'
7
+ require 'nexosis_api/column'
8
+ require 'nexosis_api/column_options'
9
+ require 'nexosis_api/column_role'
10
+ require 'nexosis_api/column_type'
11
+ require 'nexosis_api/dataset_data'
12
+ require 'nexosis_api/dataset_jointarget'
13
+ require 'nexosis_api/dataset_model'
14
+ require 'nexosis_api/dataset_summary'
15
+ require 'nexosis_api/http_exception'
16
+ require 'nexosis_api/impact_metric'
17
+ require 'nexosis_api/imports_response'
18
+ require 'nexosis_api/join'
19
+ require 'nexosis_api/link'
20
+ require 'nexosis_api/message'
21
+ require 'nexosis_api/metric'
22
+ require 'nexosis_api/model_summary'
23
+ require 'nexosis_api/paged_array'
24
+ require 'nexosis_api/predict_response'
25
+ require 'nexosis_api/session_contest'
26
+ require 'nexosis_api/session_response'
27
+ require 'nexosis_api/session_result'
28
+ require 'nexosis_api/session_selection_metrics'
29
+ require 'nexosis_api/session'
30
+ require 'nexosis_api/time_interval'
31
+ require 'nexosis_api/view_definition'
32
+ require 'nexosis_api/view_data'
33
+ require 'nexosis_api/client/contest'
34
+ require 'nexosis_api/client/sessions'
35
+ require 'nexosis_api/client/datasets'
36
+ require 'nexosis_api/client/imports'
37
+ require 'nexosis_api/client/views'
38
+ require 'nexosis_api/client/models'
39
+
40
+ module NexosisApi
41
+ # Primary entry point to working with Nexosis API
42
+ class Client
43
+ include HTTParty
44
+ base_uri 'https://ml.nexosis.com/v1'
45
+ include Client::Sessions
46
+ include Client::Datasets
47
+ include Client::Imports
48
+ include Client::Views
49
+ include Client::Models
50
+ include Client::Contest
51
+
52
+ def initialize(options = {})
53
+ raise ArgumentError, 'api_key was not defined' unless options[:api_key].nil? == false
54
+ @api_key = options[:api_key]
55
+ self.class.base_uri options[:base_uri] unless options[:base_uri].nil?
56
+ @headers = { 'api-key' => @api_key, 'Content-Type' => 'application/json',
57
+ 'User-Agent' => 'Nexosis-Ruby-API-Client/2.1' }
58
+ @options = { headers: @headers, format: :json }
59
+ end
60
+
61
+ # Gets the quota stats for the account
62
+ #
63
+ # @return [Hash] a hash of quota values and current values
64
+ def get_account_quotas()
65
+ session_url = '/sessions?page=0&pageSize=1'
66
+ response = self.class.get(session_url, @options)
67
+ response.headers.select { |k, _v| k.to_s.start_with? 'nexosis-account' }
68
+ end
69
+
70
+ # Provide access to read or modify the api key
71
+ # @return [String]
72
+ # @since 2.0.0
73
+ def api_key(value)
74
+ @api_key = value unless value.nil?
75
+ @headers['api-key'] = @api_key
76
+ @api_key
77
+ end
78
+
79
+ private
80
+
81
+ # @private
82
+ def process_csv_to_s csv
83
+ content = ''
84
+ if(csv.is_a?(CSV))
85
+ csv.each do |row|
86
+ if(csv.headers.nil?)
87
+ # not using row.to_csv because it uses non-compliant '\n' newline
88
+ content.concat(row.join(',')).concat("\r\n")
89
+ else
90
+ content.concat(row.fields.join(',')).concat("\r\n")
91
+ end
92
+ end
93
+ if(csv.headers.nil? == false)
94
+ content.prepend(csv.headers.join(',').concat("\r\n")) unless csv.headers.nil?
95
+ end
96
+ else
97
+ content = csv
98
+ end
99
+ content
100
+ end
101
+
102
+ # @private
103
+ def create_query(page_number, page_size, options = {})
104
+ options.store(:page_number, page_number)
105
+ options.store(:page_size, page_size)
106
+ query = {
107
+ 'page' => [page_number],
108
+ 'pageSize' => [page_size]
109
+ }
110
+ query['startDate'] = [options[:start_date].iso8601.gsub(/\+/,'%2B')] unless options[:start_date].nil?
111
+ query['endDate'] = [options[:end_date].iso8601.gsub(/\+/,'%2B')] unless options[:end_date].nil?
112
+ query['include'] = options[:include] unless options[:include].nil?
113
+ query
114
+ end
115
+
116
+ def array_query_normalizer(query_set)
117
+ query_set.map { |key, value| value.map { |v| "#{key}=#{v}" } }.join('&')
118
+ end
119
+ end
120
+ end