centrum_faktur 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/centrum_faktur.gemspec +3 -3
- data/lib/centrum_faktur/account.rb +5 -3
- data/lib/centrum_faktur/comment.rb +9 -7
- data/lib/centrum_faktur/connection.rb +2 -2
- data/lib/centrum_faktur/customer.rb +21 -19
- data/lib/centrum_faktur/estimate.rb +25 -23
- data/lib/centrum_faktur/invoice.rb +25 -23
- data/lib/centrum_faktur/payment.rb +9 -7
- data/lib/centrum_faktur/user.rb +5 -3
- data/lib/centrum_faktur/version.rb +1 -1
- data/test/comment_test.rb +5 -3
- data/test/configuration_test.rb +1 -1
- data/test/connection_test.rb +2 -2
- data/test/customer_test.rb +3 -2
- data/test/invoice_test.rb +5 -3
- data/test/payments_test.rb +7 -5
- data/test/user_test.rb +10 -3
- data/test/utils_test.rb +19 -10
- metadata +7 -8
- data/README.markdown +0 -162
data/Gemfile
CHANGED
data/centrum_faktur.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path(
|
2
|
+
require File.expand_path("../lib/centrum_faktur/version", __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Wojciech Wnętrzak"]
|
@@ -12,9 +12,9 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.files = `git ls-files`.split("\n")
|
13
13
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
14
|
gem.name = "centrum_faktur"
|
15
|
-
gem.require_paths = [
|
15
|
+
gem.require_paths = ["lib"]
|
16
16
|
gem.version = CentrumFaktur::VERSION
|
17
17
|
|
18
|
-
gem.add_dependency "multi_json"
|
18
|
+
gem.add_dependency "multi_json", "~> 1.3.2"
|
19
19
|
gem.add_development_dependency "fakeweb"
|
20
20
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
class CentrumFaktur::Account
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
class << self
|
3
|
+
def list(options = {})
|
4
|
+
request = CentrumFaktur::Connection.new.get("/api/1.0/accounts/", options)
|
5
|
+
request.handle_response
|
6
|
+
end
|
5
7
|
end
|
6
8
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
class CentrumFaktur::Comment
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
class << self
|
3
|
+
def list(comment_uri = "/api/1.0/comments/", options = {})
|
4
|
+
request = CentrumFaktur::Connection.new.get(comment_uri, options)
|
5
|
+
request.handle_response
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
def create(comment_uri, params)
|
9
|
+
request = CentrumFaktur::Connection.new.post(comment_uri, params)
|
10
|
+
request.handle_response
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
@@ -43,7 +43,7 @@ class CentrumFaktur::Connection
|
|
43
43
|
@path = URI.parse(to).to_s
|
44
44
|
request = Net::HTTP::Post.new(@path, headers)
|
45
45
|
request.basic_auth(login, password)
|
46
|
-
request.body = MultiJson.
|
46
|
+
request.body = MultiJson.dump(CentrumFaktur::Utils.normalize_params(params))
|
47
47
|
@response = http.request(request)
|
48
48
|
self
|
49
49
|
end
|
@@ -68,7 +68,7 @@ class CentrumFaktur::Connection
|
|
68
68
|
def parse_response
|
69
69
|
case format.to_sym
|
70
70
|
when :json
|
71
|
-
response.body ? MultiJson.
|
71
|
+
response.body ? MultiJson.load(response.body) : nil
|
72
72
|
when :yaml
|
73
73
|
response.body ? YAML.load(response.body) : nil
|
74
74
|
when :xml, :pickle, :pdf
|
@@ -1,26 +1,28 @@
|
|
1
1
|
class CentrumFaktur::Customer
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
class << self
|
3
|
+
def list(options = {})
|
4
|
+
request = CentrumFaktur::Connection.new.get("/api/1.0/customers/", options)
|
5
|
+
request.handle_response
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
def show(customer_uri, options = {})
|
9
|
+
request = CentrumFaktur::Connection.new.get(customer_uri, options)
|
10
|
+
request.handle_response
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
def create(params)
|
14
|
+
request = CentrumFaktur::Connection.new.post("/api/1.0/customers/", params)
|
15
|
+
request.handle_response
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
def update(customer_uri, params)
|
19
|
+
request = CentrumFaktur::Connection.new.put(customer_uri, params)
|
20
|
+
request.handle_response
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
def destroy(customer_uri)
|
24
|
+
request = CentrumFaktur::Connection.new.delete(customer_uri)
|
25
|
+
request.handle_response
|
26
|
+
end
|
25
27
|
end
|
26
28
|
end
|
@@ -1,31 +1,33 @@
|
|
1
1
|
class CentrumFaktur::Estimate
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
class << self
|
3
|
+
def list(options = {})
|
4
|
+
request = CentrumFaktur::Connection.new.get("/api/1.0/estimates/", options)
|
5
|
+
request.handle_response
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
def list_updates(options = {})
|
9
|
+
request = CentrumFaktur::Connection.new.get("/api/1.0/estimates/updates/", options)
|
10
|
+
request.handle_response
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
def show(estimate_uri, options = {})
|
14
|
+
request = CentrumFaktur::Connection.new.get(estimate_uri, options)
|
15
|
+
request.handle_response
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
def create(params)
|
19
|
+
request = CentrumFaktur::Connection.new.post("/api/1.0/estimates/", params)
|
20
|
+
request.handle_response
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
def update(estimate_uri, params)
|
24
|
+
request = CentrumFaktur::Connection.new.put(estimate_uri, params)
|
25
|
+
request.handle_response
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
def destroy(estimate_uri)
|
29
|
+
request = CentrumFaktur::Connection.new.delete(estimate_uri)
|
30
|
+
request.handle_response
|
31
|
+
end
|
30
32
|
end
|
31
33
|
end
|
@@ -1,31 +1,33 @@
|
|
1
1
|
class CentrumFaktur::Invoice
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
class << self
|
3
|
+
def list(options = {})
|
4
|
+
request = CentrumFaktur::Connection.new.get("/api/1.0/invoices/", options)
|
5
|
+
request.handle_response
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
def list_updates(options = {})
|
9
|
+
request = CentrumFaktur::Connection.new.get("/api/1.0/invoices/updates/", options)
|
10
|
+
request.handle_response
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
def show(invoice_uri, options = {})
|
14
|
+
request = CentrumFaktur::Connection.new.get(invoice_uri, options)
|
15
|
+
request.handle_response
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
def create(params)
|
19
|
+
request = CentrumFaktur::Connection.new.post("/api/1.0/invoices/", params)
|
20
|
+
request.handle_response
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
def update(invoice_uri, params)
|
24
|
+
request = CentrumFaktur::Connection.new.put(invoice_uri, params)
|
25
|
+
request.handle_response
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
def destroy(invoice_uri)
|
29
|
+
request = CentrumFaktur::Connection.new.delete(invoice_uri)
|
30
|
+
request.handle_response
|
31
|
+
end
|
30
32
|
end
|
31
33
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
class CentrumFaktur::Payment
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
class << self
|
3
|
+
def list(comment_uri = "/api/1.0/payments/", options = {})
|
4
|
+
request = CentrumFaktur::Connection.new.get(comment_uri, options)
|
5
|
+
request.handle_response
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
def create(payment_uri, params)
|
9
|
+
request = CentrumFaktur::Connection.new.post(payment_uri, params)
|
10
|
+
request.handle_response
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
data/lib/centrum_faktur/user.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
class CentrumFaktur::User
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
class << self
|
3
|
+
def list(options = {})
|
4
|
+
request = CentrumFaktur::Connection.new.get("/api/1.0/users/", options)
|
5
|
+
request.handle_response
|
6
|
+
end
|
5
7
|
end
|
6
8
|
end
|
data/test/comment_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
require "helper"
|
3
3
|
|
4
|
-
describe
|
4
|
+
describe CentrumFaktur::Comment do
|
5
5
|
before do
|
6
6
|
CentrumFaktur.configure do |config|
|
7
7
|
config.login = "john"
|
@@ -10,17 +10,19 @@ describe "Comment" do
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
it "
|
13
|
+
it "returns estimate comments list limited to one" do
|
14
14
|
FakeWeb.register_uri(:get, "https://john:secret@john.centrumfaktur.pl/api/1.0/estimates/14587/comments/?limit=1", :response => fixture("comments.txt"))
|
15
15
|
response = CentrumFaktur::Comment.list("/api/1.0/estimates/14587/comments/", :limit => 1)
|
16
16
|
expected = [{"body"=>"cool", "user_uri"=>"/api/1.0/users/749/", "comment_type"=>"user", "created"=>"2011-06-14 20:06:36", "commented_object_type"=>"estimate", "commented_object_uri"=>"/api/1.0/estimates/20527/", "is_public"=>false}]
|
17
|
+
|
17
18
|
assert_equal expected, response
|
18
19
|
end
|
19
20
|
|
20
|
-
it "
|
21
|
+
it "creates comment" do
|
21
22
|
FakeWeb.register_uri(:post, "https://john:secret@john.centrumfaktur.pl/api/1.0/estimates/14587/comments/", :response => fixture("new_comment.txt"))
|
22
23
|
response = CentrumFaktur::Comment.create("/api/1.0/estimates/14587/comments/", {:body => "cool", :is_public => false})
|
23
24
|
expected = {"body"=>"thanks", "user_uri"=>"/api/1.0/users/749/", "comment_type"=>"user", "created"=>"2011-06-16 21:55:03", "commented_object_type"=>"estimate", "commented_object_uri"=>"/api/1.0/estimates/20627/", "is_public"=>false}
|
25
|
+
|
24
26
|
assert_equal expected, response
|
25
27
|
end
|
26
28
|
end
|
data/test/configuration_test.rb
CHANGED
data/test/connection_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe CentrumFaktur::Connection do
|
4
4
|
before do
|
5
5
|
CentrumFaktur.configure do |config|
|
6
6
|
config.login = "fake"
|
@@ -9,7 +9,7 @@ describe "Connection" do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
it "
|
12
|
+
it "returns url to custom profile" do
|
13
13
|
assert_equal "https://fake.centrumfaktur.pl", CentrumFaktur::Connection.new.uri.to_s
|
14
14
|
end
|
15
15
|
end
|
data/test/customer_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
require "helper"
|
3
3
|
|
4
|
-
describe
|
4
|
+
describe CentrumFaktur::Customer do
|
5
5
|
before do
|
6
6
|
CentrumFaktur.configure do |config|
|
7
7
|
config.login = "john"
|
@@ -10,10 +10,11 @@ describe "Customer" do
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
it "
|
13
|
+
it "returns customers list" do
|
14
14
|
FakeWeb.register_uri(:get, "https://john:secret@john.centrumfaktur.pl/api/1.0/customers/", :response => fixture("customers.txt"))
|
15
15
|
response = CentrumFaktur::Customer.list
|
16
16
|
expected = [{"name"=>"Stefan Stefański", "contact"=>"", "address"=>"Stefanowo\r\nul. Stefańska 1", "resource_uri"=>"/api/1.0/customers/3138/", "email"=>"w.wnetrzak+stefan@gmail.com", "tax_id"=>""}]
|
17
|
+
|
17
18
|
assert_equal expected, response
|
18
19
|
end
|
19
20
|
end
|
data/test/invoice_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
require "helper"
|
3
3
|
|
4
|
-
describe
|
4
|
+
describe CentrumFaktur::Invoice do
|
5
5
|
before do
|
6
6
|
CentrumFaktur.configure do |config|
|
7
7
|
config.login = "john"
|
@@ -10,14 +10,16 @@ describe "Invoice" do
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
it "
|
13
|
+
it "detroys invoice" do
|
14
14
|
FakeWeb.register_uri(:delete, "https://john:secret@john.centrumfaktur.pl/api/1.0/invoices/666/", :response => fixture("destroy_invoice.txt"))
|
15
15
|
response = CentrumFaktur::Invoice.destroy("/api/1.0/invoices/666/")
|
16
|
+
|
16
17
|
assert_equal nil, response
|
17
18
|
end
|
18
19
|
|
19
|
-
it "
|
20
|
+
it "raises error when invoice does not exist" do
|
20
21
|
FakeWeb.register_uri(:delete, "https://john:secret@john.centrumfaktur.pl/api/1.0/invoices/666/", :response => fixture("destroy_invoice_404.txt"))
|
22
|
+
|
21
23
|
assert_raises CentrumFaktur::ResponseError do
|
22
24
|
CentrumFaktur::Invoice.destroy("/api/1.0/invoices/666/")
|
23
25
|
end
|
data/test/payments_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe CentrumFaktur::Payment do
|
4
4
|
before do
|
5
5
|
CentrumFaktur.configure do |config|
|
6
6
|
config.login = "john"
|
@@ -9,7 +9,7 @@ describe "Payment" do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
it "
|
12
|
+
it "gets payment" do
|
13
13
|
FakeWeb.register_uri(:get,
|
14
14
|
"https://john:secret@john.centrumfaktur.pl/api/1.0/invoices/22933/payments",
|
15
15
|
:response => fixture("payments.txt")
|
@@ -23,15 +23,17 @@ describe "Payment" do
|
|
23
23
|
assert_equal expected, response
|
24
24
|
end
|
25
25
|
|
26
|
-
it "
|
26
|
+
it "creates payment" do
|
27
27
|
FakeWeb.register_uri(:post, "https://john:secret@john.centrumfaktur.pl/api/1.0/invoices/22933/payments", :response => fixture("new_payment.txt"))
|
28
28
|
response = CentrumFaktur::Payment.create("/api/1.0/invoices/22933/payments",
|
29
29
|
{:date => "2011-06-10", :amount => 99.00}
|
30
30
|
)
|
31
31
|
|
32
|
-
expected = {
|
33
|
-
"
|
32
|
+
expected = {
|
33
|
+
"date" => "2011-06-10",
|
34
|
+
"amount" => 99.00, "created" => "2012-01-01", "resource_uri" => "/api/1.0/payments/99999/"
|
34
35
|
}
|
36
|
+
|
35
37
|
assert_equal expected, response
|
36
38
|
end
|
37
39
|
end
|
data/test/user_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
require "helper"
|
3
3
|
|
4
|
-
describe
|
4
|
+
describe CentrumFaktur::User do
|
5
5
|
before do
|
6
6
|
CentrumFaktur.configure do |config|
|
7
7
|
config.login = "john"
|
@@ -10,10 +10,17 @@ describe "User" do
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
it "
|
13
|
+
it "returns users list" do
|
14
14
|
FakeWeb.register_uri(:get, "https://john:secret@john.centrumfaktur.pl/api/1.0/users/", :response => fixture("users.txt"))
|
15
15
|
response = CentrumFaktur::User.list
|
16
|
-
expected = [{
|
16
|
+
expected = [{
|
17
|
+
"login" => "morgoth",
|
18
|
+
"first_name" => "Wojciech",
|
19
|
+
"last_name" => "Wnętrzak",
|
20
|
+
"email" => "w.wnetrzak@gmail.com",
|
21
|
+
"resource_uri" => "/api/1.0/users/749/"
|
22
|
+
}]
|
23
|
+
|
17
24
|
assert_equal expected, response
|
18
25
|
end
|
19
26
|
end
|
data/test/utils_test.rb
CHANGED
@@ -1,52 +1,61 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
|
-
describe
|
4
|
-
it "
|
3
|
+
describe CentrumFaktur::Utils do
|
4
|
+
it "converts params to inline style" do
|
5
5
|
params = CentrumFaktur::Utils.inline_params({:offset => 2, :limit => 10})
|
6
|
+
|
6
7
|
assert_equal "offset=2&limit=10", params
|
7
8
|
end
|
8
9
|
|
9
|
-
it "
|
10
|
+
it "converts params to inline style with path" do
|
10
11
|
path = CentrumFaktur::Utils.path_with_params("/api/1.0/invoices/", {:offset => 2, :limit => 10})
|
12
|
+
|
11
13
|
assert_equal "/api/1.0/invoices/?offset=2&limit=10", path.to_s
|
12
14
|
end
|
13
15
|
|
14
|
-
it "
|
16
|
+
it "returns path when no params provided" do
|
15
17
|
path = CentrumFaktur::Utils.path_with_params("/api/1.0/invoices/", {})
|
18
|
+
|
16
19
|
assert_equal "/api/1.0/invoices/", path.to_s
|
17
20
|
end
|
18
21
|
|
19
|
-
it "
|
22
|
+
it "normalizes date to required format" do
|
20
23
|
normalized = CentrumFaktur::Utils.normalize_value(Time.mktime(2012, 01, 01))
|
24
|
+
|
21
25
|
assert_equal "2012-01-01", normalized
|
22
26
|
end
|
23
27
|
|
24
|
-
it "
|
28
|
+
it "does not normalize not Date values" do
|
25
29
|
normalized = CentrumFaktur::Utils.normalize_value("value")
|
30
|
+
|
26
31
|
assert_equal "value", normalized
|
27
32
|
end
|
28
33
|
|
29
|
-
it "
|
34
|
+
it "normalizes params hash" do
|
30
35
|
params = {:body => "value", :date => Time.mktime(2012, 01, 01)}
|
31
36
|
normalized = CentrumFaktur::Utils.normalize_params(params)
|
37
|
+
|
32
38
|
assert_equal({:body => "value", :date => "2012-01-01"}, normalized)
|
33
39
|
end
|
34
40
|
|
35
|
-
it "
|
41
|
+
it "normalizes nested params hash" do
|
36
42
|
params = {:body => "value", :nested => {:date => Time.mktime(2012, 01, 01)}}
|
37
43
|
normalized = CentrumFaktur::Utils.normalize_params(params)
|
44
|
+
|
38
45
|
assert_equal({:body => "value", :nested => {:date => "2012-01-01"}}, normalized)
|
39
46
|
end
|
40
47
|
|
41
|
-
it "
|
48
|
+
it "normalizes nested array params hash" do
|
42
49
|
params = {:body => "value", :items => [:date1 => Time.mktime(2012, 01, 01), :date2 => Time.mktime(2012, 01, 02)]}
|
43
50
|
normalized = CentrumFaktur::Utils.normalize_params(params)
|
51
|
+
|
44
52
|
assert_equal({:body => "value", :items => [:date1 => "2012-01-01", :date2 => "2012-01-02"]}, normalized)
|
45
53
|
end
|
46
54
|
|
47
|
-
it "
|
55
|
+
it "normalizes nested array values" do
|
48
56
|
params = {:body => "value", :items => [Time.mktime(2012, 01, 01), "value"]}
|
49
57
|
normalized = CentrumFaktur::Utils.normalize_params(params)
|
58
|
+
|
50
59
|
assert_equal({:body => "value", :items => ["2012-01-01", "value"]}, normalized)
|
51
60
|
end
|
52
61
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: centrum_faktur
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 1.3.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 1.3.2
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: fakeweb
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -54,7 +54,6 @@ files:
|
|
54
54
|
- .travis.yml
|
55
55
|
- Gemfile
|
56
56
|
- LICENSE
|
57
|
-
- README.markdown
|
58
57
|
- README.md
|
59
58
|
- Rakefile
|
60
59
|
- centrum_faktur.gemspec
|
@@ -107,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
106
|
version: '0'
|
108
107
|
requirements: []
|
109
108
|
rubyforge_project:
|
110
|
-
rubygems_version: 1.8.
|
109
|
+
rubygems_version: 1.8.22
|
111
110
|
signing_key:
|
112
111
|
specification_version: 3
|
113
112
|
summary: Ruby client for Centrum Faktur API
|
data/README.markdown
DELETED
@@ -1,162 +0,0 @@
|
|
1
|
-
# Centrum Faktur
|
2
|
-
|
3
|
-
Ruby client for [Centrum Faktur API](http://centrumfaktur.pl/api/)
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
```
|
8
|
-
gem install centrum_faktur
|
9
|
-
```
|
10
|
-
|
11
|
-
## Configuration
|
12
|
-
|
13
|
-
``` ruby
|
14
|
-
require "centrum_faktur"
|
15
|
-
|
16
|
-
CentrumFaktur.configure do |config|
|
17
|
-
config.login = "your_login"
|
18
|
-
config.subdomain = "your-subdomain"
|
19
|
-
config.password = "your-password"
|
20
|
-
end
|
21
|
-
```
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
Requests return Array or Hash, where keys are strings.
|
26
|
-
When other format than json (default) or yaml is specified, response is not parsed.
|
27
|
-
So for xml and pickle requests string is returned.
|
28
|
-
|
29
|
-
``` ruby
|
30
|
-
CentrumFaktur::Invoice.show("/api/1.0/invoices/1/", :format => :xml)
|
31
|
-
```
|
32
|
-
|
33
|
-
Writing invoice to pdf can be done as follows:
|
34
|
-
|
35
|
-
``` ruby
|
36
|
-
File.open("my-invoice.pdf", "w") { |file| file.write(CentrumFaktur::Invoice.show("/api/1.0/invoices/1/", :format => :pdf)) }
|
37
|
-
```
|
38
|
-
|
39
|
-
All params that respond to `strftime` (i.e. Date, Time) will be normalized to format
|
40
|
-
required by API, that is: `"YYYY-MM-DD"`
|
41
|
-
|
42
|
-
### Account
|
43
|
-
|
44
|
-
Only listing accounts is supported via API
|
45
|
-
|
46
|
-
``` ruby
|
47
|
-
CentrumFaktur::Account.list
|
48
|
-
```
|
49
|
-
|
50
|
-
### Comment
|
51
|
-
|
52
|
-
Listing all comments:
|
53
|
-
|
54
|
-
``` ruby
|
55
|
-
CentrumFaktur::Comment.list
|
56
|
-
```
|
57
|
-
|
58
|
-
Or listing comments for given resource:
|
59
|
-
|
60
|
-
``` ruby
|
61
|
-
CentrumFaktur::Comment.list("/api/1.0/estimates/1/comments/")
|
62
|
-
```
|
63
|
-
|
64
|
-
Creating comment:
|
65
|
-
|
66
|
-
You must pass path to resource comment and required attributes:
|
67
|
-
|
68
|
-
``` ruby
|
69
|
-
CentrumFaktur::Comment.create("/api/1.0/estimates/1/comments/", {:body => "cool", :is_public => false})
|
70
|
-
```
|
71
|
-
|
72
|
-
### Estimate
|
73
|
-
|
74
|
-
Listing all estimates:
|
75
|
-
|
76
|
-
``` ruby
|
77
|
-
CentrumFaktur::Estimate.list
|
78
|
-
```
|
79
|
-
|
80
|
-
Monitoring estimate changes (with optional filter param):
|
81
|
-
|
82
|
-
``` ruby
|
83
|
-
CentrumFaktur::Estimate.list_updates(:updated_since => "2012-01-12")
|
84
|
-
```
|
85
|
-
|
86
|
-
Creating estimate (check required attributes in API description):
|
87
|
-
|
88
|
-
``` ruby
|
89
|
-
CentrumFaktur::Estimate.create({})
|
90
|
-
```
|
91
|
-
|
92
|
-
Updating estimate:
|
93
|
-
|
94
|
-
``` ruby
|
95
|
-
CentrumFaktur::Estimate.update("/api/1.0/estimates/1/", {})
|
96
|
-
```
|
97
|
-
|
98
|
-
Removing estimate:
|
99
|
-
|
100
|
-
``` ruby
|
101
|
-
CentrumFaktur::Estimate.destroy("/api/1.0/estimates/1/")
|
102
|
-
```
|
103
|
-
|
104
|
-
### Invoice
|
105
|
-
|
106
|
-
Listing all invoices:
|
107
|
-
|
108
|
-
``` ruby
|
109
|
-
CentrumFaktur::Invoice.list
|
110
|
-
```
|
111
|
-
|
112
|
-
Monitoring invoice changes:
|
113
|
-
|
114
|
-
``` ruby
|
115
|
-
CentrumFaktur::Invoice.list_updates
|
116
|
-
```
|
117
|
-
|
118
|
-
Displaying invoice:
|
119
|
-
|
120
|
-
``` ruby
|
121
|
-
CentrumFaktur::Invoice.show("/api/1.0/invoices/1/")
|
122
|
-
```
|
123
|
-
|
124
|
-
Creating invoice (check required attributes in API description):
|
125
|
-
|
126
|
-
``` ruby
|
127
|
-
CentrumFaktur::Invoice.create({})
|
128
|
-
```
|
129
|
-
|
130
|
-
Updating invoice:
|
131
|
-
|
132
|
-
``` ruby
|
133
|
-
CentrumFaktur::Invoice.update("/api/1.0/invoices/1/", {})
|
134
|
-
```
|
135
|
-
|
136
|
-
Removing invoice:
|
137
|
-
|
138
|
-
``` ruby
|
139
|
-
CentrumFaktur::Invoice.destroy("/api/1.0/invoices/1/")
|
140
|
-
```
|
141
|
-
|
142
|
-
### User ###
|
143
|
-
|
144
|
-
Only listing users is supported via API
|
145
|
-
|
146
|
-
``` ruby
|
147
|
-
CentrumFaktur::User.list
|
148
|
-
```
|
149
|
-
|
150
|
-
## Continuous Integration
|
151
|
-
|
152
|
-
[![Build Status](https://secure.travis-ci.org/morgoth/centrum_faktur.png)](http://travis-ci.org/morgoth/centrum_faktur)
|
153
|
-
|
154
|
-
## Contributors
|
155
|
-
|
156
|
-
* [Grzegorz Pawlik](https://github.com/pawlik)
|
157
|
-
|
158
|
-
## Copyright
|
159
|
-
|
160
|
-
Created during development for [Ragnarson](http://ragnarson.com/)
|
161
|
-
|
162
|
-
Copyright © Wojciech Wnętrzak. See LICENSE for details.
|