myerp_api 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9dd46358ff3cf30aaf0eb053299d5da6f78e4bab
4
- data.tar.gz: e58f9d539520680c9108bb75d5fbb641a44bd3f9
3
+ metadata.gz: db3fe364b6b4f2cb6126bf526411469834f83408
4
+ data.tar.gz: 4145410f302514a5bd945e51e9ad55e0e698dc66
5
5
  SHA512:
6
- metadata.gz: 277265e93330eadb167b26df510b09027eb16f6fccf5b08a3ec0ac27108ccedb5aeb0c090448ba9ae0b536c6079c0b83092f4a13fcb6d806d32bae758d7e9f25
7
- data.tar.gz: 1b44d4575174b1bcb699937832587eaf231b2a41c734fad3cf0173c894028be2dab8a6c29c0b4d3697404bbf333ed5b9ff4babd1aa2113f1453004b9a90e9489
6
+ metadata.gz: e1294d6dd8eb4e1231e55ac369bd29a63475874ec7b10920bee917fd2d68d762d6b5fe54ab30be81cc32c176cdfb88664e31d0da6528b8a0dc413344045be06a
7
+ data.tar.gz: 289d6fe688717161dda9c289ee16d4fa198225306ae1ace493db33b240ad0d2dcc2de0b17eecf3523f58885ec9d9a8619feef6d477387dfc0863164609ce8be2
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.1
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # myERP API
2
2
 
