megaplan 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +42 -0
- data/README.md +56 -0
- data/Rakefile +6 -0
- data/lib/megaplan.rb +31 -0
- data/lib/megaplan/api.rb +183 -0
- data/lib/megaplan/checklist.rb +26 -0
- data/lib/megaplan/comment.rb +27 -0
- data/lib/megaplan/contractor.rb +24 -0
- data/lib/megaplan/deal.rb +28 -0
- data/lib/megaplan/employee.rb +34 -0
- data/lib/megaplan/event.rb +31 -0
- data/lib/megaplan/favorite.rb +22 -0
- data/lib/megaplan/filter.rb +14 -0
- data/lib/megaplan/history.rb +18 -0
- data/lib/megaplan/informer.rb +30 -0
- data/lib/megaplan/invoice.rb +14 -0
- data/lib/megaplan/message.rb +14 -0
- data/lib/megaplan/offer.rb +14 -0
- data/lib/megaplan/payer.rb +22 -0
- data/lib/megaplan/project.rb +41 -0
- data/lib/megaplan/search.rb +21 -0
- data/lib/megaplan/severity.rb +13 -0
- data/lib/megaplan/system.rb +23 -0
- data/lib/megaplan/tag.rb +22 -0
- data/lib/megaplan/task.rb +62 -0
- data/lib/megaplan/todo_list.rb +14 -0
- data/lib/megaplan/topic.rb +22 -0
- data/lib/megaplan/unit.rb +14 -0
- data/lib/megaplan/user.rb +22 -0
- data/lib/megaplan/version.rb +3 -0
- data/megaplan.gemspec +59 -0
- data/spec/megaplan_spec.rb +11 -0
- data/spec/spec_helper.rb +2 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4313ae0cfaa865e13faf009d3bf638b172628529
|
4
|
+
data.tar.gz: a3a3c9e1149069b0e7d82bff3f30bcb154c99902
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b017e7e040a39d2f9b1dab4e9cc2fd4cb5f289d29556709ea125d688280da95fe2efdf1750e54bda4fed2e2103c10a1540b073958d2f5d2d3dede14f495df54e
|
7
|
+
data.tar.gz: 6433235fe49f2dde1f357f2adca614c11bf4ceefcf77b12909cedee91d83db300cc354e0a02a8a159670573cc47f9042a7f5c93e40884c426b76bb006898d8ab
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
megaplan (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.2.5)
|
10
|
+
httparty (0.13.7)
|
11
|
+
json (~> 1.8)
|
12
|
+
multi_xml (>= 0.5.2)
|
13
|
+
json (1.8.3)
|
14
|
+
multi_xml (0.5.5)
|
15
|
+
rake (10.5.0)
|
16
|
+
rspec (3.4.0)
|
17
|
+
rspec-core (~> 3.4.0)
|
18
|
+
rspec-expectations (~> 3.4.0)
|
19
|
+
rspec-mocks (~> 3.4.0)
|
20
|
+
rspec-core (3.4.3)
|
21
|
+
rspec-support (~> 3.4.0)
|
22
|
+
rspec-expectations (3.4.0)
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
+
rspec-support (~> 3.4.0)
|
25
|
+
rspec-mocks (3.4.1)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.4.0)
|
28
|
+
rspec-support (3.4.1)
|
29
|
+
|
30
|
+
PLATFORMS
|
31
|
+
ruby
|
32
|
+
|
33
|
+
DEPENDENCIES
|
34
|
+
bundler (~> 1.11)
|
35
|
+
httparty
|
36
|
+
json (>= 1.7.7)
|
37
|
+
megaplan!
|
38
|
+
rake (~> 10.0)
|
39
|
+
rspec (~> 3.0)
|
40
|
+
|
41
|
+
BUNDLED WITH
|
42
|
+
1.11.2
|
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# Megaplan
|
2
|
+
|
3
|
+
Megaplan API on Rails
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'megaplan'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install megaplan
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Megaplan gem models has similar to Megaplan API names, attributes, methods. All API routes is available. If you want to find deal with Id=1, you should pass such a query {"Id" => 1}. This gem is just a shell without any relations between models.
|
24
|
+
|
25
|
+
require 'megaplan'
|
26
|
+
client = Megaplan::Api.new(endpoint: YOUR_ENDPOINT, login: YOUR_EMAIL, password: YOUR_PASSWORD)
|
27
|
+
query = { "Id" => 1 }
|
28
|
+
|
29
|
+
Megaplan::Contractor.list(client, query)
|
30
|
+
Megaplan::Deal.list(client, query)
|
31
|
+
|
32
|
+
Megaplan::Contractor.save(client, query)
|
33
|
+
Megaplan::Deal.save(client, query)
|
34
|
+
|
35
|
+
Megaplan::Contractor.delete(client, query)
|
36
|
+
Megaplan::Deal.delete(client, query)
|
37
|
+
|
38
|
+
Megaplan::Deal.find(client, query)
|
39
|
+
|
40
|
+
You can check some of the calls at https://help.megaplan.ru/API
|
41
|
+
|
42
|
+
## Development
|
43
|
+
|
44
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
45
|
+
|
46
|
+
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).
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/nononoy/megaplan. 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.
|
51
|
+
|
52
|
+
|
53
|
+
## License
|
54
|
+
|
55
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
56
|
+
|
data/Rakefile
ADDED
data/lib/megaplan.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "megaplan/api"
|
2
|
+
require "megaplan/checklist"
|
3
|
+
require "megaplan/comment"
|
4
|
+
require "megaplan/contractor"
|
5
|
+
require "megaplan/deal"
|
6
|
+
require "megaplan/employee"
|
7
|
+
require "megaplan/event"
|
8
|
+
require "megaplan/favorite"
|
9
|
+
require "megaplan/filter"
|
10
|
+
require "megaplan/history"
|
11
|
+
require "megaplan/informer"
|
12
|
+
require "megaplan/invoice"
|
13
|
+
require "megaplan/message"
|
14
|
+
require "megaplan/offer"
|
15
|
+
require "megaplan/offer"
|
16
|
+
require "megaplan/payer"
|
17
|
+
require "megaplan/project"
|
18
|
+
require "megaplan/search"
|
19
|
+
require "megaplan/severity"
|
20
|
+
require "megaplan/system"
|
21
|
+
require "megaplan/tag"
|
22
|
+
require "megaplan/task"
|
23
|
+
require "megaplan/todo_list"
|
24
|
+
require "megaplan/topic"
|
25
|
+
require "megaplan/unit"
|
26
|
+
require "megaplan/user"
|
27
|
+
require "megaplan/version"
|
28
|
+
|
29
|
+
module Megaplan
|
30
|
+
|
31
|
+
end
|
data/lib/megaplan/api.rb
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
module Megaplan
|
2
|
+
require 'forwardable'
|
3
|
+
|
4
|
+
class Api
|
5
|
+
|
6
|
+
extend Forwardable
|
7
|
+
def_delegators 'self.class', :resource_path, :bad_response, :parsed_body
|
8
|
+
|
9
|
+
attr_reader :endpoint, :login, :password
|
10
|
+
|
11
|
+
def initialize(attrs = {})
|
12
|
+
@endpoint = attrs[:endpoint]
|
13
|
+
@login = attrs[:login]
|
14
|
+
@password = attrs[:password]
|
15
|
+
end
|
16
|
+
|
17
|
+
def authenticate
|
18
|
+
response = HTTParty.get(auth_path, :query => auth_params)
|
19
|
+
if response.success?
|
20
|
+
parsed_body(response)
|
21
|
+
else
|
22
|
+
bad_response(response, parsed_body(response), auth_params)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def auth_params
|
27
|
+
require 'digest/md5'
|
28
|
+
{ Login: login, Password: Digest::MD5.hexdigest(password) }
|
29
|
+
end
|
30
|
+
|
31
|
+
def auth_path
|
32
|
+
"https://" + initial_path + "/BumsCommonApiV01/User/authorize.api"
|
33
|
+
end
|
34
|
+
|
35
|
+
def initial_path
|
36
|
+
"#{endpoint}.megaplan.ru"
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_headers(type, path)
|
40
|
+
attrs = authenticate
|
41
|
+
secret_key = attrs['SecretKey']
|
42
|
+
date = Time.now.rfc2822
|
43
|
+
{ "Date"=> date,
|
44
|
+
"Accept"=> "application/json",
|
45
|
+
"Content-Type" => "application/json",
|
46
|
+
"X-Authorization" => "#{attrs['AccessId']}:#{create_signature(type, secret_key, date, path)}"
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
def create_signature(type, key, date, path)
|
51
|
+
require 'cgi'
|
52
|
+
require 'openssl'
|
53
|
+
|
54
|
+
data = "#{type == :get ? "GET" : "POST"}\n\napplication/json\n#{date}\n#{path}"
|
55
|
+
Base64.strict_encode64(OpenSSL::HMAC.hexdigest('sha1', key, data))
|
56
|
+
end
|
57
|
+
|
58
|
+
class << self
|
59
|
+
|
60
|
+
def parsed_body(res)
|
61
|
+
body = JSON.parse(res.body) rescue {}
|
62
|
+
if body["status"]["code"] != "error"
|
63
|
+
body["data"]
|
64
|
+
else
|
65
|
+
body
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def to_query(params)
|
70
|
+
params.to_a.map { |x| "#{CGI.escape(x[0])}=#{CGI.escape(x[1])}" }.join("&")
|
71
|
+
end
|
72
|
+
|
73
|
+
def query_path(path, query)
|
74
|
+
path + (query.any? ? "?#{to_query(query)}" : "")
|
75
|
+
end
|
76
|
+
|
77
|
+
def check_response(response)
|
78
|
+
if response.success?
|
79
|
+
parsed_body(response)
|
80
|
+
else
|
81
|
+
bad_response(response, parsed_body(response))
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def find(client, query)
|
86
|
+
output = []
|
87
|
+
@arr.each do |item|
|
88
|
+
success = if query.keys.all? { |x| item.keys.include? x }
|
89
|
+
if query.all? { |k,v| !v.respond_to?(:keys)}
|
90
|
+
query.keys.all? { |i| query[i] == item[i]} ? true : false
|
91
|
+
else
|
92
|
+
result = []
|
93
|
+
query.keys.each do |each|
|
94
|
+
result << if query[each].respond_to?(:keys)
|
95
|
+
if query[each].keys.all? { |x| item[each].keys.include? x }
|
96
|
+
query[each].keys.all?{ |i| query[each][i] == item[each][i] } ? true : false
|
97
|
+
end
|
98
|
+
else
|
99
|
+
true if query[each] == item[each]
|
100
|
+
end
|
101
|
+
end
|
102
|
+
result.uniq == [true] ? true : false
|
103
|
+
end
|
104
|
+
else
|
105
|
+
false
|
106
|
+
end
|
107
|
+
output << item if success
|
108
|
+
end
|
109
|
+
output
|
110
|
+
end
|
111
|
+
|
112
|
+
def list(client, query = {})
|
113
|
+
make_get_req('list.api', client, query, nil)
|
114
|
+
end
|
115
|
+
|
116
|
+
def card(client, query = {})
|
117
|
+
make_get_req('card.api', client, query, nil)
|
118
|
+
end
|
119
|
+
|
120
|
+
def create(client, query = {})
|
121
|
+
make_post_req('create.api', client, query, nil)
|
122
|
+
end
|
123
|
+
|
124
|
+
def save(client, query = {})
|
125
|
+
make_post_req('save.api', client, query, nil)
|
126
|
+
end
|
127
|
+
|
128
|
+
def edit(client, query = {})
|
129
|
+
make_post_req('edit.api', client, query, nil)
|
130
|
+
end
|
131
|
+
|
132
|
+
def delete(client, query = {})
|
133
|
+
make_post_req('delete.api', client, query, nil)
|
134
|
+
end
|
135
|
+
|
136
|
+
def custom_get(client, custom_path, query = {})
|
137
|
+
make_get_req(nil, client, query, custom_path)
|
138
|
+
end
|
139
|
+
|
140
|
+
def custom_post(client, custom_path, query = {})
|
141
|
+
make_post_req(nil, client, query, custom_path)
|
142
|
+
end
|
143
|
+
|
144
|
+
def make_post_req(action, client, query, custom_path)
|
145
|
+
path = resource_path(:post, client, action, custom_path, query)
|
146
|
+
headers = client.get_headers(:post, path.gsub('https://', ''))
|
147
|
+
response = HTTParty.post(path, body: query.to_json, headers: headers)
|
148
|
+
check_response(response)
|
149
|
+
end
|
150
|
+
|
151
|
+
def make_get_req(action, client, query, custom_path)
|
152
|
+
path = resource_path(:get, client, action, custom_path, query)
|
153
|
+
headers = client.get_headers(:get, path.gsub('https://', ''))
|
154
|
+
response = HTTParty.get(path, headers: headers)
|
155
|
+
check_response(response)
|
156
|
+
end
|
157
|
+
|
158
|
+
def resource_path(type, client, action_path, custom_path, query = {})
|
159
|
+
if custom_path
|
160
|
+
url = "https://#{client.initial_path}" << custom_path
|
161
|
+
else
|
162
|
+
class_name = name.split('::').inject(Object) do |mod, class_name|
|
163
|
+
mod.const_get(class_name)
|
164
|
+
end
|
165
|
+
class_endpoint = class_name.class_endpoint rescue "/"
|
166
|
+
url = "https://#{client.initial_path}" << class_endpoint << action_path
|
167
|
+
end
|
168
|
+
query_path(url, query)
|
169
|
+
end
|
170
|
+
|
171
|
+
def bad_response(response, parsed_body)
|
172
|
+
puts parsed_body
|
173
|
+
|
174
|
+
if response.class == HTTParty::Response
|
175
|
+
raise HTTParty::ResponseError, response
|
176
|
+
end
|
177
|
+
raise StandardError, (parsed_body['status']['message'] rescue 'unknown error')
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Megaplan
|
2
|
+
|
3
|
+
class Checklist < Api
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def class_endpoint
|
8
|
+
"/BumsCommonApiV01/Checklist/"
|
9
|
+
end
|
10
|
+
|
11
|
+
def update(client, query = {})
|
12
|
+
custom_post(client, class_endpoint + "update.api", query)
|
13
|
+
end
|
14
|
+
|
15
|
+
def all(client, query = {})
|
16
|
+
custom_get(client, class_endpoint + "all.api", query)["items"] rescue []
|
17
|
+
end
|
18
|
+
|
19
|
+
def toggle(client, query = {})
|
20
|
+
custom_get(client, class_endpoint + "toggle.api", query)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Megaplan
|
2
|
+
|
3
|
+
class Comment < Api
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def class_endpoint
|
8
|
+
"/BumsCommonApiV01/Comment/"
|
9
|
+
end
|
10
|
+
|
11
|
+
def mark_as_read(client, query = {})
|
12
|
+
custom_post(client, class_endpoint + "markAsRead.api", query)
|
13
|
+
end
|
14
|
+
|
15
|
+
def all(client, query = {})
|
16
|
+
custom_get(client, class_endpoint + "all.api", query)["comments"] rescue []
|
17
|
+
end
|
18
|
+
|
19
|
+
def comment_by_id(client, query = {})
|
20
|
+
custom_get(client, class_endpoint + "commentById.api", query)["comment"] rescue nil
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Megaplan
|
2
|
+
|
3
|
+
class Contractor < Api
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def class_endpoint
|
8
|
+
"/BumsCrmApiV01/Contractor/"
|
9
|
+
end
|
10
|
+
|
11
|
+
def find(client, query)
|
12
|
+
scope = list(client)
|
13
|
+
@arr = scope['clients']
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def list_fields(client, query = {})
|
18
|
+
custom_get(client, class_endpoint + "listFields.api", query)['Fields'] rescue []
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Megaplan
|
2
|
+
|
3
|
+
class Deal < Api
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def class_endpoint
|
8
|
+
"/BumsTradeApiV01/Deal/"
|
9
|
+
end
|
10
|
+
|
11
|
+
def find(client, query)
|
12
|
+
scope = list(client)
|
13
|
+
@arr = scope['deals']
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def programs(client, query = {})
|
18
|
+
custom_get(client, "/BumsTradeApiV01/Program/list.api", query)['programs'] rescue []
|
19
|
+
end
|
20
|
+
|
21
|
+
def list_fields(client, query = {})
|
22
|
+
custom_get(client, class_endpoint + "listFields.api", query)['Fields'] rescue []
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Megaplan
|
2
|
+
|
3
|
+
class Employee < Api
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def class_endpoint
|
8
|
+
"/BumsStaffApiV01/Employee/"
|
9
|
+
end
|
10
|
+
|
11
|
+
def available_actions(client, query = {})
|
12
|
+
custom_get(client, class_endpoint + "availableActions.api", query)
|
13
|
+
end
|
14
|
+
|
15
|
+
def departments(client)
|
16
|
+
custom_get(client, "/BumsStaffApiV01/Department/list.api")["departments"] rescue []
|
17
|
+
end
|
18
|
+
|
19
|
+
def phone_types(client, query = {})
|
20
|
+
custom_get(client, class_endpoint + "phoneTypes.api", query)["PhoneTypes"] rescue []
|
21
|
+
end
|
22
|
+
|
23
|
+
def can_create(client)
|
24
|
+
custom_get(client, class_endpoint + "canCreate.api")["CanCreate"] rescue nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def employees_online(client)
|
28
|
+
custom_get(client, class_endpoint + "employeesOnline.api")["Ids"] rescue []
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Megaplan
|
2
|
+
|
3
|
+
class Event < Api
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def class_endpoint
|
8
|
+
"/BumsTimeApiV01/Event/"
|
9
|
+
end
|
10
|
+
|
11
|
+
def categories(client, query = {})
|
12
|
+
custom_get(client, class_endpoint + "categories.api", query)['categories'] rescue []
|
13
|
+
end
|
14
|
+
|
15
|
+
def update(client, query = {})
|
16
|
+
custom_post(client, class_endpoint + "update.api", query)
|
17
|
+
end
|
18
|
+
|
19
|
+
def finish(client, query = {})
|
20
|
+
custom_post(client, class_endpoint + "finish.api", query)
|
21
|
+
end
|
22
|
+
|
23
|
+
def places(client)
|
24
|
+
custom_get(client, class_endpoint + "places.api")["places"] rescue []
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Megaplan
|
2
|
+
|
3
|
+
class Favorite < Api
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def class_endpoint
|
8
|
+
"/BumsCommonApiV01/Favorite/"
|
9
|
+
end
|
10
|
+
|
11
|
+
def add(client, query = {})
|
12
|
+
custom_post(client, class_endpoint + "add.api", query)
|
13
|
+
end
|
14
|
+
|
15
|
+
def remove(client, query = {})
|
16
|
+
custom_post(client, class_endpoint + "remove.api", query)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Megaplan
|
2
|
+
|
3
|
+
class History < Api
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def class_endpoint
|
8
|
+
"/BumsCommonApiV01/History/"
|
9
|
+
end
|
10
|
+
|
11
|
+
def all(client, query = {})
|
12
|
+
custom_get(client, class_endpoint + "all.api", query)['changes'] rescue []
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Megaplan
|
2
|
+
|
3
|
+
class Informer < Api
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def class_endpoint
|
8
|
+
"/BumsCommonApiV01/Informer/"
|
9
|
+
end
|
10
|
+
|
11
|
+
def notifications(client, query = {})
|
12
|
+
custom_get(client, class_endpoint + "notifications.api", query)["notifications"] rescue []
|
13
|
+
end
|
14
|
+
|
15
|
+
def deactivate_notification(client, query = {})
|
16
|
+
custom_post(client, class_endpoint + "deactivateNotification.api", query)
|
17
|
+
end
|
18
|
+
|
19
|
+
def approvals(client, query = {})
|
20
|
+
custom_get(client, class_endpoint + "approvals.api", query)
|
21
|
+
end
|
22
|
+
|
23
|
+
def approvals_count(client)
|
24
|
+
custom_get(client, class_endpoint + "approvalsCount.api")["Count"] rescue nil
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Megaplan
|
2
|
+
|
3
|
+
class Payer < Api
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def class_endpoint
|
8
|
+
"/BumsCrmApiV01/Payer/"
|
9
|
+
end
|
10
|
+
|
11
|
+
def change_contractor(client, query = {})
|
12
|
+
custom_post(client, class_endpoint + "changeContractor.api", query)
|
13
|
+
end
|
14
|
+
|
15
|
+
def list_fields(client, query = {})
|
16
|
+
custom_get(client, class_endpoint + "listFields.api", query)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Megaplan
|
2
|
+
|
3
|
+
class Project < Api
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def class_endpoint
|
8
|
+
"/BumsProjectApiV01/Project/"
|
9
|
+
end
|
10
|
+
|
11
|
+
def action(client, query = {})
|
12
|
+
custom_get(client, class_endpoint + "action.api", query)
|
13
|
+
end
|
14
|
+
|
15
|
+
def available_actions(client, query = {})
|
16
|
+
custom_get(client, class_endpoint + "availableActions.api", query)
|
17
|
+
end
|
18
|
+
|
19
|
+
def available_actions_for_list(client, query = {})
|
20
|
+
custom_get(client, class_endpoint + "availableActionsForList.api", query)
|
21
|
+
end
|
22
|
+
|
23
|
+
def can_create(client)
|
24
|
+
custom_get(client, class_endpoint + "canCreate.api")
|
25
|
+
end
|
26
|
+
|
27
|
+
def convert(client, query = {})
|
28
|
+
custom_post(client, class_endpoint + "convert.api", query)
|
29
|
+
end
|
30
|
+
|
31
|
+
def save_auditors(client, query = {})
|
32
|
+
custom_post(client, class_endpoint + "saveAuditors.api", query)
|
33
|
+
end
|
34
|
+
|
35
|
+
def save_executors(client, query = {})
|
36
|
+
custom_post(client, class_endpoint + "saveExecutors.api", query)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Megaplan
|
2
|
+
|
3
|
+
class Search < Api
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def class_endpoint
|
8
|
+
"/BumsCommonApiV01/Search/"
|
9
|
+
end
|
10
|
+
|
11
|
+
def new(client, query = {})
|
12
|
+
path = resource_path(:get, client, 'quick.api', nil, query)
|
13
|
+
headers = client.get_headers(:get, path.gsub('https://', ''))
|
14
|
+
response = HTTParty.get(path, :headers => headers)
|
15
|
+
check_response(response)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Megaplan
|
2
|
+
|
3
|
+
class System < Api
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def datetime(client)
|
7
|
+
custom_get(client, "/BumsCommonApiV01/System/datetime.api")["datetime"] rescue nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def feedback(client, query)
|
11
|
+
custom_post(client, "/BumsCommonApiV01/System/feedback.api", query)
|
12
|
+
end
|
13
|
+
|
14
|
+
def currencies(client, query = {})
|
15
|
+
custom_get(client, "/BumsCommonApiV01/Currency/list.api", query)["currencies"] rescue []
|
16
|
+
end
|
17
|
+
|
18
|
+
def taxes(client, query = {})
|
19
|
+
custom_get(client, "/BumsCommonApiV01/Tax/list.api", query)["taxes"] rescue []
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/megaplan/tag.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Megaplan
|
2
|
+
|
3
|
+
class Tag < Api
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def class_endpoint
|
8
|
+
"/BumsCommonApiV01/Tags/"
|
9
|
+
end
|
10
|
+
|
11
|
+
def assign(client, query = {})
|
12
|
+
custom_post(client, class_endpoint + "assign.api", query)
|
13
|
+
end
|
14
|
+
|
15
|
+
def search(client, query = {})
|
16
|
+
custom_post(client, class_endpoint + "search.api", query)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Megaplan
|
2
|
+
|
3
|
+
class Task < Api
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def class_endpoint
|
8
|
+
"/BumsTaskApiV01/Task/"
|
9
|
+
end
|
10
|
+
|
11
|
+
def action(client, query = {})
|
12
|
+
custom_get(client, class_endpoint + "action.api", query)
|
13
|
+
end
|
14
|
+
|
15
|
+
def available_actions(client, query = {})
|
16
|
+
custom_get(client, class_endpoint + "availableActions.api", query)["actions"] rescue []
|
17
|
+
end
|
18
|
+
|
19
|
+
def deadline_change(client, query = {})
|
20
|
+
custom_post(client, class_endpoint + "deadlineChange.api", query)
|
21
|
+
end
|
22
|
+
|
23
|
+
def deadline_action(client, query = {})
|
24
|
+
custom_post(client, class_endpoint + "deadlineAction.api", query)
|
25
|
+
end
|
26
|
+
|
27
|
+
def save_executors(client, query = {})
|
28
|
+
custom_post(client, class_endpoint + "saveExecutors.api", query)
|
29
|
+
end
|
30
|
+
|
31
|
+
def save_auditors(client, query = {})
|
32
|
+
custom_post(client, class_endpoint + "saveAuditors.api", query)
|
33
|
+
end
|
34
|
+
|
35
|
+
def delegate(client, query = {})
|
36
|
+
custom_post(client, class_endpoint + "delegate.api", query)
|
37
|
+
end
|
38
|
+
|
39
|
+
def check_delegate(client, query = {})
|
40
|
+
custom_post(client, class_endpoint + "checkDelegate.api", query)
|
41
|
+
end
|
42
|
+
|
43
|
+
def employees_to_delegate(client, query = {})
|
44
|
+
custom_post(client, class_endpoint + "employeesToDelegate.api", query)
|
45
|
+
end
|
46
|
+
|
47
|
+
def super_tasks(client, query = {})
|
48
|
+
custom_post(client, class_endpoint + "superTasks.api", query)
|
49
|
+
end
|
50
|
+
|
51
|
+
def super_projects(client, query = {})
|
52
|
+
custom_post(client, class_endpoint + "superProjects.api", query)["projects"] rescue []
|
53
|
+
end
|
54
|
+
|
55
|
+
def convert(client, query = {})
|
56
|
+
custom_post(client, class_endpoint + "convert.api", query)
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Megaplan
|
2
|
+
|
3
|
+
class Topic < Api
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def class_endpoint
|
8
|
+
"/BumsDiscussApiV01/Topic/"
|
9
|
+
end
|
10
|
+
|
11
|
+
def toggle_topic(client, query = {})
|
12
|
+
custom_post(client, class_endpoint + "toggleTopic.api", query)
|
13
|
+
end
|
14
|
+
|
15
|
+
def section_list(client, query = {})
|
16
|
+
custom_get(client, class_endpoint + "sectionList.api", query)["sections"] rescue []
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Megaplan
|
2
|
+
|
3
|
+
class User < Api
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def info(client)
|
8
|
+
custom_get(client, "/BumsCommonApiV01/UserInfo/id.api")
|
9
|
+
end
|
10
|
+
|
11
|
+
def block(client, query = {})
|
12
|
+
custom_post(client, "/BumsCommonApiV01/UserAccount/block.api", query)
|
13
|
+
end
|
14
|
+
|
15
|
+
def unblock(client, query = {})
|
16
|
+
custom_post(client, "/BumsCommonApiV01/UserAccount/unblock.api", query)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
data/megaplan.gemspec
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'megaplan/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "megaplan"
|
8
|
+
spec.version = Megaplan::VERSION
|
9
|
+
spec.authors = ["Viacheslav Gruzdov"]
|
10
|
+
spec.email = ["lucky-@mail.ru"]
|
11
|
+
|
12
|
+
spec.summary = "Simple Ruby shell for Megaplan.ru API"
|
13
|
+
spec.description = "Megaplan on Rails"
|
14
|
+
spec.homepage = "https://github.com/nononoy/megaplan-rb"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = [
|
18
|
+
"Gemfile",
|
19
|
+
"Gemfile.lock",
|
20
|
+
"README.md",
|
21
|
+
"Rakefile",
|
22
|
+
"lib/megaplan.rb",
|
23
|
+
"lib/megaplan/api.rb",
|
24
|
+
"lib/megaplan/checklist.rb",
|
25
|
+
"lib/megaplan/comment.rb",
|
26
|
+
"lib/megaplan/contractor.rb",
|
27
|
+
"lib/megaplan/deal.rb",
|
28
|
+
"lib/megaplan/employee.rb",
|
29
|
+
"lib/megaplan/event.rb",
|
30
|
+
"lib/megaplan/favorite.rb",
|
31
|
+
"lib/megaplan/filter.rb",
|
32
|
+
"lib/megaplan/history.rb",
|
33
|
+
"lib/megaplan/informer.rb",
|
34
|
+
"lib/megaplan/invoice.rb",
|
35
|
+
"lib/megaplan/message.rb",
|
36
|
+
"lib/megaplan/offer.rb",
|
37
|
+
"lib/megaplan/payer.rb",
|
38
|
+
"lib/megaplan/project.rb",
|
39
|
+
"lib/megaplan/search.rb",
|
40
|
+
"lib/megaplan/severity.rb",
|
41
|
+
"lib/megaplan/system.rb",
|
42
|
+
"lib/megaplan/tag.rb",
|
43
|
+
"lib/megaplan/task.rb",
|
44
|
+
"lib/megaplan/todo_list.rb",
|
45
|
+
"lib/megaplan/topic.rb",
|
46
|
+
"lib/megaplan/unit.rb",
|
47
|
+
"lib/megaplan/user.rb",
|
48
|
+
"lib/megaplan/version.rb",
|
49
|
+
"megaplan.gemspec",
|
50
|
+
"spec/megaplan_spec.rb",
|
51
|
+
"spec/spec_helper.rb"]
|
52
|
+
spec.bindir = "exe"
|
53
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
54
|
+
spec.require_paths = ["lib"]
|
55
|
+
|
56
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
57
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
58
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
59
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: megaplan
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Viacheslav Gruzdov
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-19 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.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
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.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Megaplan on Rails
|
56
|
+
email:
|
57
|
+
- lucky-@mail.ru
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- Gemfile
|
63
|
+
- Gemfile.lock
|
64
|
+
- README.md
|
65
|
+
- Rakefile
|
66
|
+
- lib/megaplan.rb
|
67
|
+
- lib/megaplan/api.rb
|
68
|
+
- lib/megaplan/checklist.rb
|
69
|
+
- lib/megaplan/comment.rb
|
70
|
+
- lib/megaplan/contractor.rb
|
71
|
+
- lib/megaplan/deal.rb
|
72
|
+
- lib/megaplan/employee.rb
|
73
|
+
- lib/megaplan/event.rb
|
74
|
+
- lib/megaplan/favorite.rb
|
75
|
+
- lib/megaplan/filter.rb
|
76
|
+
- lib/megaplan/history.rb
|
77
|
+
- lib/megaplan/informer.rb
|
78
|
+
- lib/megaplan/invoice.rb
|
79
|
+
- lib/megaplan/message.rb
|
80
|
+
- lib/megaplan/offer.rb
|
81
|
+
- lib/megaplan/payer.rb
|
82
|
+
- lib/megaplan/project.rb
|
83
|
+
- lib/megaplan/search.rb
|
84
|
+
- lib/megaplan/severity.rb
|
85
|
+
- lib/megaplan/system.rb
|
86
|
+
- lib/megaplan/tag.rb
|
87
|
+
- lib/megaplan/task.rb
|
88
|
+
- lib/megaplan/todo_list.rb
|
89
|
+
- lib/megaplan/topic.rb
|
90
|
+
- lib/megaplan/unit.rb
|
91
|
+
- lib/megaplan/user.rb
|
92
|
+
- lib/megaplan/version.rb
|
93
|
+
- megaplan.gemspec
|
94
|
+
- spec/megaplan_spec.rb
|
95
|
+
- spec/spec_helper.rb
|
96
|
+
homepage: https://github.com/nononoy/megaplan-rb
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.5.1
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Simple Ruby shell for Megaplan.ru API
|
120
|
+
test_files: []
|