balanced 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
data/CONTRIBUTORS CHANGED
@@ -3,3 +3,4 @@ Marshall Jones
3
3
  Alex Notov
4
4
  Josh Deeden
5
5
  Ivan Lyutov
6
+ Alex Sharp
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Online Marketplace Payments
4
4
 
5
+ [![Build Status](https://secure.travis-ci.org/balanced/balanced-ruby.png)](http://travis-ci.org/balanced/balanced-ruby)
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
@@ -25,9 +27,11 @@ See https://www.balancedpayments.com/docs/ruby for tutorials and documentation.
25
27
 
26
28
  1. Fork it
27
29
  2. Create your feature branch (`git checkout -b my-new-feature`)
28
- 3. Commit your changes (`git commit -am 'Add some feature'`)
29
- 4. Push to the branch (`git push origin my-new-feature`)
30
- 5. Create new Pull Request
30
+ 3. Write your code **and unit tests**
31
+ 4. Ensure all tests still pass (`bundle exec rspec`)
32
+ 5. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 6. Push to the branch (`git push origin my-new-feature`)
34
+ 7. Create new pull request
31
35
 
32
36
 
33
37
  ### Specs
@@ -54,5 +58,7 @@ spec/cassettes. To clear them and regenerate:
54
58
  ### Building Documentation
55
59
 
56
60
  Documentation is build using YARD - http://rubydoc.info/docs/yard
57
-
58
- yard doc -e doc/balanced_plugin.rb -p doc/balanced_templates/ 'lib/**/resources.rb' --one-file
61
+
62
+ export AMAZON_ACCESS_KEY_ID='xxx'
63
+ export AMAZON_SECRET_ACCESS_KEY='yyy'
64
+ ./upload_docs.rb
data/balanced.gemspec CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |gem|
18
18
  gem.add_development_dependency("vcr", '~> 2.2.0')
19
19
  gem.add_development_dependency("guard", '~> 1.1.1')
20
20
  gem.add_development_dependency("guard-rspec", '~> 1.0.0')
21
+ gem.add_development_dependency("yard")
22
+ gem.add_development_dependency("ruby-debug19")
21
23
 
22
24
  gem.files = `git ls-files`.split($\)
23
25
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -7,6 +7,18 @@ module Balanced
7
7
  class Account
8
8
  include Balanced::Resource
9
9
 
10
+ class MoreInformationRequiredError < StandardError
11
+ attr_reader :response
12
+
13
+ def initialize(response)
14
+ @response = response
15
+ end
16
+
17
+ def redirect_uri
18
+ response.headers['Location']
19
+ end
20
+ end
21
+
10
22
  def initialize attributes = {}
11
23
  Balanced::Utils.stringify_keys! attributes
12
24
  unless attributes.has_key? 'uri'
@@ -15,8 +27,16 @@ module Balanced
15
27
  super attributes
16
28
  end
17
29
 
30
+ def save
31
+ the_response = super
32
+ if response.status == 300
33
+ raise MoreInformationRequiredError, response
34
+ end
35
+ the_response
36
+ end
37
+
18
38
  # Returns a new Debit that represents a flow of money from this
19
- # Account to your Marketplace.
39
+ # Account to your Marketplace's escrow account.
20
40
  #
21
41
  # @return [Debit]
22
42
  def debit (amount=nil,
@@ -15,7 +15,7 @@ module Balanced
15
15
  super attributes
16
16
  end
17
17
 
18
- # Creates a Debit of funds from this BankAccount to your Marketplace.
18
+ # Creates a Debit of funds from this BankAccount to your Marketplace's escrow account.
19
19
  #
20
20
  # @param [String] appears_on_statement_as If nil then Balanced will use
21
21
  # the +domain_name+ property from your Marketplace.
@@ -24,7 +24,7 @@ module Balanced
24
24
  self.account.debit(amount, appears_on_statement_as, meta, description, self.uri)
25
25
  end
26
26
 
27
- # Creates a Credit of funds from your Marketplace to this Account.
27
+ # Creates a Credit of funds from your Marketplace's escrow account to this Account.
28
28
  #
29
29
  # @return [Credit]
30
30
  def credit amount, description=nil, meta={}
@@ -13,7 +13,7 @@ module Balanced
13
13
  super attributes
14
14
  end
15
15
 
16
- # Creates a Debit of funds from this Card to your Marketplace.
16
+ # Creates a Debit of funds from this Card to your Marketplace's escrow account.
17
17
  #
18
18
  # If +appears_on_statement_as+ is nil, then Balanced will use the
19
19
  # +domain_name+ property from your Marketplace.
@@ -1,6 +1,6 @@
1
1
  module Balanced
2
- # A Credit represents a transfer of funds from your Marketplace to a
3
- # Merchant's Account within your Marketplace.
2
+ # A Credit represents a transfer of funds from your Marketplace's
3
+ # escrow account to a Merchant's Account within your Marketplace.
4
4
  #
5
5
  # By default, a Credit is sent to the most recently added funding
6
6
  # destination associated with an Account. You may specify a specific
@@ -1,6 +1,6 @@
1
1
  module Balanced
2
2
  # A Debit represents a transfer of funds from a buyer's Account to your
3
- # Marketplace.
3
+ # Marketplace's escrow account.
4
4
  #
5
5
  # A Debit may be created directly, or it will be created as a side-effect
6
6
  # of capturing a Hold. If you create a Debit directly it will implicitly
@@ -2,7 +2,7 @@ module Balanced
2
2
  # A Refund represents a reversal of funds from a Debit. A Debit can have
3
3
  # many Refunds associated with it up to the total amount of the original
4
4
  # Debit. Funds are returned to your Marketplace's Merchant Account
5
- # proportional to the amoun of the Refund.
5
+ # proportional to the amount of the Refund.
6
6
  #
7
7
  class Refund
8
8
  include Balanced::Resource
@@ -20,18 +20,23 @@ module Balanced
20
20
  elsif !Balanced.is_collection(uri)
21
21
  method = :put
22
22
  end
23
- response = Balanced.send(method, uri, self.attributes)
24
- reload response
23
+ @response = Balanced.send(method, uri, self.attributes)
24
+ reload @response
25
25
  end
26
26
 
27
+ def response
28
+ @response
29
+ end
30
+ private :response
31
+
27
32
  def destroy
28
33
  Balanced.delete @attributes[:uri]
29
34
  end
30
35
 
31
- def reload response = nil
32
- if response
33
- return if response.body.to_s.length.zero?
34
- fresh = self.class.construct_from_response response.body
36
+ def reload the_response = nil
37
+ if the_response
38
+ return if the_response.body.to_s.length.zero?
39
+ fresh = self.class.construct_from_response the_response.body
35
40
  else
36
41
  fresh = self.find(@attributes[:uri])
37
42
  end
@@ -77,6 +82,7 @@ module Balanced
77
82
 
78
83
  def construct_from_response payload
79
84
  payload = Balanced::Utils.hash_with_indifferent_read_access payload
85
+ return payload if payload[:uri].nil?
80
86
  klass = Balanced.from_uri(payload[:uri])
81
87
  instance = klass.new payload
82
88
  payload.each do |name, value|
@@ -1,3 +1,3 @@
1
1
  module Balanced
2
- VERSION = '0.3.2'
2
+ VERSION = '0.3.3'
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'bundler/setup'
3
-
3
+ require 'ruby-debug'
4
4
  require 'balanced'
5
5
  require 'vcr'
6
6
 
data/upload_docs.rb ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'aws/s3'
4
+ require 'yard'
5
+
6
+ # cheap
7
+ args = [
8
+ 'doc',
9
+ '-e',
10
+ 'doc/balanced_plugin.rb',
11
+ '-p',
12
+ 'doc/balanced_templates/',
13
+ '--one-file',
14
+ '--query',
15
+ "object.to_s != 'Balanced::Account::MoreInformationRequiredError'",
16
+ 'lib/balanced/resources/account.rb',
17
+ 'lib/balanced/resources/api_key.rb',
18
+ 'lib/balanced/resources/bank_account.rb',
19
+ 'lib/balanced/resources/card.rb',
20
+ 'lib/balanced/resources/credit.rb',
21
+ 'lib/balanced/resources/debit.rb',
22
+ 'lib/balanced/resources/hold.rb',
23
+ 'lib/balanced/resources/marketplace.rb',
24
+ 'lib/balanced/resources/merchant.rb',
25
+ 'lib/balanced/resources/transaction.rb'
26
+ ]
27
+
28
+ YARD::CLI::CommandParser.run(*args)
29
+
30
+ AWS::S3::Base.establish_connection!(
31
+ :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
32
+ :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
33
+ )
34
+
35
+ puts AWS::S3::S3Object.store('docs/ruby_api_reference.html',
36
+ open('doc/index.html'),
37
+ 'justice.web',
38
+ :access => :public_read
39
+ )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: balanced
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-18 00:00:00.000000000 Z
12
+ date: 2012-06-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -107,6 +107,38 @@ dependencies:
107
107
  - - ~>
108
108
  - !ruby/object:Gem::Version
109
109
  version: 1.0.0
110
+ - !ruby/object:Gem::Dependency
111
+ name: yard
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: ruby-debug19
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
110
142
  description: ! "Balanced is the payments platform for marketplaces.\n Integrate
111
143
  a payments experience just like Amazon for your marketplace.\n Forget about dealing
112
144
  with banking systems, compliance, fraud, and security.\n "
@@ -119,6 +151,7 @@ files:
119
151
  - .gitignore
120
152
  - .rbenv-version
121
153
  - .rspec
154
+ - .travis.yml
122
155
  - CONTRIBUTORS
123
156
  - Gemfile
124
157
  - Guardfile
@@ -162,6 +195,7 @@ files:
162
195
  - spec/client_spec.rb
163
196
  - spec/spec_helper.rb
164
197
  - spec/utils_spec.rb
198
+ - upload_docs.rb
165
199
  homepage: https://balancedpayments.com
166
200
  licenses: []
167
201
  post_install_message: