nexosis_api 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 +4 -4
- data/lib/nexosis_api/client/datasets.rb +4 -7
- data/lib/nexosis_api/client/sessions.rb +26 -23
- data/lib/nexosis_api/dataset_column.rb +2 -2
- data/lib/nexosis_api/dataset_summary.rb +1 -0
- data/nexosisapi.gemspec +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52b0b16b9e0a7690ade72a0498b125aa2672f89d
|
4
|
+
data.tar.gz: da93e102814f4b830e5b5411e873c2cd2c6017c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8742572d3e9860871553bf5056d71e3ff30a5fae276e39479b73591ee443e5327b305bd4f35dafb16d451b9273facead20148b4524b7d57bc5b5924d9a9f8b94
|
7
|
+
data.tar.gz: 9298f52be1a0a8d6fe131d3c63bcd28a6236a85d372fabf3380d86f121041af14f5164fe15eee3e025cb1271a5f6aef386575be727107bf62bbd94b0141ef319
|
@@ -113,11 +113,8 @@ module NexosisApi
|
|
113
113
|
}
|
114
114
|
|
115
115
|
if(filter_options.empty? == false)
|
116
|
-
query["startDate"] = filter_options[:start_date].to_s unless filter_options[:start_date].nil?
|
117
|
-
query["endDate"] = filter_options[:end_date].to_s unless filter_options[:end_date].nil?
|
118
|
-
end
|
119
|
-
if(query.values.all?{|v|v.to_s.empty?})
|
120
|
-
query = nil
|
116
|
+
query["startDate"] = filter_options[:start_date].to_s #unless filter_options[:start_date].nil?
|
117
|
+
query["endDate"] = filter_options[:end_date].to_s #unless filter_options[:end_date].nil?
|
121
118
|
end
|
122
119
|
response = self.class.delete(dataset_remove_url, :headers => @headers, :query => query)
|
123
120
|
if(response.success?)
|
@@ -155,9 +152,9 @@ module NexosisApi
|
|
155
152
|
"startDate" => options[:start_date].to_s,
|
156
153
|
"endDate" => options[:end_date].to_s,
|
157
154
|
"page" => options[:page_number],
|
158
|
-
"pageSize" => options[:page_size]
|
155
|
+
"pageSize" => options[:page_size],
|
156
|
+
"include" => options[:include]
|
159
157
|
}
|
160
|
-
query["include"] = options[:include].to_s unless options[:include].nil?
|
161
158
|
query
|
162
159
|
end
|
163
160
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'csv'
|
2
|
+
require 'json'
|
2
3
|
|
3
4
|
module NexosisApi
|
4
5
|
class Client
|
@@ -70,87 +71,89 @@ module NexosisApi
|
|
70
71
|
# Forecast from data already saved to the API.
|
71
72
|
#
|
72
73
|
# @param dataset_name [String] The name of the saved data set that has the data to forecast on.
|
73
|
-
# @param target_column [String] The name of the column for which you want predictions.
|
74
74
|
# @param start_date [DateTime] The starting date of the forecast period. Can be ISO 8601 string.
|
75
75
|
# @param end_date [DateTime] The ending date of the forecast period. Can be ISO 8601 string.
|
76
|
+
# @param target_column [String] The name of the column for which you want predictions. Nil if defined in dataset.
|
76
77
|
# @return [NexosisApi::SessionResponse] providing information about the sesssion
|
77
|
-
def create_forecast_session(dataset_name,
|
78
|
-
create_session
|
78
|
+
def create_forecast_session(dataset_name, start_date, end_date, target_column = nil)
|
79
|
+
create_session(dataset_name, start_date, end_date, target_column)
|
79
80
|
end
|
80
81
|
|
81
82
|
# Forecast from CSV formatted data.
|
82
83
|
#
|
83
84
|
# @param csv [CSV] initialized CSV object ready for reading.
|
84
|
-
# @param target_column [String] The name of the column for which you want predictions.
|
85
85
|
# @param start_date [DateTime] The starting date of the forecast period. Can be ISO 8601 parseable string.
|
86
86
|
# @param end_date [DateTime] The ending date of the forecast period. Can be ISO 8601 parseable string.
|
87
|
+
# @param target_column [String] The name of the column for which you want predictions.
|
87
88
|
# @return [NexosisApi::SessionResponse] providing information about the sesssion
|
88
89
|
# @example load and send local file
|
89
90
|
# mycsv = CSV.read('.\mylocal.csv')
|
90
91
|
# NexosisApi.client(:api_key=>mykey).create_forecast_session_csv(mycsv,'sales','01-01-2017','02-01-2017')
|
91
|
-
def create_forecast_session_csv(csv,
|
92
|
+
def create_forecast_session_csv(csv, start_date, end_date, target_column)
|
92
93
|
content = process_csv_to_s csv
|
93
|
-
create_session(nil,
|
94
|
+
create_session(nil, start_date, end_date, target_column, false, nil, "forecast", content)
|
94
95
|
end
|
95
96
|
|
96
97
|
# Forecast from data posted in the request.
|
97
98
|
#
|
98
99
|
# @param json_data [String] Json dataset matching the dataset input schema.
|
99
|
-
# @param target_column [String] The name of the column for which you want predictions.
|
100
100
|
# @param start_date [DateTime] The starting date of the forecast period. Can be ISO 8601 string.
|
101
101
|
# @param end_date [DateTime] The ending date of the forecast period. Can be ISO 8601 string.
|
102
|
+
# @param target_column [String] The name of the column for which you want predictions. Nil if defined in dataset
|
102
103
|
# @return [NexosisApi::SessionResponse] providing information about the sesssion
|
103
104
|
# @see https://developers.nexosis.com/docs/services/98847a3fbbe64f73aa959d3cededb3af/operations/5919ef80a730020dd851f233
|
104
|
-
def create_forecast_session_data(json_data,
|
105
|
-
|
105
|
+
def create_forecast_session_data(json_data, start_date, end_date, target_column = nil)
|
106
|
+
json_data = json_data.to_json unless json_data.is_a? String
|
107
|
+
create_session nil, start_date, end_date, target_column, false, nil, "forecast", json_data, "application/json"
|
106
108
|
end
|
107
109
|
|
108
110
|
# Estimate the cost of a forecast from data already saved to the API.
|
109
111
|
#
|
110
112
|
# @param dataset_name [String] The name of the saved data set that has the data to forecast on.
|
111
|
-
# @param target_column [String] The name of the column for which you want predictions.
|
112
113
|
# @param start_date [DateTime] The starting date of the forecast period. Can be ISO 8601 string.
|
113
114
|
# @param end_date [DateTime] The ending date of the forecast period. Can be ISO 8601 string.
|
115
|
+
# @param target_column [String] The name of the column for which you want predictions. Nil if defined in dataset.
|
114
116
|
# @return [NexosisApi::SessionResponse] providing information about the sesssion, including the cost
|
115
|
-
def estimate_forecast_session(dataset_name,
|
116
|
-
create_session dataset_name,
|
117
|
+
def estimate_forecast_session(dataset_name, start_date, end_date, target_column = nil)
|
118
|
+
create_session dataset_name, start_date, end_date, target_column, true
|
117
119
|
end
|
118
120
|
|
119
121
|
# Analyze impact for an event with data already saved to the API.
|
120
122
|
#
|
121
123
|
# @param dataset_name [String] The name of the saved data set that has the data to forecast on.
|
122
|
-
# @param target_column [String] The name of the column for which you want predictions.
|
123
124
|
# @param start_date [DateTime] The starting date of the impactful event. Can be ISO 8601 string.
|
124
125
|
# @param end_date [DateTime] The ending date of the impactful event. Can be ISO 8601 string.
|
125
126
|
# @param event_name [String] The name of the event.
|
127
|
+
# @param target_column [String] The name of the column for which you want predictions. Nil if defined in datatset.
|
126
128
|
# @return [NexosisApi::SessionResponse] providing information about the sesssion
|
127
|
-
def create_impact_session(dataset_name,
|
128
|
-
create_session dataset_name,
|
129
|
+
def create_impact_session(dataset_name, start_date, end_date, event_name, target_column = nil)
|
130
|
+
create_session dataset_name, start_date, end_date, target_column, false, event_name, "impact"
|
129
131
|
end
|
130
132
|
|
131
133
|
# Analyze impact for an event with data in json format.
|
132
134
|
#
|
133
135
|
# @param json_data [String] Json dataset matching the dataset input schema.
|
134
|
-
# @param target_column [String] The name of the column for which you want predictions.
|
135
136
|
# @param start_date [DateTime] The starting date of the impactful event. Can be ISO 8601 string.
|
136
137
|
# @param end_date [DateTime] The ending date of the impactful event. Can be ISO 8601 string.
|
137
138
|
# @param event_name [String] The name of the event.
|
139
|
+
# @param target_column [String] The name of the column for which you want predictions. Nil if defined in dataset.
|
138
140
|
# @return [NexosisApi::SessionResponse] providing information about the sesssion
|
139
141
|
# @see https://developers.nexosis.com/docs/services/98847a3fbbe64f73aa959d3cededb3af/operations/5919ef80a730020dd851f233
|
140
|
-
def create_impact_session_data(json_data,
|
141
|
-
|
142
|
+
def create_impact_session_data(json_data, start_date, end_date, event_name, target_column = nil)
|
143
|
+
json_data = json_data.to_json unless json_data.is_a? String
|
144
|
+
create_session nil, start_date, end_date, target_column, false, event_name, "impact", json_data, "application/json"
|
142
145
|
end
|
143
146
|
|
144
147
|
# Estimate the cost of impact analysis for an event with data already saved to the API.
|
145
148
|
#
|
146
149
|
# @param dataset_name [String] The name of the saved data set that has the data to forecast on.
|
147
|
-
# @param target_column [String] The name of the column for which you want predictions.
|
148
150
|
# @param start_date [DateTime] The starting date of the impactful event. Can be ISO 8601 string.
|
149
151
|
# @param end_date [DateTime] The ending date of the impactful event. Can be ISO 8601 string.
|
150
152
|
# @param event_name [String] The name of the event.
|
153
|
+
# @param target_column [String] The name of the column for which you want predictions. Nil if defined in dataset.
|
151
154
|
# @return [NexosisApi::SessionResponse] providing information about the sesssion, including the cost
|
152
|
-
def estimate_impact_session(dataset_name,
|
153
|
-
create_session dataset_name,
|
155
|
+
def estimate_impact_session(dataset_name, start_date, end_date, event_name, target_column = nil)
|
156
|
+
create_session dataset_name, start_date, end_date, target_column, true, event_name, "impact"
|
154
157
|
end
|
155
158
|
|
156
159
|
# Get the results of the session.
|
@@ -192,10 +195,10 @@ module NexosisApi
|
|
192
195
|
end
|
193
196
|
end
|
194
197
|
private
|
195
|
-
def create_session(dataset_name,
|
198
|
+
def create_session(dataset_name, start_date, end_date, target_column = nil, is_estimate=false, event_name = nil, type = "forecast", content = nil, content_type = "text/csv")
|
196
199
|
session_url = "/sessions/#{type}"
|
197
200
|
query = {
|
198
|
-
"targetColumn" => target_column,
|
201
|
+
"targetColumn" => target_column.to_s,
|
199
202
|
"startDate" => start_date.to_s,
|
200
203
|
"endDate" => end_date.to_s,
|
201
204
|
"isestimate" => is_estimate.to_s
|
@@ -3,8 +3,8 @@ module NexosisApi
|
|
3
3
|
class DatasetColumn
|
4
4
|
def initialize(column_name, value_hash)
|
5
5
|
@name = column_name
|
6
|
-
@type = NexosisApi::ColumnType.const_get(value_hash["dataType"].upcase)
|
7
|
-
@role = NexosisApi::ColumnRole.const_get(value_hash["role"].upcase)
|
6
|
+
@type = NexosisApi::ColumnType.const_get(value_hash["dataType"].upcase) unless value_hash["dataType"].nil?
|
7
|
+
@role = NexosisApi::ColumnRole.const_get(value_hash["role"].upcase) unless value_hash["role"].nil?
|
8
8
|
end
|
9
9
|
# The column header, label, or name
|
10
10
|
# @return [String]
|
data/nexosisapi.gemspec
CHANGED
@@ -11,11 +11,11 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.files = %w(nexosisapi.gemspec)
|
12
12
|
spec.files += Dir.glob("lib/**/*.rb")
|
13
13
|
spec.homepage = 'https://github.com/nexosis/nexosisclient-rb'
|
14
|
-
spec.licenses = ['
|
14
|
+
spec.licenses = ['Apache 2.0']
|
15
15
|
spec.name = 'nexosis_api'
|
16
16
|
spec.require_paths = ['lib']
|
17
17
|
spec.required_ruby_version = '>= 2.0.0'
|
18
18
|
spec.summary = "Ruby client for working with the Nexosis API"
|
19
|
-
spec.version = '1.0.
|
19
|
+
spec.version = '1.0.3'
|
20
20
|
spec.metadata["yard.run"] = "yri"
|
21
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexosis_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nexosis,Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -68,7 +68,7 @@ files:
|
|
68
68
|
- nexosisapi.gemspec
|
69
69
|
homepage: https://github.com/nexosis/nexosisclient-rb
|
70
70
|
licenses:
|
71
|
-
-
|
71
|
+
- Apache 2.0
|
72
72
|
metadata:
|
73
73
|
yard.run: yri
|
74
74
|
post_install_message:
|