by_robot 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4472816e99db7354a63e611bf1cec1e1acef05d72e9eac914cd9165728377f5c
4
+ data.tar.gz: ff399cfe0aa3ca17fc1b3dd65ee222cd2fbb92f2b0c37b7a611c2489b72de243
5
+ SHA512:
6
+ metadata.gz: bc5240c67c40be1a4af21fa9eddd00ed5b79c6e0c9c7319b40e23a0795eab5a67c3623d73ceb5a0572a8788916f40c5d5ea13fd6f9e311e60a33187bf36d0542
7
+ data.tar.gz: 4598cfdc598d93ed1c462cb4417f05406a8f14f47341e118bd3091c7322dad1a50c9cc093986cdf5315248dd58700b217037621b25fcddc1dac61d42ef4e0d49
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .idea
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+ .ruby-version
20
+ .ruby-gemset
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at liuliang0817@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://gems.ruby-china.com'
2
+
3
+ # Specify your gem's dependencies in by_robot.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 liuliang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # BYAI
2
+
3
+ ByRobot/BYAI Server SDK in Ruby.
4
+
5
+ ## API文档
6
+ - 官方文档(https://api.byrobot.cn/doc/v2)
7
+ - 官方网站(https://www.byai.com)
8
+
9
+ ## API接口
10
+
11
+ ### Company
12
+ - get_companys 获取绑定公司列表接口
13
+ - get_phones 获取公司的主叫电话列表接口
14
+ - get_robots 获取公司的机器人话术列表接口
15
+
16
+ ### Task
17
+ - create_task 创建任务接口
18
+ - start 启动任务接口
19
+ - pause 暂停任务接口
20
+ - stop 停止任务接口
21
+ - delete 删除任务
22
+ - import_task_customer 向任务中导入客户接口
23
+ - update 修改任务
24
+ - call 单次电话外呼
25
+ - single_call_by_mobile 根据手机号进行单次电话外呼
26
+ - get_tasks 获取任务列表接口
27
+ - get_task_detail 获取任务详情接口
28
+ - query_done_task_phones 获取已经完成任务电话号码接口
29
+ - not_dialed_customer_list 获取任务未开始的电话列表
30
+ - phone_log_info 获取一个通话的详情接口
31
+
32
+ ### 例子
33
+ ```ruby
34
+
35
+ ByRobot.app_key = "abc"
36
+ ByRobot.app_secret = "abc"
37
+ ByRobot::Company.get_companys
38
+ ByRobot::Task.get_tasks(companyId: 111)
39
+
40
+ ```
41
+
42
+ ## Installation
43
+
44
+ Add this line to your application's Gemfile:
45
+
46
+ ```ruby
47
+ gem 'by_robot'
48
+ ```
49
+
50
+ And then execute:
51
+
52
+ $ bundle
53
+
54
+ Or install it yourself as:
55
+
56
+ $ gem install by_robot
57
+
58
+ ## Usage
59
+
60
+ TODO: Write usage instructions here
61
+
62
+ ## Development
63
+
64
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
65
+
66
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
67
+
68
+ ## Contributing
69
+
70
+ Bug reports and pull requests are welcome on GitHub at https://github.com/liuliang/by_robot. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
71
+
72
+
73
+ ## License
74
+
75
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
76
+
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
3
+ task :console do
4
+ exec "irb -r by_robot -I ./lib"
5
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "by_robot"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/by_robot.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'by_robot/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "by_robot"
8
+ spec.version = ByRobot::VERSION
9
+ spec.authors = ["liuliang"]
10
+ spec.email = ["liuliang0817@gmail.com"]
11
+
12
+ spec.summary = %q{百应/BYAI的服务端接口.}
13
+ spec.description = %q{百应/BYAI的服务端接口.}
14
+ spec.homepage = "https://github.com/liuliang/by_robot"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.13"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.4"
27
+ spec.add_development_dependency "rest-client", "~> 1.8"
28
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+ module ByRobot
3
+ class Company
4
+
5
+ def self.get_companys(params={})
6
+ Request.get('/openapi/v1/company/getCompanys', params)
7
+ end
8
+
9
+ def self.get_phones(params={})
10
+ Request.check_required_params(params, %w(companyId))
11
+ Request.get('openapi/v1/company/getPhones', params)
12
+ end
13
+
14
+ def self.get_robots(params={})
15
+ Request.check_required_params(params, %w(companyId))
16
+ Request.get('openapi/v1/company/getRobots', params)
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,38 @@
1
+ module ByRobot
2
+ class Request
3
+
4
+ BASEURL = "http://api.byrobot.cn"
5
+
6
+ def self.check_required_params(params, names)
7
+ missing_params = names.map(&:to_s) - params.keys.map(&:to_s)
8
+ warn("Warn: missing required option: #{missing_params.join(',')}") if missing_params.size > 0
9
+ end
10
+
11
+ def self.sign(sign_message)
12
+ digest = OpenSSL::Digest.new('sha1')
13
+ sign = Base64.encode64 OpenSSL::HMAC.digest(digest, ByRobot.app_secret, sign_message)
14
+ end
15
+
16
+ def self.headers
17
+ headers = {
18
+ datetime: Time.now.utc.strftime('%a, %d %b %Y %H:%M:%S GMT'),
19
+ appkey: ByRobot.app_key
20
+ }
21
+ str = headers[:appkey] + "\n" + headers[:datetime]
22
+ headers[:sign] = sign(str)
23
+ headers
24
+ end
25
+
26
+ def self.get(action, params)
27
+ JSON.parse RestClient.get("#{BASEURL}/#{action}", headers.merge({params: params}))
28
+ end
29
+
30
+ def self.post(action, params)
31
+ puts "action:#{action}"
32
+ puts "params:#{params}"
33
+ puts "headers:#{headers}"
34
+ JSON.parse RestClient.post("#{BASEURL}/#{action}", params, headers)
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,76 @@
1
+ # encoding: utf-8
2
+ module ByRobot
3
+ class Task
4
+
5
+ def self.create_task(params={})
6
+ Request.check_required_params(params, %w(companyId taskName taskType startDate userPhoneIds sceneDefId robotDefId sceneRecordId callType))
7
+ Request.post('/openapi/v1/task/createTask', params)
8
+ end
9
+
10
+ def self.start(params={})
11
+ Request.check_required_params(params, %w(taskId))
12
+ Request.post('openapi/v1/task/start', params)
13
+ end
14
+
15
+ def self.pause(params={})
16
+ Request.check_required_params(params, %w(taskId))
17
+ Request.post('openapi/v1/task/pause', params)
18
+ end
19
+
20
+ def self.stop(params={})
21
+ Request.check_required_params(params, %w(taskId))
22
+ Request.post('openapi/v1/task/stop', params)
23
+ end
24
+
25
+ def self.delete(params={})
26
+ Request.check_required_params(params, %w(taskId))
27
+ Request.post('openapi/v1/task/delete', params)
28
+ end
29
+
30
+ def self.import_task_customer(params={})
31
+ Request.check_required_params(params, %w(companyId taskId customerInfoList))
32
+ Request.post('openapi/v1/task/importTaskCustomer', params)
33
+ end
34
+
35
+ def self.update(params={})
36
+ Request.check_required_params(params, %w(companyId taskId taskName taskType userPhoneIds callType concurrencyQuota))
37
+ Request.post('openapi/v1/task/update', params)
38
+ end
39
+
40
+ def self.call(params={})
41
+ Request.check_required_params(params, %w(customerId mobile companyId sceneDefId sceneRecordId robotDefId))
42
+ Request.post('openapi/v1/task/call', params)
43
+ end
44
+
45
+ def self.single_call_by_mobile(params={})
46
+ Request.check_required_params(params, %w(mobile companyId sceneDefId sceneRecordId robotDefId))
47
+ Request.post('openapi/v1/task/singleCallByMobile', params)
48
+ end
49
+
50
+ def self.get_tasks(params={})
51
+ Request.check_required_params(params, %w(companyId))
52
+ Request.get('openapi/v1/task/getTasks', params)
53
+ end
54
+
55
+ def self.get_task_detail(params={})
56
+ Request.check_required_params(params, %w(companyId taskId))
57
+ Request.get('openapi/v1/task/getTaskDetail', params)
58
+ end
59
+
60
+ def self.query_done_task_phones(params={})
61
+ Request.check_required_params(params, %w(callJobId))
62
+ Request.post('openapi/v1/task/queryDoneTaskPhones', params)
63
+ end
64
+
65
+ def self.not_dialed_customer_list(params={})
66
+ Request.check_required_params(params, %w(taskId))
67
+ Request.post('openapi/v1/task/notDialedCustomerList', params)
68
+ end
69
+
70
+ def self.phone_log_info(params={})
71
+ Request.check_required_params(params, %w(callInstanceId))
72
+ Request.get('openapi/v1/task/phoneLogInfo', params)
73
+ end
74
+
75
+ end
76
+ end
@@ -0,0 +1,3 @@
1
+ module ByRobot
2
+ VERSION = "0.0.1"
3
+ end
data/lib/by_robot.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'rest-client'
2
+ require 'digest/sha1'
3
+ require "by_robot/version"
4
+ require 'by_robot/request'
5
+ require 'by_robot/company'
6
+ require 'by_robot/task'
7
+ module ByRobot
8
+ class << self
9
+ attr_accessor :app_key, :app_secret
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: by_robot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - liuliang
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-01-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rest-client
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.8'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.8'
69
+ description: 百应/BYAI的服务端接口.
70
+ email:
71
+ - liuliang0817@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - CODE_OF_CONDUCT.md
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - by_robot.gemspec
86
+ - lib/by_robot.rb
87
+ - lib/by_robot/company.rb
88
+ - lib/by_robot/request.rb
89
+ - lib/by_robot/task.rb
90
+ - lib/by_robot/version.rb
91
+ homepage: https://github.com/liuliang/by_robot
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.7.7
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: 百应/BYAI的服务端接口.
115
+ test_files: []