HTTP RESTFul for calling DataWow APIs
support or question support@datawow.io
gem 'datawow', '~> 1.5.0'$ rails generate datawow:installNote: Rails 4.1 or above
To call our module, use Datawow followed by any of the classes provided in our APIs
These classes are instance methods we have created for you. You can use our provider or the recommended methods, here, when using our APIs
There are 6 APIs for image class
Datawow.image_closed_question
Datawow.image_photo_tag
Datawow.image_choice
Datawow.image_message
Datawow.nanameue_human
Datawow.document_verificationThere is 1 API for video class
Datawow.video_classificationThere are 4 APIs for text class
Datawow.text_closed_question
Datawow.text_category
Datawow.text_conversation
Datawow.text_jaThere is 1 API for prediction class
Datawow.predictionThere is 1 API for moderation class
Datawow.moderationAbove methods are shortcuts for calling the following classes
Datawow::ImageClosedQuestion
Datawow::PhotoTag
Datawow::ImageChoice
Datawow::ImageMessage
Datawow::NanameueHuman
Datawow::VideoClassification
Datawow::TextClosedQuestion
Datawow::TextCategory
Datawow::TextConversation
Datawow::TextJa
Datawow::Prediction
Datawow::DocumentVerification
Datawow::ModerationThere are 3 main functions for each class: create, find_by and all
Datawow.[class].create(data: {})Datawow.[class].find_by({id: "_image_id"})Datawow.[class].all()After the library has been called for the first time, the associated modules will be initialized and you could then call using the package name instead. here
Datawow.project_key = '_token'Datawow.[class].create({data: "image URL"})Datawow.[class].find_by({id: "_image_id"})Datawow.[class].all({page: '_page', per_page: '_per_page'})If you have many projects, we recommend using the following example instead of the one shown above if you would like to create an object and change its token dynamically
Datawow::[class].new('_token').create({data: "image URL"})or
model = Datawow::[class].new
model.project_key = '_token'
model.create()For available method, see calling APIs section
config/initializers/datawow.rb
Datawow.setup do |config|
# ==> Secret key Configuration
# You can change it below and use your own secret key.
config.project_key = 'your token'
endResponse is a module and it contains data including: data, meta-data, message, and status
<Datawow::Response @status=200, @message="success" @meta={"code"=>200, "message"=>"success"}, @data={...}, />You can call the data property to get the data, which would return in the format as shown below
{
"data": {
"image": {
"id": "5a40be59fb9d7f27354c5efa",
"answer": "approved",
"credit_charged": 1,
"custom_id": "custom_id",
"data": "image_url",
"postback_url": "postback_url",
"processed_at": "2017-12-25T16:02:00.599+07:00",
"project_id": "project_id",
"status": "processed"
}
},
"status": 200,
"message": "success",
"meta": {
"code": 200,
"message": "success"
}
}if response.successful?
# Do stuff
else
log.error("Request was not successful, something went wrong.")
end