Project

docomoru

0.02
No commit activity in last 3 years
No release in over 3 years
Client library for docomo API written in Ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
= 10.4.2
= 3.2.0
= 0.29.1
= 1.20.4

Runtime

 Project Readme

Docomoru Build Status Code Climate Test Coverage

Client library for docomo API written in Ruby.

CAUTION: Docomoru does not work now. See #3

Install

docomoru can be installed from rubygems.org as a gem.

gem install docomoru

Authentication

To use docomo API via docomoru, you need to get docomo API Key.

  1. Sign-in to https://dev.smt.docomo.ne.jp/
  2. Register new application
  3. Generate API Key

Supported APIs

Currently docomoru is supporting the following APIs.

Usage

You can use docomoru as a library on Ruby code or an executable on CLI.

Library

Create an instance of Docomoru::Client, then call a method to send an HTTP request to docomo API. Each method returns Docomoru::Response that has status code, headers, and body values.

Here is an example code to use Dialogue API via docomoru. As you can see, Docomoru::Client provides low-level interface of HTTP, so you may need some wrapper class to use it from your application.

client = Docomoru::Client.new(api_key: ENV["DOCOMO_API_KEY"])
response = client.create_dialogue("Gemつくりました")
response.status #=> 200
response.headers #=> {
  "Asyncserviceinvoke" => "false",
  "Content-Type"       => "application/json;charset=UTF-8",
  "Date"               => "Fri, 05 Dec 2014 15:10:11 GMT",
  "Content-Length"     => "165",
  "Connection"         => "Close"
}
response.body #=> {
  "utt"     => "gemに登録されるのでしょうかね",
  "yomi"    => "gemに登録されるのでしょうかね",
  "mode"    => "dialog",
  "da"      => "12",
  "context" => "dXIgT9u1_XKfO1QbaVkAGQ"
}

CLI

docomoru executable is bundled to call docomo API from CLI. This executable handily creates an instance of Docomoru::Client with given API Key, then call the specified method, and returns its response.

$ docomoru <method> <arguments> [options]
              |          |          |
              |          |          `-- -a, --api-key (or use DOCOMO_API_KEY env)
              |          |              -h, --help
              |          |                  --header
              |          |                  --no-body
              |          |
              |          `------------- required arguments for the method
              |
              `------------------------ method name

$ docomoru create_dialogue かわいい
$ docomoru create_knowledge Rubyの作者は誰ですか