paymill 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,4 +2,5 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
- *.html
5
+ *.html
6
+ /.rvmrc
data/README.md CHANGED
@@ -22,7 +22,15 @@ Now you can e.g. create a new client:
22
22
 
23
23
  Paymill::Client.create(email: "stefan.sprenger@dkd.de", description: "He is a Ruby guy.")
24
24
 
25
- We currently only support `create` and `find` operations.
25
+ Or find a existing client
26
+
27
+ Paymill::Client.find("client_88a388d9dd48f86c3136")
28
+
29
+ For retrieving a collection of all clients
30
+
31
+ Paymill::Client.all()
32
+
33
+ We currently only support `create`, `find` and `all` operations.
26
34
 
27
35
  Requirements
28
36
  =====
data/lib/paymill.rb CHANGED
@@ -15,6 +15,7 @@ module Paymill
15
15
  autoload :Transaction, "paymill/transaction"
16
16
 
17
17
  module Operations
18
+ autoload :All, "paymill/operations/all"
18
19
  autoload :Create, "paymill/operations/create"
19
20
  autoload :Delete, "paymill/operations/delete"
20
21
  autoload :Find, "paymill/operations/find"
@@ -65,4 +66,4 @@ module Paymill
65
66
  data
66
67
  end
67
68
  end
68
- end
69
+ end
@@ -1,5 +1,6 @@
1
1
  module Paymill
2
2
  class Client
3
+ include Paymill::Operations::All
3
4
  include Paymill::Operations::Create
4
5
  include Paymill::Operations::Delete
5
6
  include Paymill::Operations::Find
@@ -11,7 +12,6 @@ module Paymill
11
12
  attributes.each_pair do |key, value|
12
13
  instance_variable_set("@#{key}", value)
13
14
  end
14
- @attributes = attributes
15
15
  end
16
16
  end
17
- end
17
+ end
@@ -1,5 +1,9 @@
1
1
  module Paymill
2
2
  class CreditCard
3
+ include Paymill::Operations::All
4
+ include Paymill::Operations::Create
5
+ include Paymill::Operations::Find
6
+
3
7
  attr_accessor :id, :card_type, :country, :expire_month, :expire_year,
4
8
  :card_holder, :last4, :created_at, :updated_at
5
9
 
@@ -7,7 +11,6 @@ module Paymill
7
11
  attributes.each_pair do |key, value|
8
12
  instance_variable_set("@#{key}", value)
9
13
  end
10
- @attributes = attributes
11
14
  end
12
15
  end
13
- end
16
+ end
data/lib/paymill/offer.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  module Paymill
2
2
  class Offer
3
+ include Paymill::Operations::All
3
4
  include Paymill::Operations::Create
4
5
  include Paymill::Operations::Delete
5
6
  include Paymill::Operations::Find
@@ -10,7 +11,6 @@ module Paymill
10
11
  attributes.each_pair do |key, value|
11
12
  instance_variable_set("@#{key}", value)
12
13
  end
13
- @attributes = attributes
14
14
  end
15
15
  end
16
- end
16
+ end
@@ -0,0 +1,20 @@
1
+ module Paymill
2
+ module Operations
3
+ module All
4
+ module ClassMethods
5
+ def all()
6
+ response = Paymill.request(:get, "#{self.name.split("::").last.downcase}s/", {})
7
+ results = []
8
+ response["data"].each do |obj|
9
+ results << self.new(obj)
10
+ end
11
+ results
12
+ end
13
+ end
14
+
15
+ def self.included(base)
16
+ base.extend(ClassMethods)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,5 +1,6 @@
1
1
  module Paymill
2
2
  class Subscription
3
+ include Paymill::Operations::All
3
4
  include Paymill::Operations::Create
4
5
  include Paymill::Operations::Delete
5
6
  include Paymill::Operations::Find
@@ -11,7 +12,6 @@ module Paymill
11
12
  attributes.each_pair do |key, value|
12
13
  instance_variable_set("@#{key}", value)
