@@ -154,17 +154,7 @@ def request(self, method, uri, params=None):
154
154
return data
155
155
156
156
157
- class OrderMixin :
158
-
159
- order_id = Column (Text , primary_key = True )
160
- reference = Column (Text , nullable = False , unique = True )
161
- invoice = Column (Text , nullable = False )
162
- changed = Column (DateTime (timezone = True ), nullable = False )
163
- is_complete = Column (Boolean , default = False , nullable = False )
164
-
165
- @declared_attr
166
- def data (cls ):
167
- return deferred (Column (JSON , nullable = False ))
157
+ class OrderMethodsMixin :
168
158
169
159
def synchronize (self ):
170
160
data = current_app .extensions ['fastspring' ].fetch_order (self .order_id )
@@ -188,21 +178,21 @@ def subscription_item(self):
188
178
return candidates [0 ]
189
179
190
180
191
- class SubscriptionMixin :
181
+ class OrderMixin ( OrderMethodsMixin ) :
192
182
193
- subscription_id = Column (Text , primary_key = True )
194
- begin = Column (DateTime (timezone = True ), nullable = False )
183
+ order_id = Column (Text , primary_key = True )
184
+ reference = Column (Text , nullable = False , unique = True )
185
+ invoice = Column (Text , nullable = False )
195
186
changed = Column (DateTime (timezone = True ), nullable = False )
196
- next_event = Column (DateTime (timezone = True ))
197
- next_charge = Column (DateTime (timezone = True ))
198
- end = Column (DateTime (timezone = True ))
199
- is_active = Column (Boolean , nullable = False )
200
- state = Column (Text , nullable = False )
187
+ is_complete = Column (Boolean , default = False , nullable = False )
201
188
202
189
@declared_attr
203
190
def data (cls ):
204
191
return deferred (Column (JSON , nullable = False ))
205
192
193
+
194
+ class SubscriptionMethodsMixin :
195
+
206
196
def synchronize (self ):
207
197
data = current_app .extensions ['fastspring' ].fetch_subscription (self .subscription_id ) # noqa
208
198
changed = milliseconds_to_datetime (data ['changed' ])
@@ -223,6 +213,22 @@ def cancel(self, immediately=True):
223
213
self .subscription_id , immediately = immediately )
224
214
225
215
216
+ class SubscriptionMixin (SubscriptionMethodsMixin ):
217
+
218
+ subscription_id = Column (Text , primary_key = True )
219
+ begin = Column (DateTime (timezone = True ), nullable = False )
220
+ changed = Column (DateTime (timezone = True ), nullable = False )
221
+ next_event = Column (DateTime (timezone = True ))
222
+ next_charge = Column (DateTime (timezone = True ))
223
+ end = Column (DateTime (timezone = True ))
224
+ is_active = Column (Boolean , nullable = False )
225
+ state = Column (Text , nullable = False )
226
+
227
+ @declared_attr
228
+ def data (cls ):
229
+ return deferred (Column (JSON , nullable = False ))
230
+
231
+
226
232
class APIError (Exception ):
227
233
228
234
def __init__ (self , response ):
0 commit comments