3
+ [![Build Status](https://travis-ci.org/myERP/myerp-ruby-api-client.png?branch=master)](https://travis-ci.org/myERP/myerp-ruby-api-client)
3
4
 
4
5
  The myERP API gem allows Ruby developers to programmatically access the data of myERP accounts.
5
6
 
@@ -52,14 +53,6 @@ puts "#{customer.full_name} updated [id=#{customer.id}]"
52
53
  # Delete a customer
53
54
  customer = client.customers.delete(customer)
54
55
  puts "#{customer.full_name} deleted [id=#{customer.id}]"
55
-
56
- # Bulk creation/modification
57
- customers = client.customers.bulkSave([customer, customer2])
58
- puts customers
59
-
60
- # Bulk deletion
61
- customers = client.customers.delete([customer, customer2])
62
- puts customers
63
56
  ```
64
57
 
65
58
  ## Contributing
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -46,18 +46,12 @@ module MyERP
46
46
  raise MyERP::AuthenticationFailed.new(response, params)
47
47
  when 404
48
48
  raise MyERP::NotFound.new(response, params)
49
- when 409
50
- raise MyERP::Conflict.new(response, params)
51
- when 412
52
- raise MyERP::MissingField.new(response, params)
53
49
  when 422
54
50
  raise MyERP::UnprocessableEntity.new(response, params)
55
51
  when 429
56
52
  raise MyERP::RateLimited.new(response, params)
57
53
  when 500
58
54
  raise MyERP::ServerError.new(response, params)
59
- when 502
60
- raise MyERP::Unavailable.new(response, params)
61
55
  else
62
56
  raise MyERP::HTTPError.new(response, params)
63
57
  end
data/lib/myerp/crud.rb CHANGED
@@ -32,21 +32,10 @@ module MyERP
32
32
  api_model.parse(resp.parsed_response).first
33
33
  end
34
34
 
35
- def bulkSave(models)
36
- raise "array required" unless models.is_a?(Array)
37
- resp = request(:put, credentials, "#{api_model.api_path}", :body => models.to_json)
38
- api_model.parse(resp.parsed_response)
39
- end
40
-
41
35
  def delete(model)
42
- if model.is_a?(Array)
43
- resp = request(:delete, credentials, "#{api_model.api_path}", :body => model.to_json)
44
- api_model.parse(resp.parsed_response)
45
- else
46
- raise "model unsaved" unless !model.new?
47
- resp = request(:delete, credentials, "#{api_model.api_path}/#{model.to_i}")
48
- api_model.parse(resp.parsed_response).first
49
- end
36
+ raise "model unsaved" unless !model.new?
37
+ resp = request(:delete, credentials, "#{api_model.api_path}/#{model.to_i}")
38
+ api_model.parse(resp.parsed_response).first
50
39
  end
51
40
  end
52
41
  end
data/lib/myerp/errors.rb CHANGED
@@ -18,11 +18,8 @@ module MyERP
18
18
 
19
19
  class RateLimited < HTTPError; end
20
20
  class NotFound < HTTPError; end
21
- class Unavailable < HTTPError; end
22
21
  class BadRequest < HTTPError; end
23
22
  class ServerError < HTTPError; end
24
23
  class AuthenticationFailed < HTTPError ; end
25
- class UnprocessableEntity < HTTPError; end
26
- class MissingField < HTTPError; end
27
- class Conflict < HTTPError; end
24
+ class UnprocessableEntity < HTTPError; end
28
25
  end
data/myerp_api.gemspec CHANGED
@@ -2,20 +2,23 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: myerp_api 0.1.2 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "myerp_api"
8
- s.version = "0.1.1"
9
+ s.version = "0.1.2"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
11
13
  s.authors = ["Didier Baquier"]
12
- s.date = "2014-03-06"
14
+ s.date = "2014-03-12"
13
15
  s.description = "The myERP API gem is a lightweight gem for accessing the myERP REST web services"
14
16
  s.email = "didier.baquier@myerp.com"
15
17
  s.extra_rdoc_files = [
16
18
  "README.md"
17
19
  ]
18
20
  s.files = [
21
+ ".travis.yml",
19
22
  "Gemfile",
20
23
  "README.md",
21
24
  "Rakefile",
@@ -49,12 +52,15 @@ Gem::Specification.new do |s|
49
52
  "lib/myerp/sales_order.rb",
50
53
  "lib/myerp/transaction.rb",
51
54
  "lib/myerp_api.rb",
52
- "myerp_api.gemspec"
55
+ "myerp_api.gemspec",
56
+ "spec/myerp/base_spec.rb",
57
+ "spec/myerp/credentials_spec.rb",
58
+ "spec/spec_helper.rb",
59
+ "spec/test_rubies"
53
60
  ]
54
61
  s.homepage = "http://www.myerp.com"
55
62
  s.licenses = ["MIT"]
56
- s.require_paths = ["lib"]
57
- s.rubygems_version = "2.0.3"
63
+ s.rubygems_version = "2.2.2"
58
64
  s.summary = "The myERP API gem is a lightweight gem for accessing the myERP REST web services"
59
65
 
60
66
  if s.respond_to? :specification_version then
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe MyERP::Base do
4
+ describe "email/key errors" do
5
+ it "should raise error if missing a credential" do
6
+ lambda { MyERP::Base.new(nil, "key") }.should raise_error(MyERP::InvalidCredentials)
7
+ lambda { MyERP::Base.new("email", nil) }.should raise_error(MyERP::InvalidCredentials)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe MyERP::Credentials do
4
+ describe "#valid?" do
5
+ it "should return true if email, key, and options is filled out" do
6
+ MyERP::Credentials.new("email", "key", {}).should be_valid
7
+ end
8
+
9
+ it "should return false if either email, key, and options is nil" do
10
+ MyERP::Credentials.new("email", "key", nil).should_not be_valid
11
+ MyERP::Credentials.new("email", nil, {}).should_not be_valid
12
+ MyERP::Credentials.new(nil, "key", {}).should_not be_valid
13
+ MyERP::Credentials.new(nil, nil, nil).should_not be_valid
14
+ end
15
+ end
16
+
17
+ describe "#basic_auth" do
18
+ it "should base64 encode the credentials" do
19
+ MyERP::Credentials.new("email", "key", {}).basic_auth.should == "ZW1haWw6a2V5"
20
+ end
21
+ end
22
+
23
+ describe "#host" do
24
+ it "should not display the port if it's http/80 or https/443" do
25
+ MyERP::Credentials.new("email", "key", {:protocol => 'https', :host => 'app.myerp.com', :port => 443, :prefix => '/api/v1'})
26
+ .host.should == "https://app.myerp.com/api/v1"
27
+
28
+ MyERP::Credentials.new("email", "key", {:protocol => 'http', :host => 'app.myerp.com', :port => 80, :prefix => '/api/v1'})
29
+ .host.should == "http://app.myerp.com/api/v1"
30
+ end
31
+
32
+ it "should display the port if it's http/!=80 or https/!=443" do
33
+ MyERP::Credentials.new("email", "key", {:protocol => 'https', :host => 'app.myerp.com', :port => 4433, :prefix => '/api/v1'})
34
+ .host.should == "https://app.myerp.com:4433/api/v1"
35
+
36
+ MyERP::Credentials.new("email", "key", {:protocol => 'http', :host => 'app.myerp.com', :port => 8080, :prefix => '/api/v1'})
37
+ .host.should == "http://app.myerp.com:8080/api/v1"
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,30 @@
1
+ require 'myerp_api'
2
+ require 'webmock/rspec'
3
+ require 'vcr'
4
+ require 'factory_girl'
5
+
6
+ VCR.configure do |c|
7
+ c.cassette_library_dir = '.cassettes'
8
+ c.hook_into :webmock
9
+ end
10
+
11
+ FileUtils.rm(Dir["#{VCR.configuration.cassette_library_dir}/*"]) if ENV['VCR_REFRESH'] == 'true'
12
+
13
+ FactoryGirl.find_definitions
14
+
15
+ RSpec.configure do |config|
16
+
17
+ config.before(:suite) do
18
+ WebMock.allow_net_connect!
19
+ end
20
+
21
+ config.before(:each) do
22
+ WebMock.allow_net_connect!
23
+ end
24
+
25
+ def cassette(*args)
26
+ VCR.use_cassette(*args) do
27
+ yield
28
+ end
29
+ end
30
+ end
data/spec/test_rubies ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -o verbose
4
+ RBXOPT="-Xrbc.db" rvm ruby-1.8.7-p334,ruby-1.9.2-p180,rbx,jruby-1.6.2 exec bundle
5
+ RBXOPT="-Xrbc.db" rvm ruby-1.8.7-p334,ruby-1.9.2-p180,rbx,jruby-1.6.2 exec bundle exec rake spec
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myerp_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Didier Baquier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-06 00:00:00.000000000 Z
11
+ date: 2014-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -186,6 +186,7 @@ extensions: []
186
186
  extra_rdoc_files:
187
187
  - README.md
188
188
  files:
189
+ - ".travis.yml"
189
190
  - Gemfile
190
191
  - README.md
191
192
  - Rakefile
@@ -220,6 +221,10 @@ files:
220
221
  - lib/myerp/transaction.rb
221
222
  - lib/myerp_api.rb
222
223
  - myerp_api.gemspec
224
+ - spec/myerp/base_spec.rb
225
+ - spec/myerp/credentials_spec.rb
226
+ - spec/spec_helper.rb
227
+ - spec/test_rubies
223
228
  homepage: http://www.myerp.com
224
229
  licenses:
225
230
  - MIT