square.rb 42.1.0.20250416 → 42.2.0.20250521

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77c2bdeadc2cefd90cf043acfde740a8dc81febbf047b997214d402b20a4be26
4
- data.tar.gz: 4d2aa8fbb3c12485fd0edb6fcdafff4723405067df639faf8f82ee7cf2bd0b65
3
+ metadata.gz: 8940a45f80671de60b0b2ef73f31c98b996afb665715c54baef6807a61a19604
4
+ data.tar.gz: 0d20d17799f84a5c33088e970614d244ba6134846784bb9cbfbe60b9b2d9a6c2
5
5
  SHA512:
6
- metadata.gz: 0ffc679938a0656374252391dff967676155325e0727e8b9bff3a685875cd3da09d67da112aa2b2ff0e431c2d7651ea4fe1bcd00fda9925e46a49e4ca73ea47b
7
- data.tar.gz: d630339a17cb8a968550b16ffc9543ade635507914ff7258ddec32668630ac9e03bfd59ad7f98d562b4a4608b7b4e8c13aedd99c4b11bbc2fb9d6fadf6e13b52
6
+ metadata.gz: 63a465723e293824109cddd4fc6769c47c0f2fb687da50c83db7670a97c478f112dc3634c1eeee8c12bd28cffcc0a3a59d881fff88b0f64cf9b02ef49e6516fc
7
+ data.tar.gz: 2a7184e4c7fdd5cb18938c0ac73bfad60f86c3a60c2c8a588e5655af7229d04686b200075341ea7511213ca262a9cde9b720c9c7a84029faca2fcb1755a54bfc
@@ -5,7 +5,7 @@ module Square
5
5
  attr_accessor :config, :http_call_back
6
6
 
7
7
  def self.user_agent
8
- 'Square-Ruby-SDK/42.1.0.20250416 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}'
8
+ 'Square-Ruby-SDK/42.2.0.20250521 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}'
9
9
  end
10
10
 
11
11
  def self.user_agent_parameters
@@ -204,7 +204,9 @@ module Square
204
204
  # the fields to POST for the request. See the corresponding object
205
205
  # definition for field details.
206
206
  # @return [ApiResponse] the complete http response with raw body and status code.
207
+ # @deprecated This endpoint is deprecated at Square API version 2025-05-21. Use create_timecard instead.
207
208
  def create_shift(body:)
209
+ warn 'Endpoint create_shift in LaborApi is deprecated'
208
210
  new_api_call_builder