13
14
  end
14
- @attributes = attributes
15
15
  end
16
16
  end
17
- end
17
+ end
@@ -1,5 +1,6 @@
1
1
  module Paymill
2
2
  class Transaction
3
+ include Paymill::Operations::All
3
4
  include Paymill::Operations::Create
4
5
  include Paymill::Operations::Find
5
6
 
@@ -10,7 +11,6 @@ module Paymill
10
11
  attributes.each_pair do |key, value|
11
12
  instance_variable_set("@#{key}", value)
12
13
  end
13
- @attributes = attributes
14
14
  end
15
15
  end
16
- end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module Paymill
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -17,12 +17,19 @@ describe Paymill::Client do
17
17
  end
18
18
 
19
19
  describe ".find" do
20
- it "makes a new GET request using the correct API endpoint" do
20
+ it "makes a new GET request using the correct API endpoint to receive a specific client" do
21
21
  Paymill.should_receive(:request).with(:get, "clients/123", {}).and_return("data" => {})
22
22
  Paymill::Client.find("123")
23
23
  end
24
24
  end
25
25
 
26
+ describe ".all" do
27
+ it "makes a new GET request using the correct API endpoint to receive all clients" do
28
+ Paymill.should_receive(:request).with(:get, "clients/", {}).and_return("data" => {})
29
+ Paymill::Client.all
30
+ end
31
+ end
32
+
26
33
  describe ".delete" do
27
34
  it "makes a new DELETE request using the correct API endpoint" do
28
35
  Paymill.should_receive(:request).with(:delete, "clients/123", {}).and_return(true)
@@ -36,4 +43,4 @@ describe Paymill::Client do
36
43
  Paymill::Client.create(valid_attributes)
37
44
  end
38
45
  end
39
- end
46
+ end
@@ -26,4 +26,25 @@ describe Paymill::CreditCard do
26
26
  credit_card.last4.should eql("1111")
27
27
  end
28
28
  end
29
- end
29
+
30
+ describe ".find" do
31
+ it "makes a new GET request using the correct API endpoint to receive a specific creditcard" do
32
+ Paymill.should_receive(:request).with(:get, "creditcards/123", {}).and_return("data" => {})
33
+ Paymill::CreditCard.find("123")
34
+ end
35
+ end
36
+
37
+ describe ".all" do
38
+ it "makes a new GET request using the correct API endpoint to receive all creditcards" do
39
+ Paymill.should_receive(:request).with(:get, "creditcards/", {}).and_return("data" => {})
40
+ Paymill::CreditCard.all
41
+ end
42
+ end
43
+
44
+ describe ".create" do
45
+ it "makes a new POST request using the correct API endpoint" do
46
+ Paymill.should_receive(:request).with(:post, "creditcards", valid_attributes).and_return("data" => {})
47
+ Paymill::CreditCard.create(valid_attributes)
48
+ end
49
+ end
50
+ end
@@ -24,12 +24,19 @@ describe Paymill::Offer do
24
24
  end
25
25
 
26
26
  describe ".find" do
27
- it "makes a new GET request using the correct API endpoint" do
27
+ it "makes a new GET request using the correct API endpoint to receive a specific offer" do
28
28
  Paymill.should_receive(:request).with(:get, "offers/123", {}).and_return("data" => {})
29
29
  Paymill::Offer.find("123")
30
30
  end
31
31
  end
32
32
 
33
+ describe ".all" do
34
+ it "makes a new GET request using the correct API endpoint to receive all offers" do
35
+ Paymill.should_receive(:request).with(:get, "offers/", {}).and_return("data" => {})
36
+ Paymill::Offer.all
37
+ end
38
+ end
39
+
33
40
  describe ".delete" do
34
41
  it "makes a new DELETE request using the correct API endpoint" do
35
42
  Paymill.should_receive(:request).with(:delete, "offers/123", {}).and_return(true)
