sellsy-client 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +41 -0
- data/LICENSE.txt +21 -0
- data/README.md +45 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/sellsy.rb +14 -0
- data/lib/sellsy/address.rb +83 -0
- data/lib/sellsy/api.rb +64 -0
- data/lib/sellsy/attachment.rb +19 -0
- data/lib/sellsy/contact.rb +67 -0
- data/lib/sellsy/custom_field.rb +42 -0
- data/lib/sellsy/customer.rb +140 -0
- data/lib/sellsy/document.rb +185 -0
- data/lib/sellsy/invoice.rb +156 -0
- data/lib/sellsy/opportunity.rb +156 -0
- data/lib/sellsy/prospect.rb +138 -0
- data/lib/sellsy/version.rb +3 -0
- data/sellsy-client.gemspec +24 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 78b03e7b612e383e392d3787bec683bffa6dca68a58c3f97db72376db5c839cf
|
4
|
+
data.tar.gz: d64a36eecac409851efd06e4f20ee93ebb164afe78b0cf93c07e4309b4ff7b16
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aeaeddef7c89273e8902ba8fb9440c22270375acb1dfbfa7ba6e68e6e4ea9c8d2f173f3206fd7da2b9bbff179e6cc59c212c67eb0d15ce64260f76eeeb7a77dd
|
7
|
+
data.tar.gz: c3e014c216c40e60395f840e8497256adaeb33eb3889555bc2971306d68426610a5e8979ebd7187bf2fecd53890cee92c1f7a2111acf449d9d0c248fdc3451a8
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -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 jbvilain@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 [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
sellsy-client (0.1.0)
|
5
|
+
multi_json (~> 1.11)
|
6
|
+
rest-client (~> 2.0, >= 2.0.2)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
domain_name (0.5.20190701)
|
12
|
+
unf (>= 0.0.5, < 1.0.0)
|
13
|
+
http-accept (1.7.0)
|
14
|
+
http-cookie (1.0.3)
|
15
|
+
domain_name (~> 0.5)
|
16
|
+
mime-types (3.3.1)
|
17
|
+
mime-types-data (~> 3.2015)
|
18
|
+
mime-types-data (3.2019.1009)
|
19
|
+
minitest (5.14.0)
|
20
|
+
multi_json (1.14.1)
|
21
|
+
netrc (0.11.0)
|
22
|
+
rake (12.3.3)
|
23
|
+
rest-client (2.1.0)
|
24
|
+
http-accept (>= 1.7.0, < 2.0)
|
25
|
+
http-cookie (>= 1.0.2, < 2.0)
|
26
|
+
mime-types (>= 1.16, < 4.0)
|
27
|
+
netrc (~> 0.8)
|
28
|
+
unf (0.1.4)
|
29
|
+
unf_ext
|
30
|
+
unf_ext (0.0.7.6)
|
31
|
+
|
32
|
+
PLATFORMS
|
33
|
+
ruby
|
34
|
+
|
35
|
+
DEPENDENCIES
|
36
|
+
minitest (~> 5.0)
|
37
|
+
rake (~> 12.0)
|
38
|
+
sellsy-client!
|
39
|
+
|
40
|
+
BUNDLED WITH
|
41
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Jean-Baptiste Vilain
|
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,45 @@
|
|
1
|
+
# Sellsy-client gem
|
2
|
+
|
3
|
+
sellsy-client is a Ruby client for the Sellsy API. It is based on the previous versions of the similar gem "sellsy" :
|
4
|
+
- https://github.com/faustus7/sellsy
|
5
|
+
- https://github.com/GCorbel/sellsy
|
6
|
+
- https://github.com/guilb/sellsy
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'sellsy-client'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle install
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install sellsy-client
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
TODO: Write usage instructions here
|
27
|
+
|
28
|
+
## Development
|
29
|
+
|
30
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
31
|
+
|
32
|
+
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).
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/hotentic/sellsy-client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/hotentic/sellsy-client/blob/master/CODE_OF_CONDUCT.md).
|
37
|
+
|
38
|
+
|
39
|
+
## License
|
40
|
+
|
41
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
42
|
+
|
43
|
+
## Code of Conduct
|
44
|
+
|
45
|
+
Everyone interacting in the "sellsy-client" project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/hotentic/sellsy-client/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "sellsy"
|
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(__FILE__)
|
data/bin/setup
ADDED
data/lib/sellsy.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'sellsy/version'
|
2
|
+
require 'sellsy/api'
|
3
|
+
require 'sellsy/customer'
|
4
|
+
require 'sellsy/invoice'
|
5
|
+
require 'sellsy/address'
|
6
|
+
require 'sellsy/contact'
|
7
|
+
require 'sellsy/opportunity'
|
8
|
+
require 'sellsy/prospect'
|
9
|
+
require 'sellsy/document'
|
10
|
+
require 'sellsy/attachment'
|
11
|
+
require 'sellsy/custom_field'
|
12
|
+
|
13
|
+
module Sellsy
|
14
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'multi_json'
|
2
|
+
|
3
|
+
module Sellsy
|
4
|
+
class Address
|
5
|
+
attr_accessor :id
|
6
|
+
attr_accessor :part1, :town, :country_code, :linkedid, :linkedtype, :zip, :name
|
7
|
+
|
8
|
+
def create
|
9
|
+
params = {
|
10
|
+
"name" => name,
|
11
|
+
"linkedtype" => linkedtype,
|
12
|
+
"linkedid" => linkedid,
|
13
|
+
"part1" => part1,
|
14
|
+
"zip" => zip,
|
15
|
+
"town" => town,
|
16
|
+
"countrycode" => country_code,
|
17
|
+
}
|
18
|
+
|
19
|
+
command = {
|
20
|
+
'method' => 'Addresses.create',
|
21
|
+
'params' => params
|
22
|
+
}
|
23
|
+
|
24
|
+
response = MultiJson.load(Sellsy::Api.request command)
|
25
|
+
|
26
|
+
@id = response['response']['address_id'] if response['response']
|
27
|
+
|
28
|
+
response['status'] == 'success'
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.find(id)
|
32
|
+
command = {
|
33
|
+
'method' => 'Addresses.getOne',
|
34
|
+
'params' => {
|
35
|
+
'id' => id
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
response = MultiJson.load(Sellsy::Api.request command)
|
40
|
+
address = Address.new
|
41
|
+
|
42
|
+
if response['response']
|
43
|
+
value = response['response']
|
44
|
+
address.id = key
|
45
|
+
address.part1 = value['part1']
|
46
|
+
address.town = value['town']
|
47
|
+
address.country_code = value['countrycode']
|
48
|
+
address.linkedid = value['linkedid']
|
49
|
+
address.linkedtype = value['linkedtype']
|
50
|
+
address.zip = value['zip']
|
51
|
+
end
|
52
|
+
|
53
|
+
address
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.all
|
57
|
+
command = {
|
58
|
+
'method' => 'Addresses.getList',
|
59
|
+
'params' => {}
|
60
|
+
}
|
61
|
+
|
62
|
+
response = MultiJson.load(Sellsy::Api.request command)
|
63
|
+
|
64
|
+
addresses = []
|
65
|
+
|
66
|
+
if response['response']
|
67
|
+
response['response']['result'].each do |key, value|
|
68
|
+
address = Address.new
|
69
|
+
address.id = key
|
70
|
+
address.part1 = value['part1']
|
71
|
+
address.town = value['town']
|
72
|
+
address.country_code = value['countrycode']
|
73
|
+
address.linkedid = value['linkedid']
|
74
|
+
address.linkedtype = value['linkedtype']
|
75
|
+
address.zip = value['zip']
|
76
|
+
addresses << address
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
addresses
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/sellsy/api.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'multi_json'
|
2
|
+
require 'rest_client'
|
3
|
+
|
4
|
+
module Sellsy
|
5
|
+
class Api
|
6
|
+
class << self
|
7
|
+
attr_accessor :configuration
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.configure
|
11
|
+
self.configuration ||= Configuration.new
|
12
|
+
yield(configuration)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.authentication_header
|
16
|
+
encoded_key = URI::escape(self.configuration.consumer_secret) + "&" + URI::escape(self.configuration.user_secret)
|
17
|
+
now = Time.now
|
18
|
+
oauth_params = {
|
19
|
+
'oauth_consumer_key' => self.configuration.consumer_token,
|
20
|
+
'oauth_token' => self.configuration.user_token,
|
21
|
+
'oauth_nonce' => Digest::MD5.hexdigest((now.to_i + rand(0..1000)).to_s),
|
22
|
+
'oauth_timestamp' => now.to_i.to_s,
|
23
|
+
'oauth_signature_method' => 'PLAINTEXT',
|
24
|
+
'oauth_version' => '1.0',
|
25
|
+
'oauth_signature' => encoded_key
|
26
|
+
}
|
27
|
+
|
28
|
+
'OAuth ' + oauth_params.map { |k, v| k + '="' + v + '"' }.join(', ')
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.info
|
32
|
+
command = {
|
33
|
+
:method => 'Infos.getInfos',
|
34
|
+
:params => {}
|
35
|
+
}
|
36
|
+
|
37
|
+
MultiJson.load(self.request command)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.request(payload, file = nil)
|
41
|
+
file_params = file ? {'do_file' => file} : {}
|
42
|
+
|
43
|
+
puts "params : #{payload}"
|
44
|
+
|
45
|
+
RestClient.log = 'stdout'
|
46
|
+
RestClient.post('https://apifeed.sellsy.com/0/',
|
47
|
+
{:request => 1, :io_mode => 'json', 'do_in' => payload.to_json, :multipart => true}.merge(file_params),
|
48
|
+
{:authorization => self.authentication_header}) do |resp|
|
49
|
+
puts "resp : #{resp.body}"
|
50
|
+
resp
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class Configuration
|
55
|
+
attr_accessor :consumer_secret
|
56
|
+
attr_accessor :consumer_token
|
57
|
+
attr_accessor :user_secret
|
58
|
+
attr_accessor :user_token
|
59
|
+
|
60
|
+
def initialize
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Sellsy
|
2
|
+
class Attachment
|
3
|
+
attr_accessor :id, :entity_id, :entity_type, :file
|
4
|
+
|
5
|
+
def create
|
6
|
+
command = {
|
7
|
+
'method' => 'Briefcases.uploadFile',
|
8
|
+
'params' => {
|
9
|
+
'linkedtype' => @entity_type,
|
10
|
+
'linkedid' => @entity_id
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
response = MultiJson.load(Sellsy::Api.request(command, file))
|
15
|
+
@id = response['response']
|
16
|
+
response['status'] == 'success'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|