@@ -310,13 +310,12 @@ definitions:
310
310
customer_usage :
311
311
type : DeclarativeStream
312
312
name : customer_usage
313
- primary_key :
314
- - lago_invoice_id
315
313
retriever :
316
314
type : SimpleRetriever
317
315
requester :
318
316
$ref : " #/definitions/base_requester"
319
- path : /customers/{{stream_slice.customer_external_id}}/current_usage
317
+ path : >-
318
+ /customers/{{stream_slice.customer_external_id}}/current_usage?external_subscription_id={{stream_slice.external_subscription_id}}
320
319
http_method : GET
321
320
error_handler :
322
321
type : CompositeErrorHandler
@@ -336,13 +335,31 @@ definitions:
336
335
field_path :
337
336
- customer_usage
338
337
partition_router :
339
- type : SubstreamPartitionRouter
340
- parent_stream_configs :
341
- - type : ParentStreamConfig
342
- parent_key : external_id
343
- partition_field : customer_external_id
344
- stream :
345
- $ref : " #/definitions/streams/customers"
338
+ - type : SubstreamPartitionRouter
339
+ parent_stream_configs :
340
+ - type : ParentStreamConfig
341
+ parent_key : external_customer_id
342
+ partition_field : customer_external_id
343
+ stream :
344
+ $ref : " #/definitions/streams/subscriptions"
345
+ - type : SubstreamPartitionRouter
346
+ parent_stream_configs :
347
+ - type : ParentStreamConfig
348
+ parent_key : external_id
349
+ partition_field : external_subscription_id
350
+ stream :
351
+ $ref : " #/definitions/streams/subscriptions"
352
+ transformations :
353
+ - type : AddFields
354
+ fields :
355
+ - path :
356
+ - customer_id
357
+ value : " {{stream_slice.customer_external_id}}"
358
+ - type : AddFields
359
+ fields :
360
+ - path :
361
+ - subscription_id
362
+ value : " {{stream_slice.external_subscription_id}}"
346
363
schema_loader :
347
364
type : InlineSchemaLoader
348
365
schema :
@@ -383,6 +400,80 @@ definitions:
383
400
type : InlineSchemaLoader
384
401
schema :
385
402
$ref : " #/schemas/fees"
403
+ customer_usage_past :
404
+ type : DeclarativeStream
405
+ name : customer_usage_past
406
+ primary_key :
407
+ - lago_invoice_id
408
+ retriever :
409
+ type : SimpleRetriever
410
+ requester :
411
+ $ref : " #/definitions/base_requester"
412
+ path : >-
413
+ /customers/{{stream_slice.customer_external_id}}/past_usage?external_subscription_id={{stream_slice.external_subscription_id}}
414
+ http_method : GET
415
+ error_handler :
416
+ type : CompositeErrorHandler
417
+ error_handlers :
418
+ - type : DefaultErrorHandler
419
+ response_filters :
420
+ - type : HttpResponseFilter
421
+ action : IGNORE
422
+ predicate : >-
423
+ {{response.status == 405 and response.code ==
424
+ 'no_active_subscription' }}
425
+ http_codes : []
426
+ record_selector :
427
+ type : RecordSelector
428
+ extractor :
429
+ type : DpathExtractor
430
+ field_path :
431
+ - usage_periods
432
+ paginator :
433
+ type : DefaultPaginator
434
+ page_token_option :
435
+ type : RequestOption
436
+ inject_into : request_parameter
437
+ field_name : page
438
+ page_size_option :
439
+ type : RequestOption
440
+ inject_into : request_parameter
441
+ field_name : per_page
442
+ pagination_strategy :
443
+ type : CursorPagination
444
+ page_size : 100
445
+ cursor_value : " {{ response.meta.next_page }}"
446
+ stop_condition : " {{ response.meta.next_page is none}}"
447
+ partition_router :
448
+ - type : SubstreamPartitionRouter
449
+ parent_stream_configs :
450
+ - type : ParentStreamConfig
451
+ parent_key : external_customer_id
452
+ partition_field : customer_external_id
453
+ stream :
454
+ $ref : " #/definitions/streams/subscriptions"
455
+ - type : SubstreamPartitionRouter
456
+ parent_stream_configs :
457
+ - type : ParentStreamConfig
458
+ parent_key : external_id
459
+ partition_field : external_subscription_id
460
+ stream :
461
+ $ref : " #/definitions/streams/subscriptions"
462
+ transformations :
463
+ - type : AddFields
464
+ fields :
465
+ - path :
466
+ - customer_id
467
+ value : " {{stream_slice.customer_external_id}}"
468
+ - type : AddFields
469
+ fields :
470
+ - path :
471
+ - subscription_id
472
+ value : " {{stream_slice.external_subscription_id}}"
473
+ schema_loader :
474
+ type : InlineSchemaLoader
475
+ schema :
476
+ $ref : " #/schemas/customer_usage_past"
386
477
base_requester :
387
478
type : HttpRequester
388
479
url_base : " {{ config.get('api_url', 'https://api.getlago.com/api/v1') }}"
@@ -401,6 +492,7 @@ streams:
401
492
- $ref : " #/definitions/streams/wallets"
402
493
- $ref : " #/definitions/streams/customer_usage"
403
494
- $ref : " #/definitions/streams/fees"
495
+ - $ref : " #/definitions/streams/customer_usage_past"
404
496
405
497
spec :
406
498
type : Spec
@@ -1373,6 +1465,44 @@ schemas:
1373
1465
type :
1374
1466
- " null"
1375
1467
- integer
1468
+ filters :
1469
+ type :
1470
+ - array
1471
+ - " null"
1472
+ items :
1473
+ type :
1474
+ - object
1475
+ - " null"
1476
+ properties :
1477
+ amount_cents :
1478
+ type :
1479
+ - number
1480
+ - " null"
1481
+ events_count :
1482
+ type :
1483
+ - number
1484
+ - " null"
1485
+ units :
1486
+ type :
1487
+ - string
1488
+ - " null"
1489
+ values :
1490
+ type :
1491
+ - object
1492
+ - " null"
1493
+ properties :
1494
+ card_type :
1495
+ type :
1496
+ - array
1497
+ - " null"
1498
+ items :
1499
+ type :
1500
+ - string
1501
+ - " null"
1502
+ grouped_usage :
1503
+ type :
1504
+ - array
1505
+ - " null"
1376
1506
groups :
1377
1507
type :
1378
1508
- " null"
@@ -1414,6 +1544,10 @@ schemas:
1414
1544
type :
1415
1545
- " null"
1416
1546
- string
1547
+ customer_id :
1548
+ type :
1549
+ - string
1550
+ - " null"
1417
1551
from_datetime :
1418
1552
type :
1419
1553
- " null"
@@ -1426,6 +1560,10 @@ schemas:
1426
1560
type :
1427
1561
- " null"
1428
1562
- string
1563
+ subscription_id :
1564
+ type :
1565
+ - string
1566
+ - " null"
1429
1567
taxes_amount_cents :
1430
1568
type :
1431
1569
- " null"
@@ -1799,3 +1937,178 @@ schemas:
1799
1937
type :
1800
1938
- " null"
1801
1939
- string
1940
+ customer_usage_past :
1941
+ type : object
1942
+ $schema : http://json-schema.org/schema#
1943
+ additionalProperties : true
1944
+ properties :
1945
+ amount_cents :
1946
+ type :
1947
+ - number
1948
+ - " null"
1949
+ charges_usage :
1950
+ type :
1951
+ - array
1952
+ - " null"
1953
+ items :
1954
+ type :
1955
+ - object
1956
+ - " null"
1957
+ properties :
1958
+ amount_cents :
1959
+ type :
1960
+ - number
1961
+ - " null"
1962
+ amount_currency :
1963
+ type :
1964
+ - string
1965
+ - " null"
1966
+ billable_metric :
1967
+ type :
1968
+ - object
1969
+ - " null"
1970
+ properties :
1971
+ aggregation_type :
1972
+ type :
1973
+ - string
1974
+ - " null"
1975
+ code :
1976
+ type :
1977
+ - string
1978
+ - " null"
1979
+ lago_id :
1980
+ type :
1981
+ - string
1982
+ - " null"
1983
+ name :
1984
+ type :
1985
+ - string
1986
+ - " null"
1987
+ charge :
1988
+ type :
1989
+ - object
1990
+ - " null"
1991
+ properties :
1992
+ charge_model :
1993
+ type :
1994
+ - string
1995
+ - " null"
1996
+ lago_id :
1997
+ type :
1998
+ - string
1999
+ - " null"
2000
+ events_count :
2001
+ type :
2002
+ - number
2003
+ - " null"
2004
+ filters :
2005
+ type :
2006
+ - array
2007
+ - " null"
2008
+ items :
2009
+ type :
2010
+ - object
2011
+ - " null"
2012
+ properties :
2013
+ amount_cents :
2014
+ type :
2015
+ - number
2016
+ - " null"
2017
+ events_count :
2018
+ type :
2019
+ - number
2020
+ - " null"
2021
+ units :
2022
+ type :
2023
+ - string
2024
+ - " null"
2025
+ values :
2026
+ type :
2027
+ - object
2028
+ - " null"
2029
+ properties :
2030
+ card_type :
2031
+ type :
2032
+ - array
2033
+ - " null"
2034
+ items :
2035
+ type :
2036
+ - string
2037
+ - " null"
2038
+ grouped_usage :
2039
+ type :
2040
+ - array
2041
+ - " null"
2042
+ groups :
2043
+ type :
2044
+ - array
2045
+ - " null"
2046
+ items :
2047
+ type :
2048
+ - object
2049
+ - " null"
2050
+ properties :
2051
+ amount_cents :
2052
+ type :
2053
+ - number
2054
+ - " null"
2055
+ events_count :
2056
+ type :
2057
+ - number
2058
+ - " null"
2059
+ key :
2060
+ type :
2061
+ - string
2062
+ - " null"
2063
+ lago_id :
2064
+ type :
2065
+ - string
2066
+ - " null"
2067
+ units :
2068
+ type :
2069
+ - string
2070
+ - " null"
2071
+ value :
2072
+ type :
2073
+ - string
2074
+ - " null"
2075
+ units :
2076
+ type :
2077
+ - string
2078
+ - " null"
2079
+ currency :
2080
+ type :
2081
+ - string
2082
+ - " null"
2083
+ customer_id :
2084
+ type :
2085
+ - string
2086
+ - " null"
2087
+ from_datetime :
2088
+ type :
2089
+ - string
2090
+ - " null"
2091
+ issuing_date :
2092
+ type :
2093
+ - string
2094
+ - " null"
2095
+ lago_invoice_id :
2096
+ type : string
2097
+ subscription_id :
2098
+ type :
2099
+ - string
2100
+ - " null"
2101
+ taxes_amount_cents :
2102
+ type :
2103
+ - number
2104
+ - " null"
2105
+ to_datetime :
2106
+ type :
2107
+ - string
2108
+ - " null"
2109
+ total_amount_cents :
2110
+ type :
2111
+ - number
2112
+ - " null"
2113
+ required :
2114
+ - lago_invoice_id
0 commit comments