@@ -6,12 +6,14 @@ class Invoice < APIResource
6
6
include Iugu ::APIDelete
7
7
8
8
def customer
9
- return false unless @attributes [ " customer_id" ]
10
- Customer . fetch @attributes [ " customer_id" ]
9
+ return false unless @attributes [ ' customer_id' ]
10
+ Customer . fetch @attributes [ ' customer_id' ]
11
11
end
12
12
13
13
def cancel
14
- copy Iugu ::Factory . create_from_response ( self . class . object_type , APIRequest . request ( "PUT" , "#{ self . class . url ( self . id ) } /cancel" ) )
14
+ copy Iugu ::Factory . create_from_response ( self . class . object_type ,
15
+ APIRequest . request ( 'PUT' ,
16
+ "#{ self . class . url ( self . id ) } /cancel" ) )
15
17
self . errors = nil
16
18
true
17
19
rescue Iugu ::RequestWithErrors => ex
@@ -20,16 +22,21 @@ def cancel
20
22
end
21
23
22
24
def refund
23
- copy Iugu ::Factory . create_from_response ( self . class . object_type , APIRequest . request ( "POST" , "#{ self . class . url ( self . id ) } /refund" ) )
25
+ copy Iugu ::Factory . create_from_response ( self . class . object_type ,
26
+ APIRequest . request ( 'POST' ,
27
+ "#{ self . class . url ( self . id ) } /refund" ) )
24
28
self . errors = nil
25
29
true
26
30
rescue Iugu ::RequestWithErrors => ex
27
31
self . errors = ex . errors
28
32
false
29
33
end
30
34
31
- def duplicate ( due_date )
32
- copy Iugu ::Factory . create_from_response ( self . class . object_type , APIRequest . request ( "POST" , "#{ self . class . url ( self . id ) } /duplicate" , { due_date : due_date , ignore_canceled_email : true } ) )
35
+ def duplicate ( attributes = { } )
36
+ copy Iugu ::Factory . create_from_response ( self . class . object_type ,
37
+ APIRequest . request ( 'POST' ,
38
+ "#{ self . class . url ( self . id ) } /duplicate" ,
39
+ attributes ) )
33
40
self . errors = nil
34
41
true
35
42
rescue Iugu ::RequestWithErrors => ex
0 commit comments