@@ -791,7 +791,13 @@ def url(self) -> str:
791791
792792
793793class InvoiceState (Enum ):
794- cancelled , failed , paid , unpaid , pending , finalized = range (6 )
794+ CANCELLED = "cancelled"
795+ FAILED = "failed"
796+ PAID = "paid"
797+ UNPAID = "unpaid"
798+ PENDING = "pending"
799+ FINALIZED = "finalized"
800+ OPEN = "open"
795801
796802
797803class Invoices (DefaultClient ):
@@ -829,7 +835,7 @@ def state_update(self, entity_id: int, state: InvoiceState, **kwargs):
829835 cancelled, failed, paid, unpaid, pending, finalized
830836 """
831837 log .info (f"[Invoice] state changed for invoice ({ entity_id } ): { state } " )
832- params = dict (state = state .name )
838+ params = dict (state = state .value )
833839 url = self ._entity_url (entity_id ) + '/state'
834840 response = self .rest .put (url = url , json = params , ** kwargs )
835841 instance = self ._create_instance (response = response )
@@ -838,7 +844,7 @@ def state_update(self, entity_id: int, state: InvoiceState, **kwargs):
838844 def charge (self , entity_id : int ):
839845 """Charge an Invoice."""
840846 log .info (f"[Invoice] charge invoice ({ entity_id } )" )
841- url = self ._entity_url (entity_id ) + '/state '
847+ url = self ._entity_url (entity_id ) + '/charge '
842848 response = self .rest .post (url )
843849 instance = self ._create_instance (response = response )
844850 return instance
@@ -1323,8 +1329,8 @@ def __init__(self, entity_name='friendly_id', **kwargs):
13231329 def line_items (self ) -> LineItems :
13241330 return LineItems (parent = self , instance_klass = LineItem )
13251331
1326- def state_update (self , state : InvoiceState , ** kwargs ):
1327- return self .client .state_update (entity_id = self .entity_id , state = state , ** kwargs )
1332+ def state_update (self , state : InvoiceState ):
1333+ return self .client .state_update (entity_id = self .entity_id , state = state )
13281334
1329- def charge (self , ** kwargs ):
1330- return self .client .charge (entity_id = self .entity_id , ** kwargs )
1335+ def charge (self ):
1336+ return self .client .charge (entity_id = self .entity_id )
0 commit comments