bsale_api 0.1.0

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
+ SHA1:
3
+ metadata.gz: 06fe73e2d341e9125d5139c5355e4f83a0e79d3f
4
+ data.tar.gz: 90ef8a51c059e5bd415cb62a9e1fe8fd4921477a
5
+ SHA512:
6
+ metadata.gz: 2cbf8a1366ba4b360ba1c12bd92c63eb3e9973466cd79b254ebef0aa45c20533d6bff570b026820edceb02d90580d0f54051abca456cbdbb2ac8601127dd35a8
7
+ data.tar.gz: 30ac22d783e6be89ccb92d7c8d9158706baf5e96656ae3b392e80ed679a20479d072d31612771d5028bff818394637c3fc729075d27236cd7c5f2542303b4d54
data/.env ADDED
@@ -0,0 +1 @@
1
+ BSALE_TOKEN=95f992cfa3cd049cc2c1fc29f496e488a67153b0
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.3
5
+ before_install: gem install bundler -v 1.12.0
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at developer.jimenez@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bsale_api.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Nelson Pato Jimenez
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,41 @@
1
+ # BsaleApi
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/bsale_api`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'bsale_api'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install bsale_api
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/bsale_api. 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.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bsale_api"
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/bsale_api.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bsale_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bsale_api"
8
+ spec.version = BsaleApi::VERSION
9
+ spec.authors = ["Nelson Pato Jimenez","Michel Szinavel"]
10
+ spec.email = ["developer.jimenez@gmail.com","michel.szinavel@gmail.com"]
11
+
12
+ spec.summary = %q{ BSale Api }
13
+ spec.description = %q{ Wrapper for BSALE API}
14
+ spec.homepage = "https://github.com/shipit-team/bsale_api"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_dependency "dotenv"
26
+ spec.add_dependency "httparty", "~> 0.14.0"
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.12"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rspec", "~> 3.0"
31
+ spec.add_development_dependency "pry-byebug", "~> 3.4.2"
32
+ end
@@ -0,0 +1,16 @@
1
+ class Document
2
+ def initialize
3
+ @object = {
4
+ documentTypeId: 22,
5
+ officeId: 1,
6
+ priceListId: 18,
7
+ emissionDate: 1407715200,
8
+ expirationDate: 1407715200,
9
+ declareSii: 1
10
+ }
11
+ end
12
+
13
+ def object
14
+ @object
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ class Office
2
+ def initialize
3
+ @object = {
4
+ longitude: "",
5
+ zipCode: "000000",
6
+ name: "Imaginex",
7
+ latitude: "",
8
+ isVirtual: 0,
9
+ address: "Santa Rosa 402",
10
+ country: "Chile",
11
+ municipality: "Puerto Varas",
12
+ city: "Puerto Varas",
13
+ costCenter: "25",
14
+ description: "Oficina"
15
+ }
16
+ end
17
+
18
+ def object
19
+ @object
20
+ end
21
+ end
@@ -0,0 +1,34 @@
1
+ class Shipping
2
+ attr_reader :object
3
+
4
+ def initialize
5
+ @object = {
6
+ documentTypeId: 1,
7
+ officeId: 1,
8
+ expirationDate: 1_409_149_934,
9
+ emissionDate: 1_409_149_934,
10
+ shippingTypeId: 6,
11
+ municipality: 'Puerto Varas',
12
+ city: 'Puerto Varas',
13
+ address: 'la quebrada 1005',
14
+ declareSii: 1,
15
+ recipient: 'Andres Gallardo',
16
+ details: [
17
+ {
18
+ taxId: '[1]',
19
+ quantity: 1,
20
+ comment: 'PASAJERO: JAIME GONZALEZ',
21
+ netUnitValue: 12_000
22
+ }
23
+ ],
24
+ client: {
25
+ municipality: 'PUERTO MONTT',
26
+ code: '13121776-5',
27
+ activity: 'SERV. TELECOMUNICACIONES',
28
+ company: 'JAIME ALTAMIRANO SOTO',
29
+ city: 'PUERTO MONTT',
30
+ address: 'EMILIO RECABARREN 231'
31
+ }
32
+ }
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ class BsaleApi
2
+ VERSION = "0.1.0"
3
+ end
data/lib/bsale_api.rb ADDED
@@ -0,0 +1,57 @@
1
+ require 'bsale_api/version'
2
+ require 'httparty'
3
+ require 'dotenv/load'
4
+
5
+ class BsaleApi
6
+ include HTTParty
7
+ base_uri 'https://api.bsale.cl'
8
+
9
+ def initialize(version=1, extension='.json')
10
+ @headers = {
11
+ 'Content-Type' => 'application/json',
12
+ 'access_token' => ENV['BSALE_TOKEN']
13
+ }
14
+ @version = version
15
+ @extension = extension
16
+ end
17
+
18
+ def clients
19
+ self.class.get("/v#{@version}/clients#{@extension}", headers: @headers)
20
+ end
21
+
22
+ def document(data, parameters)
23
+ self.class.send(parameters[:method].downcase, "/v#{@version}/documents#{@extension}", headers: @headers, body: data.to_json)
24
+ end
25
+
26
+ def documents
27
+ self.class.get("/v#{@version}/documents#{@extension}", headers: @headers)
28
+ end
29
+
30
+ def document_types
31
+ self.class.get("/v#{@version}/document_types#{@extension}", headers: @headers)
32
+ end
33
+
34
+ def office(parameters, data = {})
35
+ self.class.send(parameters[:method].downcase,
36
+ "/v#{@version}/offices#{parameters[:specific]}#{@extension}",
37
+ headers: @headers, body: data.to_json)
38
+ end
39
+
40
+ def offices
41
+ self.class.get("/v#{@version}/offices#{@extension}", headers: @headers)
42
+ end
43
+
44
+ def shipping(parameters, data = {})
45
+ self.class.send(parameters[:method].downcase,
46
+ "/v#{@version}/shippings#{parameters[:specific]}#{@extension}",
47
+ headers: @headers, body: data.to_json)
48
+ end
49
+
50
+ def shippings
51
+ self.class.get("/v#{@version}/shippings#{@extension}", headers: @headers)
52
+ end
53
+
54
+ def shipping_types
55
+ self.class.get("/v#{@version}/shipping_types#{@extension}", headers: @headers)
56
+ end
57
+ end
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bsale_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nelson Pato Jimenez
8
+ - Michel Szinavel
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2017-02-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: dotenv
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: httparty
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 0.14.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 0.14.0
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.12'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.12'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '10.0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '10.0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '3.0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '3.0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: pry-byebug
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: 3.4.2
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: 3.4.2
98
+ description: " Wrapper for BSALE API"
99
+ email:
100
+ - developer.jimenez@gmail.com
101
+ - michel.szinavel@gmail.com
102
+ executables: []
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - ".env"
107
+ - ".gitignore"
108
+ - ".rspec"
109
+ - ".travis.yml"
110
+ - CODE_OF_CONDUCT.md
111
+ - Gemfile
112
+ - LICENSE.txt
113
+ - README.md
114
+ - Rakefile
115
+ - bin/console
116
+ - bin/setup
117
+ - bsale_api.gemspec
118
+ - lib/bsale_api.rb
119
+ - lib/bsale_api/document.rb
120
+ - lib/bsale_api/office.rb
121
+ - lib/bsale_api/shipping.rb
122
+ - lib/bsale_api/version.rb
123
+ homepage: https://github.com/shipit-team/bsale_api
124
+ licenses:
125
+ - MIT
126
+ metadata: {}
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubyforge_project:
143
+ rubygems_version: 2.6.10
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: BSale Api
147
+ test_files: []