Class: Square::Bookings::TeamMemberProfiles::Client
- Inherits:
-
Object
- Object
- Square::Bookings::TeamMemberProfiles::Client
- Defined in:
- lib/square/bookings/team_member_profiles/client.rb
Instance Method Summary collapse
-
#get(request_options: {}, **params) ⇒ Square::Types::GetTeamMemberBookingProfileResponse
Retrieves a team member’s booking profile.
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Square::Types::ListTeamMemberBookingProfilesResponse
Lists booking profiles for team members.
Constructor Details
#initialize(client:) ⇒ void
10 11 12 |
# File 'lib/square/bookings/team_member_profiles/client.rb', line 10 def initialize(client:) @client = client end |
Instance Method Details
#get(request_options: {}, **params) ⇒ Square::Types::GetTeamMemberBookingProfileResponse
Retrieves a team member’s booking profile.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/square/bookings/team_member_profiles/client.rb', line 79 def get(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "v2/bookings/team-member-booking-profiles/#{params[:team_member_id]}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Square::Types::GetTeamMemberBookingProfileResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list(request_options: {}, **params) ⇒ Square::Types::ListTeamMemberBookingProfilesResponse
Lists booking profiles for team members.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/square/bookings/team_member_profiles/client.rb', line 29 def list(request_options: {}, **params) params = Square::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[bookable_only limit cursor location_id] query_params = {} query_params["bookable_only"] = params[:bookable_only] if params.key?(:bookable_only) query_params["limit"] = params[:limit] if params.key?(:limit) query_params["cursor"] = params[:cursor] if params.key?(:cursor) query_params["location_id"] = params[:location_id] if params.key?(:location_id) params.except(*query_param_names) Square::Internal::CursorItemIterator.new( cursor_field: :cursor, item_field: :team_member_booking_profiles, initial_cursor: query_params[:cursor] ) do |next_cursor| query_params[:cursor] = next_cursor request = Square::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "v2/bookings/team-member-booking-profiles", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Square::Types::ListTeamMemberBookingProfilesResponse.load(response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end end |