@@ -43,4 +50,4 @@ describe Paymill::Offer do
43
50
  Paymill::Offer.create(valid_attributes)
44
51
  end
45
52
  end
46
- end
53
+ end
@@ -32,12 +32,19 @@ describe Paymill::Subscription do
32
32
  end
33
33
 
34
34
  describe ".find" do
35
- it "makes a new GET request using the correct API endpoint" do
35
+ it "makes a new GET request using the correct API endpoint to receive a specific subscription" do
36
36
  Paymill.should_receive(:request).with(:get, "subscriptions/123", {}).and_return("data" => {})
37
37
  Paymill::Subscription.find("123")
38
38
  end
39
39
  end
40
40
 
41
+ describe ".all" do
42
+ it "makes a new GET request using the correct API endpoint to receive all subscriptions" do
43
+ Paymill.should_receive(:request).with(:get, "subscriptions/", {}).and_return("data" => {})
44
+ Paymill::Subscription.all
45
+ end
46
+ end
47
+
41
48
  describe ".delete" do
42
49
  it "makes a new DELETE request using the correct API endpoint" do
43
50
  Paymill.should_receive(:request).with(:delete, "subscriptions/123", {}).and_return(true)
@@ -51,4 +58,4 @@ describe Paymill::Subscription do
51
58
  Paymill::Subscription.create(valid_attributes)
52
59
  end
53
60
  end
54
- end
61
+ end
@@ -32,16 +32,23 @@ describe Paymill::Transaction do
32
32
  end
33
33
 
34
34
  describe ".find" do
35
- it "makes a new GET request using the correct API endpoint" do
35
+ it "makes a new GET request using the correct API endpoint to receive a specific transaction" do
36
36
  Paymill.should_receive(:request).with(:get, "transactions/123", {}).and_return("data" => {})
37
37
  Paymill::Transaction.find("123")
38
38
  end
39
39
  end
40
40
 
41
+ describe ".all" do
42
+ it "makes a new GET request using the correct API endpoint to receive all transactions" do
43
+ Paymill.should_receive(:request).with(:get, "transactions/", {}).and_return("data" => {})
44
+ Paymill::Transaction.all
45
+ end
46
+ end
47
+
41
48
  describe ".create" do
42
49
  it "makes a new POST request using the correct API endpoint" do
43
50
  Paymill.should_receive(:request).with(:post, "transactions", valid_attributes).and_return("data" => {})
44
51
  Paymill::Transaction.create(valid_attributes)
45
52
  end
46
53
  end
47
- end
54
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paymill
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-24 00:00:00.000000000 Z
12
+ date: 2012-10-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &2163953000 !ruby/object:Gem::Requirement
16
+ requirement: &2160826620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2163953000
24
+ version_requirements: *2160826620
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &2163924640 !ruby/object:Gem::Requirement
27
+ requirement: &2160795040 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2163924640
35
+ version_requirements: *2160795040
36
36
  description: API wrapper for Paymill.
37
37
  email:
38
38
  - stefan.sprenger@dkd.de
@@ -51,6 +51,7 @@ files:
51
51
  - lib/paymill/client.rb
52
52
  - lib/paymill/credit_card.rb
53
53
  - lib/paymill/offer.rb
54
+ - lib/paymill/operations/all.rb
54
55
  - lib/paymill/operations/create.rb
55
56
  - lib/paymill/operations/delete.rb
56
57
  - lib/paymill/operations/find.rb
@@ -79,7 +80,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
80
  version: '0'
80
81
  segments:
81
82
  - 0
82
- hash: -2942801936658409204
83
+ hash: -3243121354173252569
83
84
  required_rubygems_version: !ruby/object:Gem::Requirement
84
85
  none: false
85
86
  requirements:
@@ -88,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
89
  version: '0'
89
90
  segments:
90
91
  - 0
91
- hash: -2942801936658409204
92
+ hash: -3243121354173252569
92
93
  requirements: []
93
94
  rubyforge_project:
94
95
  rubygems_version: 1.8.10