209
211
  .request(new_request_builder(HttpMethodEnum::POST,
210
212
  '/v2/labor/shifts',
@@ -238,7 +240,9 @@ module Square
238
240
  # the fields to POST for the request. See the corresponding object
239
241
  # definition for field details.
240
242
  # @return [ApiResponse] the complete http response with raw body and status code.
243
+ # @deprecated This endpoint is deprecated at Square API version 2025-05-21. Use search_timecards instead.
241
244
  def search_shifts(body:)
245
+ warn 'Endpoint search_shifts in LaborApi is deprecated'
242
246
  new_api_call_builder
243
247
  .request(new_request_builder(HttpMethodEnum::POST,
244
248
  '/v2/labor/shifts/search',
@@ -259,7 +263,9 @@ module Square
259
263
  # @param [String] id Required parameter: The UUID for the `Shift` being
260
264
  # deleted.
261
265
  # @return [ApiResponse] the complete http response with raw body and status code.
266
+ # @deprecated This endpoint is deprecated at Square API version 2025-05-21. Use delete_timecard instead.
262
267
  def delete_shift(id:)
268
+ warn 'Endpoint delete_shift in LaborApi is deprecated'
263
269
  new_api_call_builder
264
270
  .request(new_request_builder(HttpMethodEnum::DELETE,
265
271
  '/v2/labor/shifts/{id}',
@@ -279,7 +285,9 @@ module Square
279
285
  # @param [String] id Required parameter: The UUID for the `Shift` being
280
286
  # retrieved.
281
287
  # @return [ApiResponse] the complete http response with raw body and status code.
288
+ # @deprecated This endpoint is deprecated at Square API version 2025-05-21. Use retrieve_timecard instead.
282
289
  def get_shift(id:)
290
+ warn 'Endpoint get_shift in LaborApi is deprecated'
283
291
  new_api_call_builder
284
292
  .request(new_request_builder(HttpMethodEnum::GET,
285
293
  '/v2/labor/shifts/{id}',
@@ -308,8 +316,10 @@ module Square
308
316
  # the fields to POST for the request. See the corresponding object
309
317
  # definition for field details.
310
318
  # @return [ApiResponse] the complete http response with raw body and status code.
319
+ # @deprecated This endpoint is deprecated at Square API version 2025-05-21. Use update_timecard instead.
311
320
  def update_shift(id:,
312
321
  body:)
322
+ warn 'Endpoint update_shift in LaborApi is deprecated'
313
323
  new_api_call_builder
314
324
  .request(new_request_builder(HttpMethodEnum::PUT,
315
325
  '/v2/labor/shifts/{id}',
@@ -425,5 +435,291 @@ module Square
425
435
  .convertor(ApiResponse.method(:create)))
426
436
  .execute
427
437
  end
438
+
439
+ # Creates a new `Timecard`.
440
+ # A `Timecard` represents a complete workday for a single team member.
441
+ # You must provide the following values in your request to this
442
+ # endpoint:
443
+ # - `location_id`
444
+ # - `team_member_id`
445
+ # - `start_at`
446
+ # An attempt to create a new `Timecard` can result in a `BAD_REQUEST` error when:
447
+ # - The `status` of the new `Timecard` is `OPEN` and the team member has another
448
+ # timecard with an `OPEN` status.
449
+ # - The `start_at` date is in the future.
450
+ # - The `start_at` or `end_at` date overlaps another timecard for the same team member.
451
+ # - The `Break` instances are set in the request and a break `start_at`
452
+ # is before the `Timecard.start_at`, a break `end_at` is after
453
+ # the `Timecard.end_at`, or both.
454
+ # @param [CreateTimecardRequest] body Required parameter: An object containing
455
+ # the fields to POST for the request. See the corresponding object
456
+ # definition for field details.
457
+ # @return [ApiResponse] the complete http response with raw body and status code.
458
+ def create_timecard(body:)
459
+ new_api_call_builder
460
+ .request(new_request_builder(HttpMethodEnum::POST,
461
+ '/v2/labor/timecards',
462
+ 'default')
463
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
464
+ .body_param(new_parameter(body))
465
+ .header_param(new_parameter('application/json', key: 'accept'))
466
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
467
+ .auth(Single.new('global')))
468
+ .response(new_response_handler
469
+ .deserializer(APIHelper.method(:json_deserialize))
470
+ .is_api_response(true)
471
+ .convertor(ApiResponse.method(:create)))
472
+ .execute
473
+ end
474
+
475
+ # Returns a paginated list of `Timecard` records for a business.
476
+ # The list to be returned can be filtered by:
477
+ # - Location IDs
478
+ # - Team member IDs
479
+ # - Timecard status (`OPEN` or `CLOSED`)
480
+ # - Timecard start
481
+ # - Timecard end
482
+ # - Workday details
483
+ # The list can be sorted by:
484
+ # - `START_AT`
485
+ # - `END_AT`
486
+ # - `CREATED_AT`
487
+ # - `UPDATED_AT`
488
+ # @param [SearchTimecardsRequest] body Required parameter: An object
489
+ # containing the fields to POST for the request. See the corresponding
490
+ # object definition for field details.
491
+ # @return [ApiResponse] the complete http response with raw body and status code.
492
+ def search_timecards(body:)
493
+ new_api_call_builder
494
+ .request(new_request_builder(HttpMethodEnum::POST,
495
+ '/v2/labor/timecards/search',
496
+ 'default')
497
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
498
+ .body_param(new_parameter(body))
499
+ .header_param(new_parameter('application/json', key: 'accept'))
500
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
501
+ .auth(Single.new('global')))
502
+ .response(new_response_handler
503
+ .deserializer(APIHelper.method(:json_deserialize))
504
+ .is_api_response(true)
505
+ .convertor(ApiResponse.method(:create)))
506
+ .execute
507
+ end
508
+
509
+ # Deletes a `Timecard`.
510
+ # @param [String] id Required parameter: The UUID for the `Timecard` being
511
+ # deleted.
512
+ # @return [ApiResponse] the complete http response with raw body and status code.
513
+ def delete_timecard(id:)
514
+ new_api_call_builder
515
+ .request(new_request_builder(HttpMethodEnum::DELETE,
516
+ '/v2/labor/timecards/{id}',
517
+ 'default')
518
+ .template_param(new_parameter(id, key: 'id')
519
+ .should_encode(true))
520
+ .header_param(new_parameter('application/json', key: 'accept'))
521
+ .auth(Single.new('global')))
522
+ .response(new_response_handler
523
+ .deserializer(APIHelper.method(:json_deserialize))
524
+ .is_api_response(true)
525
+ .convertor(ApiResponse.method(:create)))
526
+ .execute
527
+ end
528
+
529
+ # Returns a single `Timecard` specified by `id`.
530
+ # @param [String] id Required parameter: The UUID for the `Timecard` being
531
+ # retrieved.
532
+ # @return [ApiResponse] the complete http response with raw body and status code.
533
+ def retrieve_timecard(id:)
534
+ new_api_call_builder
535
+ .request(new_request_builder(HttpMethodEnum::GET,
536
+ '/v2/labor/timecards/{id}',
537
+ 'default')
538
+ .template_param(new_parameter(id, key: 'id')
539
+ .should_encode(true))
540
+ .header_param(new_parameter('application/json', key: 'accept'))
541
+ .auth(Single.new('global')))
542
+ .response(new_response_handler
543
+ .deserializer(APIHelper.method(:json_deserialize))
544
+ .is_api_response(true)
545
+ .convertor(ApiResponse.method(:create)))
546
+ .execute
547
+ end
548
+
549
+ # Updates an existing `Timecard`.
550
+ # When adding a `Break` to a `Timecard`, any earlier `Break` instances in the
551
+ # `Timecard` have the `end_at` property set to a valid RFC-3339 datetime string.
552
+ # When closing a `Timecard`, all `Break` instances in the `Timecard` must be
553
+ # complete with `end_at` set on each `Break`.
554
+ # @param [String] id Required parameter: The ID of the `Timecard` to update.
555
+ # @param [UpdateTimecardRequest] body Required parameter: An object containing
556
+ # the fields to POST for the request. See the corresponding object
557
+ # definition for field details.
558
+ # @return [ApiResponse] the complete http response with raw body and status code.
559
+ def update_timecard(id:, body:)
560
+ new_api_call_builder
561
+ .request(new_request_builder(HttpMethodEnum::PUT,
562
+ '/v2/labor/timecards/{id}',
563
+ 'default')
564
+ .template_param(new_parameter(id, key: 'id')
565
+ .should_encode(true))
566
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
567
+ .body_param(new_parameter(body))
568
+ .header_param(new_parameter('application/json', key: 'accept'))
569
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
570
+ .auth(Single.new('global')))
571
+ .response(new_response_handler
572
+ .deserializer(APIHelper.method(:json_deserialize))
573
+ .is_api_response(true)
574
+ .convertor(ApiResponse.method(:create)))
575
+ .execute
576
+ end
577
+
578
+ # Creates a scheduled shift by providing draft shift details such as job ID,
579
+ # team member assignment, and start and end times.
580
+ # The following `draft_shift_details` fields are required:
581
+ # - `location_id`
582
+ # - `job_id`
583
+ # - `start_at`
584
+ # - `end_at`
585
+ # @param [CreateScheduledShiftRequest] body Required parameter: An object
586
+ # containing the fields to POST for the request. See the corresponding object
587
+ # definition for field details.
588
+ # @return [ApiResponse] the complete http response with raw body and status code.
589
+ def create_scheduled_shift(body:)
590
+ new_api_call_builder
591
+ .request(new_request_builder(HttpMethodEnum::POST,
592
+ '/v2/labor/scheduled-shifts',
593
+ 'default')
594
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
595
+ .body_param(new_parameter(body))
596
+ .header_param(new_parameter('application/json', key: 'accept'))
597
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
598
+ .auth(Single.new('global')))
599
+ .response(new_response_handler
600
+ .deserializer(APIHelper.method(:json_deserialize))
601
+ .is_api_response(true)
602
+ .convertor(ApiResponse.method(:create)))
603
+ .execute
604
+ end
605
+
606
+ # Publishes 1 - 100 scheduled shifts. This endpoint takes a map of individual publish
607
+ # requests and returns a map of responses. When a scheduled shift is published, Square keeps
608
+ # the `draft_shift_details` field as is and copies it to the `published_shift_details` field.
609
+ # The minimum `start_at` and maximum `end_at` timestamps of all shifts in a
610
+ # `BulkPublishScheduledShifts` request must fall within a two-week period.
611
+ # @param [BulkPublishScheduledShiftsRequest] body Required parameter: An object
612
+ # containing the fields to POST for the request. See the corresponding object
613
+ # definition for field details.
614
+ # @return [ApiResponse] the complete http response with raw body and status code.
615
+ def bulk_publish_scheduled_shifts(body:)
616
+ new_api_call_builder
617
+ .request(new_request_builder(HttpMethodEnum::POST,
618
+ '/v2/labor/scheduled-shifts/bulk-publish',
619
+ 'default')
620
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
621
+ .body_param(new_parameter(body))
622
+ .header_param(new_parameter('application/json', key: 'accept'))
623
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
624
+ .auth(Single.new('global')))
625
+ .response(new_response_handler
626
+ .deserializer(APIHelper.method(:json_deserialize))
627
+ .is_api_response(true)
628
+ .convertor(ApiResponse.method(:create)))
629
+ .execute
630
+ end
631
+
632
+ # Returns a paginated list of scheduled shifts, with optional filter and sort settings.
633
+ # By default, results are sorted by `start_at` in ascending order.
634
+ # @param [SearchScheduledShiftsRequest] body Required parameter: An object
635
+ # containing the fields to POST for the request. See the corresponding object
636
+ # definition for field details.
637
+ # @return [ApiResponse] the complete http response with raw body and status code.
638
+ def search_scheduled_shifts(body:)
639
+ new_api_call_builder
640
+ .request(new_request_builder(HttpMethodEnum::POST,
641
+ '/v2/labor/scheduled-shifts/search',
642
+ 'default')
643
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
644
+ .body_param(new_parameter(body))
645
+ .header_param(new_parameter('application/json', key: 'accept'))
646
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
647
+ .auth(Single.new('global')))
648
+ .response(new_response_handler
649
+ .deserializer(APIHelper.method(:json_deserialize))
650
+ .is_api_response(true)
651
+ .convertor(ApiResponse.method(:create)))
652
+ .execute
653
+ end
654
+
655
+ # Retrieves a scheduled shift by ID.
656
+ # @param [String] id Required parameter: The ID of the scheduled shift to retrieve.
657
+ # @return [ApiResponse] the complete http response with raw body and status code.
658
+ def retrieve_scheduled_shift(id:)
659
+ new_api_call_builder
660
+ .request(new_request_builder(HttpMethodEnum::GET,
661
+ '/v2/labor/scheduled-shifts/{id}',
662
+ 'default')
663
+ .template_param(new_parameter(id, key: 'id')
664
+ .should_encode(true))
665
+ .header_param(new_parameter('application/json', key: 'accept'))
666
+ .auth(Single.new('global')))
667
+ .response(new_response_handler
668
+ .deserializer(APIHelper.method(:json_deserialize))
669
+ .is_api_response(true)
670
+ .convertor(ApiResponse.method(:create)))
671
+ .execute
672
+ end
673
+
674
+ # Updates the draft shift details for a scheduled shift. This endpoint supports
675
+ # sparse updates, so only new, changed, or removed fields are required in the request.
676
+ # You must publish the shift to make updates public.
677
+ # @param [String] id Required parameter: The ID of the scheduled shift to update.
678
+ # @param [UpdateScheduledShiftRequest] body Required parameter: An object containing
679
+ # the fields to POST for the request. See the corresponding object definition for field details.
680
+ # @return [ApiResponse] the complete http response with raw body and status code.
681
+ def update_scheduled_shift(id:, body:)
682
+ new_api_call_builder
683
+ .request(new_request_builder(HttpMethodEnum::PUT,
684
+ '/v2/labor/scheduled-shifts/{id}',
685
+ 'default')
686
+ .template_param(new_parameter(id, key: 'id')
687
+ .should_encode(true))
688
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
689
+ .body_param(new_parameter(body))
690
+ .header_param(new_parameter('application/json', key: 'accept'))
691
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
692
+ .auth(Single.new('global')))
693
+ .response(new_response_handler
694
+ .deserializer(APIHelper.method(:json_deserialize))
695
+ .is_api_response(true)
696
+ .convertor(ApiResponse.method(:create)))
697
+ .execute
698
+ end
699
+
700
+ # Publishes a scheduled shift. When a scheduled shift is published, Square keeps the
701
+ # `draft_shift_details` field as is and copies it to the `published_shift_details` field.
702
+ # @param [String] id Required parameter: The ID of the scheduled shift to publish.
703
+ # @param [PublishScheduledShiftRequest] body Required parameter: An object containing
704
+ # the fields to POST for the request. See the corresponding object definition for field details.
705
+ # @return [ApiResponse] the complete http response with raw body and status code.
706
+ def publish_scheduled_shift(id:, body:)
707
+ new_api_call_builder
708
+ .request(new_request_builder(HttpMethodEnum::POST,
709
+ '/v2/labor/scheduled-shifts/{id}/publish',
710
+ 'default')
711
+ .template_param(new_parameter(id, key: 'id')
712
+ .should_encode(true))
713
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
714
+ .body_param(new_parameter(body))
715
+ .header_param(new_parameter('application/json', key: 'accept'))
716
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
717
+ .auth(Single.new('global')))
718
+ .response(new_response_handler
719
+ .deserializer(APIHelper.method(:json_deserialize))
720
+ .is_api_response(true)
721
+ .convertor(ApiResponse.method(:create)))
722
+ .execute
723
+ end
428
724
  end
429
725
  end
data/lib/square/client.rb CHANGED
@@ -5,7 +5,7 @@ module Square
5
5
  attr_reader :config, :auth_managers
6
6
 
7
7
  def sdk_version
8
- '42.1.0.20250416'
8
+ '42.2.0.20250521'
9
9
  end
10
10
 
11
11
  def square_version
@@ -274,7 +274,7 @@ module Square
274
274
  retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
275
275
  retry_methods: %i[get put], http_callback: nil, environment: 'production',
276
276
  custom_url: 'https://connect.squareup.com', access_token: nil,
277
- bearer_auth_credentials: nil, square_version: '2025-04-16',
277
+ bearer_auth_credentials: nil, square_version: '2025-05-21',
278
278
  user_agent_detail: '', additional_headers: {}, config: nil
279
279
  )
280
280
  @config = if config.nil?
@@ -24,7 +24,7 @@ module Square
24
24
  retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
25
25
  retry_methods: %i[get put], http_callback: nil, environment: 'production',
26
26
  custom_url: 'https://connect.squareup.com', access_token: nil,
27
- bearer_auth_credentials: nil, square_version: '2025-04-16',
27
+ bearer_auth_credentials: nil, square_version: '2025-05-21',
28
28
  user_agent_detail: '', additional_headers: {}
29
29
  )
30
30
 
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  require_relative 'api_test_base'
4
2
 
5
3
  class LaborApiTests < ApiTestBase
@@ -68,4 +66,17 @@ class LaborApiTests < ApiTestBase
68
66
  assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
69
67
  end
70
68
 
69
+ def test_search_timecards()
70
+ # Perform the API call through the SDK function
71
+ result = @controller.search_timecards(body: {limit: 100})
72
+
73
+ # Test response code
74
+ assert_equal(200, @response_catcher.response.status_code)
75
+
76
+ # Test headers
77
+ expected_headers = {}
78
+ expected_headers['content-type'] = 'application/json'
79
+
80
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
81
+ end
71
82
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: square.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 42.1.0.20250416
4
+ version: 42.2.0.20250521
5
5
  platform: ruby
6
6
  authors:
7
7
  - Square Developer Platform
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-16 00:00:00.000000000 Z
11
+ date: 2025-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apimatic_core_interfaces