Class: DocomoNlu::Management::Entry
- Inherits:
-
Base
- Object
- ActiveResource::Base
- Base
- DocomoNlu::Management::Entry
show all
- Defined in:
- lib/docomo_nlu/management/entry.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
check_response, headers, #id_from_response, instantiate_collection, instantiate_record, #login, #logout, #static_headers
Constructor Details
#initialize(attributes = {}, persisted = false) ⇒ Entry
Returns a new instance of Entry.
9
10
11
12
|
# File 'lib/docomo_nlu/management/entry.rb', line 9
def initialize(attributes = {}, persisted = false)
super(attributes, persisted)
prefix_options[:method] = "entry"
end
|
Class Method Details
.check_status(prefix_options) ⇒ Object
23
24
25
|
# File 'lib/docomo_nlu/management/entry.rb', line 23
def check_status(prefix_options)
JSON.parse(connection.get("#{collection_path(prefix_options)}/status", ).body)
end
|
.upload(file, prefix_options) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/docomo_nlu/management/entry.rb', line 27
def upload(file, prefix_options)
conn = Faraday.new(url: site.to_s, ssl: { verify: false }) do |builder|
builder.request :multipart builder.request :url_encoded
builder.adapter :net_http
end
conn.["Authorization"] = access_token
params = {
uploadFile: Faraday::UploadIO.new(file.path, "text/plain"),
}
response = conn.post collection_path(prefix_options), params
check_response(response)
end
|
Instance Method Details
#save ⇒ Object
14
15
16
|
# File 'lib/docomo_nlu/management/entry.rb', line 14
def save
self.class.upload(attributes[:file], prefix_options)
end
|
#status ⇒ Object
18
19
20
|
# File 'lib/docomo_nlu/management/entry.rb', line 18
def status
self.class.check_status(prefix_options)
end
|