motion-ai 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.md +22 -0
- data/README.md +44 -0
- data/Rakefile +19 -0
- data/lib/motion-ai.rb +5 -0
- data/lib/motion-ai/client.rb +50 -0
- metadata +173 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e618cfcc0879b9b07cb088c0df807bd040885ceb
|
4
|
+
data.tar.gz: 72826472b778413611f51c597c22e1be5c20ff75
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e2e2ca6d05f9976cf681df37617d435819fa2445ab9b3b963efddfbac43108d0ecf85f9fee85aa201d501d4f5ab102acfccd37b6e67e53bae3fc348f660cc65a
|
7
|
+
data.tar.gz: 26f327dcbcd58f79b87faf0a56a8d55cddae9507cd65a98f96e3f52b1bfb81359713dedcedbddc74d8ea7935bc2b20181f301741a1956120c49100f6db3a19c5
|
data/CHANGELOG.md
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 John Wang
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
Motion AI Ruby SDK
|
2
|
+
==================
|
3
|
+
|
4
|
+
Simple SDK for Motion AI REST API.
|
5
|
+
|
6
|
+
API endpoints:
|
7
|
+
|
8
|
+
Endpoint | Supported?
|
9
|
+
---------|-----------
|
10
|
+
`GET /messageBot` | yes
|
11
|
+
`POST /messsageHuman` | tbd
|
12
|
+
`GET /getConversations` | yes
|
13
|
+
`POST` Webhooks | tbd
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
```
|
18
|
+
$ gem install motion-ai
|
19
|
+
```
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'motion-ai'
|
25
|
+
|
26
|
+
client = MotionAI::Client.new bot: 'my_api_key', 'my_bot_id'
|
27
|
+
|
28
|
+
res = client.message_bot msg: 'Hello Bot!', session: '12345'
|
29
|
+
|
30
|
+
res = client.get_conversations
|
31
|
+
```
|
32
|
+
|
33
|
+
For more information on the parameters that can be passed to the API,
|
34
|
+
see the [Motion AI API docs](http://docs.motion.ai/docs/api).
|
35
|
+
|
36
|
+
## Links
|
37
|
+
|
38
|
+
Project Repo
|
39
|
+
|
40
|
+
* https://github.com/grokify/motion-ai-ruby
|
41
|
+
|
42
|
+
Motion AI Docs
|
43
|
+
|
44
|
+
* http://docs.motion.ai/docs/api
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
desc 'Default: run unit tests.'
|
5
|
+
task default: :test
|
6
|
+
|
7
|
+
desc 'Test the library.'
|
8
|
+
Rake::TestTask.new do |t|
|
9
|
+
t.libs << 'lib'
|
10
|
+
t.pattern = 'test/**/test_*.rb'
|
11
|
+
t.verbose = false
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'Generate YARD documentation.'
|
15
|
+
task :gendoc do
|
16
|
+
# puts 'yard doc generation disabled until JRuby build native extensions for redcarpet or yard removes the dependency.'
|
17
|
+
system 'yardoc'
|
18
|
+
system 'yard stats --list-undoc'
|
19
|
+
end
|
data/lib/motion-ai.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday_middleware'
|
3
|
+
require 'uri'
|
4
|
+
require 'pp'
|
5
|
+
|
6
|
+
module MotionAI
|
7
|
+
class Client
|
8
|
+
API_ENDPOINT = 'https://api.motion.ai/1.0'
|
9
|
+
GET_CONVERSATIONS_API_PATH = '/getConversations'
|
10
|
+
MESSAGE_BOT_API_PATH = '/messageBot'
|
11
|
+
|
12
|
+
attr_accessor: bot_id
|
13
|
+
|
14
|
+
def initialize(api_key, bot_id)
|
15
|
+
@api_key = api_key
|
16
|
+
@bot_id = bot_id
|
17
|
+
@http = Faraday.new(url: API_ENDPOINT) do |conn|
|
18
|
+
conn.response :json, content_type: /\bjson$/
|
19
|
+
conn.adapter Faraday.default_adapter
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def message_bot(params = {})
|
24
|
+
params[:key] = @api_key
|
25
|
+
params[:bot] = @bot_id
|
26
|
+
|
27
|
+
required = [:bot, :msg, :session, :key]
|
28
|
+
required.each do |param|
|
29
|
+
unless params.key? param
|
30
|
+
raise "Required param #{param} not present"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
@http.get URI.join(API_ENDPOINT, MESSAGE_BOT_API_PATH), params
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_conversations(params = {})
|
38
|
+
params[:key] = @api_key
|
39
|
+
|
40
|
+
required = [:key]
|
41
|
+
required.each do |param|
|
42
|
+
unless params.key? param
|
43
|
+
raise "Required param #{param} not present"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
@http.get URI.join(API_ENDPOINT, GET_CONVERSATIONS_API_PATH), params
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: motion-ai
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Wang
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: faraday_middleware
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: bundler
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '1'
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '1'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: coveralls
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
type: :development
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: mocha
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '1'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '1'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rake
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '12'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '12'
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: simplecov
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - "~>"
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
type: :development
|
117
|
+
prerelease: false
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - "~>"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
name: test-unit
|
125
|
+
requirement: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '3'
|
130
|
+
type: :development
|
131
|
+
prerelease: false
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - "~>"
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '3'
|
137
|
+
description: A Ruby SDK for the Motion AI API
|
138
|
+
email: johncwang@gmail.com
|
139
|
+
executables: []
|
140
|
+
extensions: []
|
141
|
+
extra_rdoc_files: []
|
142
|
+
files:
|
143
|
+
- CHANGELOG.md
|
144
|
+
- LICENSE.md
|
145
|
+
- README.md
|
146
|
+
- Rakefile
|
147
|
+
- lib/motion-ai.rb
|
148
|
+
- lib/motion-ai/client.rb
|
149
|
+
homepage: https://github.com/grokify/
|
150
|
+
licenses:
|
151
|
+
- MIT
|
152
|
+
metadata: {}
|
153
|
+
post_install_message:
|
154
|
+
rdoc_options: []
|
155
|
+
require_paths:
|
156
|
+
- lib
|
157
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - ">="
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: 2.2.2
|
162
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
requirements: []
|
168
|
+
rubyforge_project:
|
169
|
+
rubygems_version: 2.6.8
|
170
|
+
signing_key:
|
171
|
+
specification_version: 4
|
172
|
+
summary: Motion AI SDK - Ruby SDK for the Motion AI API
|
173
|
+
test_files: []
|