stripe 1.5.25 → 1.5.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/stripe.rb +34 -16
  2. data/lib/stripe/version.rb +1 -1
  3. metadata +5 -5
@@ -429,6 +429,7 @@ module Stripe
429
429
  include Stripe::APIOperations::Create
430
430
  include Stripe::APIOperations::Delete
431
431
  include Stripe::APIOperations::List
432
+ include Stripe::APIOperations::Update
432
433
  end
433
434
 
434
435
  class Coupon < APIResource
@@ -441,14 +442,31 @@ module Stripe
441
442
  include Stripe::APIOperations::Create
442
443
  end
443
444
 
444
- class StripeError < StandardError; end
445
+ class Event < APIResource
446
+ include Stripe::APIOperations::List
447
+ end
448
+
449
+ class StripeError < StandardError
450
+ attr_reader :message
451
+ attr_reader :http_status
452
+ attr_reader :http_body
453
+ attr_reader :json_body
454
+
455
+ def initialize(message=nil, http_status=nil, http_body=nil, json_body=nil)
456
+ @message = message
457
+ @http_status = http_status
458
+ @http_body = http_body
459
+ @json_body = json_body
460
+ end
461
+ end
462
+
445
463
  class APIError < StripeError; end
446
464
  class APIConnectionError < StripeError; end
447
465
  class CardError < StripeError
448
466
  attr_reader :param, :code
449
467
 
450
- def initialize(message, param, code)
451
- super(message)
468
+ def initialize(message, param, code, http_status=nil, http_body=nil, json_body=nil)
469
+ super(message, http_status, http_body, json_body)
452
470
  @param = param
453
471
  @code = code
454
472
  end
@@ -456,8 +474,8 @@ module Stripe
456
474
  class InvalidRequestError < StripeError
457
475
  attr_accessor :param
458
476
 
459
- def initialize(message, param)
460
- super(message)
477
+ def initialize(message, param, http_status=nil, http_body=nil, json_body=nil)
478
+ super(message, http_status, http_body, json_body)
461
479
  @param = param
462
480
  end
463
481
  end
@@ -567,7 +585,7 @@ module Stripe
567
585
  # some library out there that makes symbolize_names not work.
568
586
  resp = JSON.parse(rbody)
569
587
  rescue JSON::ParserError
570
- raise APIError.new("Invalid response object from API: #{rbody.inspect} (HTTP response code was #{rcode})")
588
+ raise APIError.new("Invalid response object from API: #{rbody.inspect} (HTTP response code was #{rcode})", rcode, rbody)
571
589
  end
572
590
 
573
591
  resp = Util.symbolize_names(resp)
@@ -584,27 +602,27 @@ module Stripe
584
602
  begin
585
603
  error_obj = JSON.parse(rbody)
586
604
  error_obj = Util.symbolize_names(error_obj)
587
- error = error_obj[:error] or raise StripeError.new
605
+ error = error_obj[:error] or raise StripeError.new # escape from parsing
588
606
  rescue JSON::ParserError, StripeError
589
- raise APIError.new("Invalid response object from API: #{rbody.inspect} (HTTP response code was #{rcode})")
607
+ raise APIError.new("Invalid response object from API: #{rbody.inspect} (HTTP response code was #{rcode})", rcode, rbody)
590
608
  end
591
609
 
592
610
  case rcode
593
611
  when 400, 404 then
594
- raise invalid_request_error(error)
612
+ raise invalid_request_error(error, rcode, rbody, error_obj)
595
613
  when 401
596
- raise authentication_error(error)
614
+ raise authentication_error(error, rcode, rbody, error_obj)
597
615
  when 402
598
- raise card_error(error)
616
+ raise card_error(error, rcode, rbody, error_obj)
599
617
  else
600
- raise api_error(error)
618
+ raise api_error(error, rcode, rbody, error_obj)
601
619
  end
602
620
  end
603
621
 
604
- def self.invalid_request_error(error); InvalidRequestError.new(error[:message], error[:param]); end
605
- def self.authentication_error(error); AuthenticationError.new(error[:message]); end
606
- def self.card_error(error); CardError.new(error[:message], error[:param], error[:code]); end
607
- def self.api_error(error); APIError.new(error[:message]); end
622
+ def self.invalid_request_error(error, rcode, rbody, error_obj); InvalidRequestError.new(error[:message], error[:param], rcode, rbody, error_obj); end
623
+ def self.authentication_error(error, rcode, rbody, error_obj); AuthenticationError.new(error[:message], rcode, rbody, error_obj); end
624
+ def self.card_error(error, rcode, rbody, error_obj); CardError.new(error[:message], error[:param], error[:code], rcode, rbody, error_obj); end
625
+ def self.api_error(error, rcode, rbody, error_obj); APIError.new(error[:message], rcode, rbody, error_obj); end
608
626
 
609
627
  def self.handle_restclient_error(e)
610
628
  case e
@@ -1,3 +1,3 @@
1
1
  module Stripe
2
- VERSION = '1.5.25'
2
+ VERSION = '1.5.26'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe
3
3
  version: !ruby/object:Gem::Version
4
- hash: 49
4
+ hash: 55
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 5
9
- - 25
10
- version: 1.5.25
9
+ - 26
10
+ version: 1.5.26
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ross Boucher
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-12-07 00:00:00 Z
19
+ date: 2012-01-27 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: rest-client
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  requirements: []
125
125
 
126
126
  rubyforge_project:
127
- rubygems_version: 1.8.11
127
+ rubygems_version: 1.8.8
128
128
  signing_key:
129
129
  specification_version: 3
130
130
  summary: Ruby bindings for the Stripe API