loading
Generated 2026-06-02T20:54:04+00:00

All Files ( 87.49% covered at 4.46 hits/line )

494 files in total.
28720 relevant lines, 25127 lines covered and 3593 lines missed. ( 87.49% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
lib/bandwidth-sdk.rb 99.61 % 285 254 253 1 1.09
lib/bandwidth-sdk/api/calls_api.rb 95.04 % 417 141 134 7 1.27
lib/bandwidth-sdk/api/conferences_api.rb 97.50 % 717 240 234 6 1.48
lib/bandwidth-sdk/api/endpoints_api.rb 96.24 % 397 133 128 5 1.27
lib/bandwidth-sdk/api/media_api.rb 98.04 % 312 102 100 2 1.30
lib/bandwidth-sdk/api/messages_api.rb 97.50 % 240 80 78 2 1.11
lib/bandwidth-sdk/api/mfa_api.rb 96.43 % 244 84 81 3 1.25
lib/bandwidth-sdk/api/multi_channel_api.rb 96.88 % 96 32 31 1 1.22
lib/bandwidth-sdk/api/phone_number_lookup_api.rb 96.30 % 239 81 78 3 1.26
lib/bandwidth-sdk/api/recordings_api.rb 93.00 % 782 257 239 18 1.42
lib/bandwidth-sdk/api/statistics_api.rb 96.30 % 85 27 26 1 1.07
lib/bandwidth-sdk/api/toll_free_verification_api.rb 93.75 % 696 240 225 15 1.25
lib/bandwidth-sdk/api/transcriptions_api.rb 97.44 % 241 78 76 2 1.44
lib/bandwidth-sdk/api_client.rb 84.66 % 441 189 160 29 19.23
lib/bandwidth-sdk/api_error.rb 95.45 % 58 22 21 1 1.64
lib/bandwidth-sdk/api_model_base.rb 94.29 % 88 35 33 2 429.60
lib/bandwidth-sdk/configuration.rb 96.79 % 771 156 151 5 14.44
lib/bandwidth-sdk/models/account_statistics.rb 82.81 % 156 64 53 11 2.84
lib/bandwidth-sdk/models/additional_denial_reason.rb 74.73 % 217 91 68 23 4.86
lib/bandwidth-sdk/models/address.rb 60.71 % 434 196 119 77 9.69
lib/bandwidth-sdk/models/answer_callback.rb 84.68 % 301 111 94 17 4.94
lib/bandwidth-sdk/models/async_lookup_request.rb 78.57 % 165 70 55 15 2.66
lib/bandwidth-sdk/models/blocked_webhook.rb 75.00 % 256 108 81 27 3.37
lib/bandwidth-sdk/models/bridge_complete_callback.rb 85.47 % 323 117 100 17 5.25
lib/bandwidth-sdk/models/bridge_target_complete_callback.rb 84.26 % 291 108 91 17 4.77
lib/bandwidth-sdk/models/brtc_error.rb 80.90 % 219 89 72 17 13.53
lib/bandwidth-sdk/models/brtc_error_response.rb 80.23 % 204 86 69 17 3.30
lib/bandwidth-sdk/models/brtc_error_source.rb 87.14 % 176 70 61 9 4.77
lib/bandwidth-sdk/models/brtc_link.rb 83.58 % 166 67 56 11 15.69
lib/bandwidth-sdk/models/business_entity_type_enum.rb 100.00 % 43 16 16 0 2.75
lib/bandwidth-sdk/models/business_registration_type_enum.rb 100.00 % 56 29 29 0 3.31
lib/bandwidth-sdk/models/bxml/bxml.rb 100.00 % 11 5 5 0 2.00
lib/bandwidth-sdk/models/bxml/nestable_verb.rb 90.91 % 46 22 20 2 33.00
lib/bandwidth-sdk/models/bxml/response.rb 100.00 % 11 5 5 0 2.00
lib/bandwidth-sdk/models/bxml/root.rb 100.00 % 47 25 25 0 6.40
lib/bandwidth-sdk/models/bxml/verb.rb 95.45 % 50 22 21 1 58.59
lib/bandwidth-sdk/models/bxml/verbs/bridge.rb 100.00 % 28 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/conference.rb 100.00 % 28 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/custom_param.rb 100.00 % 16 6 6 0 3.00
lib/bandwidth-sdk/models/bxml/verbs/forward.rb 100.00 % 20 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/gather.rb 100.00 % 42 11 11 0 3.00
lib/bandwidth-sdk/models/bxml/verbs/hangup.rb 100.00 % 10 5 5 0 1.20
lib/bandwidth-sdk/models/bxml/verbs/pause.rb 100.00 % 15 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/pause_recording.rb 100.00 % 10 5 5 0 2.80
lib/bandwidth-sdk/models/bxml/verbs/phone_number.rb 100.00 % 27 6 6 0 2.67
lib/bandwidth-sdk/models/bxml/verbs/play_audio.rb 100.00 % 17 6 6 0 2.67
lib/bandwidth-sdk/models/bxml/verbs/record.rb 100.00 % 32 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/redirect.rb 100.00 % 23 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/resume_recording.rb 100.00 % 10 5 5 0 1.20
lib/bandwidth-sdk/models/bxml/verbs/ring.rb 100.00 % 16 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/send_dtmf.rb 100.00 % 17 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/sip_uri.rb 100.00 % 27 6 6 0 2.00
lib/bandwidth-sdk/models/bxml/verbs/speak_sentence.rb 100.00 % 25 9 9 0 2.11
lib/bandwidth-sdk/models/bxml/verbs/start_gather.rb 100.00 % 19 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/start_recording.rb 100.00 % 24 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/start_stream.rb 100.00 % 31 8 8 0 2.38
lib/bandwidth-sdk/models/bxml/verbs/start_transcription.rb 100.00 % 29 8 8 0 2.38
lib/bandwidth-sdk/models/bxml/verbs/stop_gather.rb 100.00 % 10 5 5 0 1.20
lib/bandwidth-sdk/models/bxml/verbs/stop_recording.rb 100.00 % 10 5 5 0 1.20
lib/bandwidth-sdk/models/bxml/verbs/stop_stream.rb 100.00 % 16 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/stop_transcription.rb 100.00 % 15 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/stream_param.rb 100.00 % 16 6 6 0 3.00
lib/bandwidth-sdk/models/bxml/verbs/tag.rb 100.00 % 11 5 5 0 1.20
lib/bandwidth-sdk/models/bxml/verbs/transfer.rb 100.00 % 35 8 8 0 2.38
lib/bandwidth-sdk/models/call_direction_enum.rb 100.00 % 40 13 13 0 6.69
lib/bandwidth-sdk/models/call_recording_metadata.rb 86.51 % 347 126 109 17 9.40
lib/bandwidth-sdk/models/call_state.rb 88.71 % 349 124 110 14 9.10
lib/bandwidth-sdk/models/call_state_enum.rb 100.00 % 40 13 13 0 1.77
lib/bandwidth-sdk/models/call_transcription.rb 75.79 % 224 95 72 23 5.40
lib/bandwidth-sdk/models/call_transcription_detected_language_enum.rb 100.00 % 41 14 14 0 2.43
lib/bandwidth-sdk/models/call_transcription_metadata.rb 83.58 % 166 67 56 11 3.39
lib/bandwidth-sdk/models/call_transcription_response.rb 87.32 % 177 71 62 9 3.93
lib/bandwidth-sdk/models/call_transcription_track_enum.rb 100.00 % 40 13 13 0 2.31
lib/bandwidth-sdk/models/callback.rb 100.00 % 61 17 17 0 4.76
lib/bandwidth-sdk/models/callback_method_enum.rb 100.00 % 40 13 13 0 5.38
lib/bandwidth-sdk/models/card_width_enum.rb 100.00 % 40 13 13 0 2.00
lib/bandwidth-sdk/models/code_request.rb 66.46 % 367 164 109 55 6.41
lib/bandwidth-sdk/models/completed_lookup_status_enum.rb 100.00 % 41 14 14 0 2.36
lib/bandwidth-sdk/models/conference.rb 84.21 % 246 95 80 15 5.97
lib/bandwidth-sdk/models/conference_completed_callback.rb 84.93 % 188 73 62 11 3.37
lib/bandwidth-sdk/models/conference_created_callback.rb 84.93 % 188 73 62 11 3.37
lib/bandwidth-sdk/models/conference_member.rb 90.91 % 199 77 70 7 8.10
lib/bandwidth-sdk/models/conference_member_exit_callback.rb 86.59 % 218 82 71 11 4.21
lib/bandwidth-sdk/models/conference_member_join_callback.rb 86.59 % 218 82 71 11 4.21
lib/bandwidth-sdk/models/conference_recording_available_callback.rb 84.68 % 300 111 94 17 4.94
lib/bandwidth-sdk/models/conference_recording_metadata.rb 83.81 % 278 105 88 17 7.54
lib/bandwidth-sdk/models/conference_redirect_callback.rb 84.93 % 188 73 62 11 3.37
lib/bandwidth-sdk/models/conference_state_enum.rb 100.00 % 40 13 13 0 1.77
lib/bandwidth-sdk/models/contact.rb 62.42 % 326 149 93 56 7.89
lib/bandwidth-sdk/models/create_async_bulk_lookup_response.rb 86.96 % 168 69 60 9 3.48
lib/bandwidth-sdk/models/create_async_bulk_lookup_response_data.rb 77.33 % 178 75 58 17 3.75
lib/bandwidth-sdk/models/create_call.rb 71.54 % 661 267 191 76 7.55
lib/bandwidth-sdk/models/create_call_response.rb 73.97 % 562 219 162 57 8.02
lib/bandwidth-sdk/models/create_endpoint_request_base.rb 75.96 % 250 104 79 25 3.39
lib/bandwidth-sdk/models/create_endpoint_response.rb 77.42 % 218 93 72 21 4.17
lib/bandwidth-sdk/models/create_endpoint_response_data.rb 74.32 % 356 148 110 38 8.52
lib/bandwidth-sdk/models/create_message_request_error.rb 79.76 % 199 84 67 17 3.01
lib/bandwidth-sdk/models/create_multi_channel_message_response.rb 89.86 % 167 69 62 7 3.30
lib/bandwidth-sdk/models/create_sync_lookup_response.rb 86.96 % 167 69 60 9 3.46
lib/bandwidth-sdk/models/create_sync_lookup_response_data.rb 83.54 % 190 79 66 13 4.49
lib/bandwidth-sdk/models/create_web_rtc_connection_request.rb 76.15 % 266 109 83 26 4.07
lib/bandwidth-sdk/models/deactivation_event_enum.rb 100.00 % 39 12 12 0 2.58
lib/bandwidth-sdk/models/device.rb 75.23 % 258 109 82 27 7.02
lib/bandwidth-sdk/models/device_status_enum.rb 100.00 % 40 13 13 0 2.46
lib/bandwidth-sdk/models/disconnect_callback.rb 85.83 % 333 120 103 17 5.39
lib/bandwidth-sdk/models/diversion.rb 86.08 % 206 79 68 11 4.77
lib/bandwidth-sdk/models/dtmf_callback.rb 85.83 % 331 120 103 17 5.39
lib/bandwidth-sdk/models/endpoint.rb 75.18 % 329 137 103 34 7.82
lib/bandwidth-sdk/models/endpoint_direction_enum.rb 100.00 % 41 14 14 0 2.14
lib/bandwidth-sdk/models/endpoint_event.rb 70.89 % 381 158 112 46 5.18
lib/bandwidth-sdk/models/endpoint_event_type_enum.rb 100.00 % 40 13 13 0 1.77
lib/bandwidth-sdk/models/endpoint_response.rb 77.42 % 218 93 72 21 4.17
lib/bandwidth-sdk/models/endpoint_status_enum.rb 100.00 % 40 13 13 0 4.31
lib/bandwidth-sdk/models/endpoint_type_enum.rb 100.00 % 39 12 12 0 4.83
lib/bandwidth-sdk/models/endpoints.rb 73.28 % 311 131 96 35 8.30
lib/bandwidth-sdk/models/error_object.rb 74.73 % 216 91 68 23 6.42
lib/bandwidth-sdk/models/error_source.rb 87.14 % 177 70 61 9 6.94
lib/bandwidth-sdk/models/failure_webhook.rb 80.61 % 237 98 79 19 3.71
lib/bandwidth-sdk/models/field_error.rb 82.81 % 156 64 53 11 3.77
lib/bandwidth-sdk/models/file_format_enum.rb 100.00 % 40 13 13 0 4.15
lib/bandwidth-sdk/models/gather_callback.rb 86.18 % 341 123 106 17 5.53
lib/bandwidth-sdk/models/get_async_bulk_lookup_response.rb 86.96 % 167 69 60 9 3.46
lib/bandwidth-sdk/models/get_async_bulk_lookup_response_data.rb 83.54 % 190 79 66 13 4.35
lib/bandwidth-sdk/models/in_progress_lookup_status_enum.rb 100.00 % 42 15 15 0 2.87
lib/bandwidth-sdk/models/inbound_callback.rb 70.87 % 301 127 90 37 4.60
lib/bandwidth-sdk/models/inbound_callback_message.rb 73.51 % 457 185 136 49 8.46
lib/bandwidth-sdk/models/inbound_callback_type_enum.rb 100.00 % 41 14 14 0 1.93
lib/bandwidth-sdk/models/initiate_callback.rb 81.20 % 305 117 95 22 4.51
lib/bandwidth-sdk/models/latest_message_delivery_status_enum.rb 100.00 % 42 15 15 0 3.67
lib/bandwidth-sdk/models/line_type_enum.rb 100.00 % 42 15 15 0 3.67
lib/bandwidth-sdk/models/link.rb 82.81 % 154 64 53 11 5.23
lib/bandwidth-sdk/models/link_schema.rb 83.58 % 166 67 56 11 10.79
lib/bandwidth-sdk/models/links_object.rb 84.29 % 176 70 59 11 4.39
lib/bandwidth-sdk/models/list_endpoints_response.rb 78.35 % 229 97 76 21 4.73
lib/bandwidth-sdk/models/list_message_direction_enum.rb 100.00 % 40 13 13 0 2.08
lib/bandwidth-sdk/models/list_message_item.rb 89.13 % 397 138 123 15 11.78
lib/bandwidth-sdk/models/lookup_error_response.rb 86.96 % 168 69 60 9 2.75
lib/bandwidth-sdk/models/lookup_error_schema.rb 77.66 % 226 94 73 21 10.52
lib/bandwidth-sdk/models/lookup_error_schema_meta.rb 86.76 % 167 68 59 9 4.62
lib/bandwidth-sdk/models/lookup_result.rb 85.71 % 276 105 90 15 19.77
lib/bandwidth-sdk/models/machine_detection_complete_callback.rb 84.68 % 301 111 94 17 4.94
lib/bandwidth-sdk/models/machine_detection_configuration.rb 78.66 % 426 164 129 35 5.79
lib/bandwidth-sdk/models/machine_detection_mode_enum.rb 100.00 % 40 13 13 0 1.77
lib/bandwidth-sdk/models/machine_detection_result.rb 82.81 % 157 64 53 11 3.39
lib/bandwidth-sdk/models/media.rb 83.58 % 163 67 56 11 3.39
lib/bandwidth-sdk/models/message.rb 87.29 % 310 118 103 15 7.19
lib/bandwidth-sdk/models/message_direction_enum.rb 100.00 % 40 13 13 0 3.54
lib/bandwidth-sdk/models/message_request.rb 78.13 % 311 128 100 28 5.01
lib/bandwidth-sdk/models/message_status_enum.rb 100.00 % 46 19 19 0 2.68
lib/bandwidth-sdk/models/message_type_enum.rb 100.00 % 41 14 14 0 2.21
lib/bandwidth-sdk/models/messages_list.rb 86.76 % 166 68 59 9 3.44
lib/bandwidth-sdk/models/messaging_code_response.rb 81.97 % 146 61 50 11 2.25
lib/bandwidth-sdk/models/messaging_request_error.rb 76.25 % 188 80 61 19 2.66
lib/bandwidth-sdk/models/mfa_forbidden_request_error.rb 81.97 % 146 61 50 11 1.87
lib/bandwidth-sdk/models/mfa_request_error.rb 82.81 % 156 64 53 11 2.30
lib/bandwidth-sdk/models/mfa_unauthorized_request_error.rb 81.97 % 146 61 50 11 1.87
lib/bandwidth-sdk/models/mms_message_content.rb 86.49 % 176 74 64 10 5.86
lib/bandwidth-sdk/models/mms_message_content_file.rb 75.68 % 172 74 56 18 3.22
lib/bandwidth-sdk/models/multi_channel_action.rb 100.00 % 61 17 17 0 6.59
lib/bandwidth-sdk/models/multi_channel_action_calendar_event.rb 67.07 % 382 164 110 54 4.63
lib/bandwidth-sdk/models/multi_channel_channel_list_mms_object.rb 70.43 % 271 115 81 34 3.26
lib/bandwidth-sdk/models/multi_channel_channel_list_mms_response_object.rb 69.84 % 299 126 88 38 3.67
lib/bandwidth-sdk/models/multi_channel_channel_list_object_base.rb 71.57 % 238 102 73 29 2.87
lib/bandwidth-sdk/models/multi_channel_channel_list_owner_object.rb 78.26 % 163 69 54 15 2.09
lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_object.rb 70.43 % 271 115 81 34 3.26
lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_object_all_of_content.rb 67.50 % 105 40 27 13 4.20
lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_response_object.rb 69.84 % 299 126 88 38 4.31
lib/bandwidth-sdk/models/multi_channel_channel_list_request_object.rb 100.00 % 56 17 17 0 3.18
lib/bandwidth-sdk/models/multi_channel_channel_list_response_object.rb 100.00 % 56 17 17 0 3.59
lib/bandwidth-sdk/models/multi_channel_channel_list_sms_object.rb 70.43 % 271 115 81 34 5.52
lib/bandwidth-sdk/models/multi_channel_channel_list_sms_response_object.rb 69.84 % 299 126 88 38 6.00
lib/bandwidth-sdk/models/multi_channel_error.rb 86.96 % 168 69 60 9 2.75
lib/bandwidth-sdk/models/multi_channel_message_channel_enum.rb 100.00 % 41 14 14 0 4.29
lib/bandwidth-sdk/models/multi_channel_message_content.rb 82.81 % 155 64 53 11 2.30
lib/bandwidth-sdk/models/multi_channel_message_request.rb 77.36 % 253 106 82 24 3.89
lib/bandwidth-sdk/models/multi_channel_message_response_data.rb 74.29 % 335 140 104 36 5.76
lib/bandwidth-sdk/models/opt_in_workflow.rb 74.53 % 242 106 79 27 6.49
lib/bandwidth-sdk/models/page.rb 75.45 % 259 110 83 27 7.15
lib/bandwidth-sdk/models/page_info.rb 84.29 % 176 70 59 11 6.09
lib/bandwidth-sdk/models/priority_enum.rb 100.00 % 40 13 13 0 3.54
lib/bandwidth-sdk/models/product_type_enum.rb 100.00 % 47 20 20 0 2.45
lib/bandwidth-sdk/models/rbm_action_base.rb 68.75 % 256 112 77 35 12.13
lib/bandwidth-sdk/models/rbm_action_dial.rb 68.00 % 290 125 85 40 3.46
lib/bandwidth-sdk/models/rbm_action_open_url.rb 68.38 % 317 136 93 43 3.95
lib/bandwidth-sdk/models/rbm_action_type_enum.rb 100.00 % 44 17 17 0 4.06
lib/bandwidth-sdk/models/rbm_action_view_location.rb 68.24 % 346 148 101 47 4.17
lib/bandwidth-sdk/models/rbm_card_content.rb 83.67 % 235 98 82 16 8.95
lib/bandwidth-sdk/models/rbm_card_content_media.rb 72.73 % 256 110 80 30 4.25
lib/bandwidth-sdk/models/rbm_location_response.rb 82.81 % 156 64 53 11 2.30
lib/bandwidth-sdk/models/rbm_media_height_enum.rb 100.00 % 41 14 14 0 2.14
lib/bandwidth-sdk/models/rbm_message_carousel_card.rb 72.17 % 261 115 83 32 3.74
lib/bandwidth-sdk/models/rbm_message_content_file.rb 77.91 % 201 86 67 19 5.58
lib/bandwidth-sdk/models/rbm_message_content_rich_card.rb 60.00 % 103 40 24 16 4.95
lib/bandwidth-sdk/models/rbm_message_content_text.rb 80.46 % 203 87 70 17 6.63
lib/bandwidth-sdk/models/rbm_message_media.rb 79.52 % 195 83 66 17 3.45
lib/bandwidth-sdk/models/rbm_open_url_enum.rb 100.00 % 40 13 13 0 1.77
lib/bandwidth-sdk/models/rbm_standalone_card.rb 75.70 % 250 107 81 26 3.99
lib/bandwidth-sdk/models/rbm_suggestion_response.rb 80.82 % 175 73 59 14 2.48
lib/bandwidth-sdk/models/rbm_web_view_enum.rb 100.00 % 41 14 14 0 1.93
lib/bandwidth-sdk/models/recording_available_callback.rb 87.41 % 380 135 118 17 6.01
lib/bandwidth-sdk/models/recording_complete_callback.rb 87.41 % 381 135 118 17 6.01
lib/bandwidth-sdk/models/recording_state_enum.rb 100.00 % 40 13 13 0 1.77
lib/bandwidth-sdk/models/recording_transcription_metadata.rb 84.29 % 177 70 59 11 4.73
lib/bandwidth-sdk/models/recording_transcriptions.rb 82.26 % 147 62 51 11 2.32
lib/bandwidth-sdk/models/redirect_callback.rb 85.47 % 321 117 100 17 5.25
lib/bandwidth-sdk/models/redirect_method_enum.rb 100.00 % 40 13 13 0 2.46
lib/bandwidth-sdk/models/sip_connection_metadata.rb 84.29 % 175 70 59 11 3.04
lib/bandwidth-sdk/models/sip_credentials.rb 82.81 % 156 64 53 11 3.77
lib/bandwidth-sdk/models/sms_message_content.rb 75.68 % 172 74 56 18 7.74
lib/bandwidth-sdk/models/standalone_card_orientation_enum.rb 100.00 % 40 13 13 0 2.00
lib/bandwidth-sdk/models/status_callback.rb 72.18 % 321 133 96 37 5.19
lib/bandwidth-sdk/models/status_callback_message.rb 72.99 % 424 174 127 47 8.37
lib/bandwidth-sdk/models/status_callback_type_enum.rb 100.00 % 42 15 15 0 2.07
lib/bandwidth-sdk/models/stir_shaken.rb 83.58 % 166 67 56 11 3.39
lib/bandwidth-sdk/models/sync_lookup_request.rb 79.76 % 196 84 67 17 3.58
lib/bandwidth-sdk/models/telephone_number.rb 81.97 % 146 61 50 11 3.30
lib/bandwidth-sdk/models/tfv_basic_authentication.rb 72.22 % 206 90 65 25 4.63
lib/bandwidth-sdk/models/tfv_callback_status_enum.rb 100.00 % 40 13 13 0 2.00
lib/bandwidth-sdk/models/tfv_error.rb 83.58 % 165 67 56 11 2.69
lib/bandwidth-sdk/models/tfv_status.rb 74.81 % 330 135 101 34 5.27
lib/bandwidth-sdk/models/tfv_status_enum.rb 100.00 % 41 14 14 0 2.21
lib/bandwidth-sdk/models/tfv_submission_info.rb 69.70 % 550 231 161 70 6.19
lib/bandwidth-sdk/models/tfv_submission_wrapper.rb 81.97 % 145 61 50 11 2.13
lib/bandwidth-sdk/models/thumbnail_alignment_enum.rb 100.00 % 40 13 13 0 2.00
lib/bandwidth-sdk/models/transcribe_recording.rb 77.31 % 293 119 92 27 4.01
lib/bandwidth-sdk/models/transcription.rb 82.81 % 156 64 53 11 4.86
lib/bandwidth-sdk/models/transcription_available_callback.rb 87.12 % 369 132 115 17 5.90
lib/bandwidth-sdk/models/transfer_answer_callback.rb 85.09 % 311 114 97 17 5.10
lib/bandwidth-sdk/models/transfer_complete_callback.rb 86.18 % 343 123 106 17 5.53
lib/bandwidth-sdk/models/transfer_disconnect_callback.rb 86.82 % 363 129 112 17 5.78
lib/bandwidth-sdk/models/update_call.rb 78.10 % 346 137 107 30 4.78
lib/bandwidth-sdk/models/update_call_recording.rb 73.75 % 184 80 59 21 2.09
lib/bandwidth-sdk/models/update_conference.rb 77.17 % 320 127 98 29 4.57
lib/bandwidth-sdk/models/update_conference_member.rb 89.71 % 169 68 61 7 3.13
lib/bandwidth-sdk/models/verification_denial_webhook.rb 82.88 % 278 111 92 19 4.63
lib/bandwidth-sdk/models/verification_request.rb 64.13 % 763 329 211 118 11.06
lib/bandwidth-sdk/models/verification_update_request.rb 64.55 % 700 299 193 106 11.04
lib/bandwidth-sdk/models/verification_webhook.rb 73.53 % 236 102 75 27 2.92
lib/bandwidth-sdk/models/verify_code_request.rb 67.77 % 274 121 82 39 4.37
lib/bandwidth-sdk/models/verify_code_response.rb 81.97 % 146 61 50 11 2.89
lib/bandwidth-sdk/models/voice_api_error.rb 83.58 % 164 67 56 11 2.69
lib/bandwidth-sdk/models/voice_code_response.rb 81.97 % 146 61 50 11 2.25
lib/bandwidth-sdk/models/webhook_subscription.rb 76.36 % 261 110 84 26 8.49
lib/bandwidth-sdk/models/webhook_subscription_basic_authentication.rb 72.22 % 207 90 65 25 5.79
lib/bandwidth-sdk/models/webhook_subscription_error.rb 89.71 % 165 68 61 7 5.31
lib/bandwidth-sdk/models/webhook_subscription_request_schema.rb 68.87 % 239 106 73 33 3.58
lib/bandwidth-sdk/models/webhook_subscription_type_enum.rb 100.00 % 40 13 13 0 2.69
lib/bandwidth-sdk/models/webhook_subscriptions_list_body.rb 83.12 % 185 77 64 13 3.73
lib/bandwidth-sdk/version.rb 100.00 % 15 2 2 0 1.00
spec/unit/api/calls_api_spec.rb 100.00 % 233 128 128 0 1.02
spec/unit/api/conferences_api_spec.rb 100.00 % 331 184 184 0 1.07
spec/unit/api/endpoints_api_spec.rb 100.00 % 172 100 100 0 1.03
spec/unit/api/media_api_spec.rb 100.00 % 115 61 61 0 1.07
spec/unit/api/messages_api_spec.rb 100.00 % 109 77 77 0 1.00
spec/unit/api/mfa_api_spec.rb 100.00 % 114 53 53 0 1.08
spec/unit/api/multi_channel_api_spec.rb 100.00 % 70 36 36 0 1.00
spec/unit/api/phone_number_lookup_api_spec.rb 100.00 % 131 84 84 0 1.10
spec/unit/api/recordings_api_spec.rb 100.00 % 371 194 194 0 1.07
spec/unit/api/statistics_api_spec.rb 100.00 % 37 22 22 0 1.00
spec/unit/api/toll_free_verification_api_spec.rb 100.00 % 306 164 164 0 1.10
spec/unit/api/transcriptions_api_spec.rb 100.00 % 112 65 65 0 1.08
spec/unit/client/api_client_spec.rb 100.00 % 377 122 122 0 1.16
spec/unit/client/api_error_spec.rb 100.00 % 23 13 13 0 1.00
spec/unit/client/configuration_spec.rb 100.00 % 277 166 166 0 1.43
spec/unit/models/account_statistics_spec.rb 100.00 % 68 32 32 0 1.13
spec/unit/models/additional_denial_reason_spec.rb 100.00 % 101 44 44 0 1.09
spec/unit/models/address_spec.rb 100.00 % 187 80 80 0 1.05
spec/unit/models/answer_callback_spec.rb 100.00 % 123 46 46 0 1.09
spec/unit/models/async_lookup_request_spec.rb 100.00 % 77 36 36 0 1.14
spec/unit/models/blocked_webhook_spec.rb 100.00 % 104 46 46 0 1.09
spec/unit/models/bridge_complete_callback_spec.rb 100.00 % 130 46 46 0 1.09
spec/unit/models/bridge_target_complete_callback_spec.rb 100.00 % 116 43 43 0 1.09
spec/unit/models/brtc_error_response_spec.rb 100.00 % 93 41 41 0 1.15
spec/unit/models/brtc_error_source_spec.rb 100.00 % 76 34 34 0 1.12
spec/unit/models/brtc_error_spec.rb 100.00 % 101 43 43 0 1.09
spec/unit/models/brtc_link_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/business_entity_type_enum_spec.rb 100.00 % 52 25 25 0 1.00
spec/unit/models/business_registration_type_enum_spec.rb 100.00 % 130 64 64 0 1.00
spec/unit/models/bxml/bxml_spec.rb 100.00 % 41 26 26 0 1.31
spec/unit/models/bxml/nestable_verb_spec.rb 100.00 % 11 6 6 0 1.17
spec/unit/models/bxml/response_spec.rb 100.00 % 41 26 26 0 1.31
spec/unit/models/bxml/verb_spec.rb 100.00 % 15 8 8 0 1.25
spec/unit/models/bxml/verbs/bridge_spec.rb 100.00 % 58 17 17 0 1.29
spec/unit/models/bxml/verbs/conference_spec.rb 100.00 % 58 17 17 0 1.29
spec/unit/models/bxml/verbs/custom_param_spec.rb 100.00 % 36 17 17 0 1.29
spec/unit/models/bxml/verbs/forward_spec.rb 100.00 % 44 17 17 0 1.29
spec/unit/models/bxml/verbs/gather_spec.rb 100.00 % 86 34 34 0 1.44
spec/unit/models/bxml/verbs/hangup_spec.rb 100.00 % 16 9 9 0 1.22
spec/unit/models/bxml/verbs/pause_recording_spec.rb 100.00 % 16 9 9 0 1.22
spec/unit/models/bxml/verbs/pause_spec.rb 100.00 % 34 17 17 0 1.29
spec/unit/models/bxml/verbs/phone_number_spec.rb 100.00 % 56 17 17 0 1.29
spec/unit/models/bxml/verbs/play_audio_spec.rb 100.00 % 36 17 17 0 1.29
spec/unit/models/bxml/verbs/record_spec.rb 100.00 % 68 17 17 0 1.29
spec/unit/models/bxml/verbs/redirect_spec.rb 100.00 % 50 17 17 0 1.29
spec/unit/models/bxml/verbs/resume_recording_spec.rb 100.00 % 16 9 9 0 1.22
spec/unit/models/bxml/verbs/ring_spec.rb 100.00 % 36 17 17 0 1.29
spec/unit/models/bxml/verbs/send_dtmf_spec.rb 100.00 % 36 17 17 0 1.29
spec/unit/models/bxml/verbs/sip_uri_spec.rb 100.00 % 56 17 17 0 1.29
spec/unit/models/bxml/verbs/speak_sentence_spec.rb 100.00 % 38 17 17 0 1.29
spec/unit/models/bxml/verbs/start_gather_spec.rb 100.00 % 42 17 17 0 1.29
spec/unit/models/bxml/verbs/start_recording_spec.rb 100.00 % 52 17 17 0 1.29
spec/unit/models/bxml/verbs/start_stream_spec.rb 100.00 % 78 34 34 0 1.44
spec/unit/models/bxml/verbs/start_transcription_spec.rb 100.00 % 74 34 34 0 1.44
spec/unit/models/bxml/verbs/stop_gather_spec.rb 100.00 % 16 9 9 0 1.22
spec/unit/models/bxml/verbs/stop_recording_spec.rb 100.00 % 16 9 9 0 1.22
spec/unit/models/bxml/verbs/stop_stream_spec.rb 100.00 % 36 17 17 0 1.29
spec/unit/models/bxml/verbs/stop_transcription_spec.rb 100.00 % 34 17 17 0 1.29
spec/unit/models/bxml/verbs/stream_param_spec.rb 100.00 % 36 17 17 0 1.29
spec/unit/models/bxml/verbs/tag_spec.rb 100.00 % 16 9 9 0 1.22
spec/unit/models/bxml/verbs/transfer_spec.rb 100.00 % 86 34 34 0 1.44
spec/unit/models/call_direction_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/call_recording_metadata_spec.rb 100.00 % 137 48 48 0 1.08
spec/unit/models/call_state_enum_spec.rb 100.00 % 31 16 16 0 1.00
spec/unit/models/call_state_spec.rb 100.00 % 159 48 48 0 1.08
spec/unit/models/call_transcription_detected_language_enum_spec.rb 100.00 % 40 19 19 0 1.00
spec/unit/models/call_transcription_metadata_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/call_transcription_response_spec.rb 100.00 % 76 34 34 0 1.12
spec/unit/models/call_transcription_spec.rb 100.00 % 92 42 42 0 1.10
spec/unit/models/call_transcription_track_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/callback_method_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/callback_spec.rb 100.00 % 65 30 30 0 2.07
spec/unit/models/card_width_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/code_request_spec.rb 100.00 % 167 72 72 0 1.06
spec/unit/models/completed_lookup_status_enum_spec.rb 100.00 % 40 19 19 0 1.00
spec/unit/models/conference_completed_callback_spec.rb 100.00 % 82 35 35 0 1.11
spec/unit/models/conference_created_callback_spec.rb 100.00 % 82 35 35 0 1.11
spec/unit/models/conference_member_exit_callback_spec.rb 100.00 % 94 38 38 0 1.11
spec/unit/models/conference_member_join_callback_spec.rb 100.00 % 94 38 38 0 1.11
spec/unit/models/conference_member_spec.rb 100.00 % 84 36 36 0 1.11
spec/unit/models/conference_recording_available_callback_spec.rb 100.00 % 119 44 44 0 1.09
spec/unit/models/conference_recording_metadata_spec.rb 100.00 % 108 42 42 0 1.10
spec/unit/models/conference_redirect_callback_spec.rb 100.00 % 82 35 35 0 1.11
spec/unit/models/conference_spec.rb 100.00 % 98 38 38 0 1.11
spec/unit/models/conference_state_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/contact_spec.rb 100.00 % 145 64 64 0 1.06
spec/unit/models/create_async_bulk_lookup_response_data_spec.rb 100.00 % 68 32 32 0 1.13
spec/unit/models/create_async_bulk_lookup_response_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/create_call_response_spec.rb 100.00 % 242 86 86 0 1.05
spec/unit/models/create_call_spec.rb 100.00 % 278 105 105 0 1.04
spec/unit/models/create_endpoint_request_base_spec.rb 100.00 % 107 46 46 0 1.09
spec/unit/models/create_endpoint_response_data_spec.rb 100.00 % 151 61 61 0 1.07
spec/unit/models/create_endpoint_response_spec.rb 100.00 % 122 44 44 0 1.16
spec/unit/models/create_message_request_error_spec.rb 100.00 % 93 41 41 0 1.10
spec/unit/models/create_multi_channel_message_response_spec.rb 100.00 % 68 32 32 0 1.13
spec/unit/models/create_sync_lookup_response_data_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/create_sync_lookup_response_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/create_web_rtc_connection_request_spec.rb 100.00 % 111 47 47 0 1.09
spec/unit/models/deactivation_event_enum_spec.rb 100.00 % 28 13 13 0 1.00
spec/unit/models/device_spec.rb 100.00 % 111 48 48 0 1.08
spec/unit/models/device_status_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/disconnect_callback_spec.rb 100.00 % 134 47 47 0 1.09
spec/unit/models/diversion_spec.rb 100.00 % 88 37 37 0 1.11
spec/unit/models/dtmf_callback_spec.rb 100.00 % 132 47 47 0 1.09
spec/unit/models/endpoint_direction_enum_spec.rb 100.00 % 40 19 19 0 1.00
spec/unit/models/endpoint_event_spec.rb 100.00 % 163 65 65 0 1.06
spec/unit/models/endpoint_event_type_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/endpoint_response_spec.rb 100.00 % 108 45 45 0 1.29
spec/unit/models/endpoint_spec.rb 100.00 % 140 58 58 0 1.09
spec/unit/models/endpoint_status_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/endpoint_type_enum_spec.rb 100.00 % 28 13 13 0 1.00
spec/unit/models/endpoints_spec.rb 100.00 % 135 56 56 0 1.09
spec/unit/models/error_object_spec.rb 100.00 % 103 46 46 0 1.15
spec/unit/models/error_source_spec.rb 100.00 % 76 34 34 0 1.12
spec/unit/models/failure_webhook_spec.rb 100.00 % 104 46 46 0 1.09
spec/unit/models/field_error_spec.rb 100.00 % 68 32 32 0 1.13
spec/unit/models/file_format_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/gather_callback_spec.rb 100.00 % 136 48 48 0 1.08
spec/unit/models/get_async_bulk_lookup_response_data_spec.rb 100.00 % 74 35 35 0 1.20
spec/unit/models/get_async_bulk_lookup_response_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/in_progress_lookup_status_enum_spec.rb 100.00 % 46 22 22 0 1.00
spec/unit/models/inbound_callback_message_spec.rb 100.00 % 181 69 69 0 1.17
spec/unit/models/inbound_callback_spec.rb 100.00 % 161 55 55 0 1.16
spec/unit/models/inbound_callback_type_enum_spec.rb 100.00 % 40 19 19 0 1.00
spec/unit/models/initiate_callback_spec.rb 100.00 % 114 45 45 0 1.09
spec/unit/models/latest_message_delivery_status_enum_spec.rb 100.00 % 46 22 22 0 1.00
spec/unit/models/line_type_enum_spec.rb 100.00 % 46 22 22 0 1.00
spec/unit/models/link_schema_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/link_spec.rb 100.00 % 68 32 32 0 1.13
spec/unit/models/links_object_spec.rb 100.00 % 76 34 34 0 1.12
spec/unit/models/list_endpoints_response_spec.rb 100.00 % 113 47 47 0 1.40
spec/unit/models/list_message_direction_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/list_message_item_spec.rb 100.00 % 165 53 53 0 1.08
spec/unit/models/lookup_error_response_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/lookup_error_schema_meta_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/lookup_error_schema_spec.rb 100.00 % 105 45 45 0 1.09
spec/unit/models/lookup_result_spec.rb 100.00 % 108 42 42 0 1.10
spec/unit/models/machine_detection_complete_callback_spec.rb 100.00 % 123 46 46 0 1.09
spec/unit/models/machine_detection_configuration_spec.rb 100.00 % 173 64 64 0 1.06
spec/unit/models/machine_detection_mode_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/machine_detection_result_spec.rb 100.00 % 68 32 32 0 1.13
spec/unit/models/media_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/message_direction_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/message_request_spec.rb 100.00 % 131 54 54 0 1.11
spec/unit/models/message_spec.rb 100.00 % 126 50 50 0 1.12
spec/unit/models/message_status_enum_spec.rb 100.00 % 70 34 34 0 1.00
spec/unit/models/message_type_enum_spec.rb 100.00 % 40 19 19 0 1.00
spec/unit/models/messages_list_spec.rb 100.00 % 79 35 35 0 1.29
spec/unit/models/messaging_code_response_spec.rb 100.00 % 64 31 31 0 1.13
spec/unit/models/messaging_request_error_spec.rb 100.00 % 89 40 40 0 1.10
spec/unit/models/mfa_forbidden_request_error_spec.rb 100.00 % 64 31 31 0 1.13
spec/unit/models/mfa_request_error_spec.rb 100.00 % 68 32 32 0 1.13
spec/unit/models/mfa_unauthorized_request_error_spec.rb 100.00 % 64 31 31 0 1.13
spec/unit/models/mms_message_content_file_spec.rb 100.00 % 81 38 38 0 1.11
spec/unit/models/mms_message_content_spec.rb 100.00 % 82 40 40 0 1.10
spec/unit/models/multi_channel_action_calendar_event_spec.rb 100.00 % 163 68 68 0 1.07
spec/unit/models/multi_channel_action_spec.rb 100.00 % 93 48 48 0 1.58
spec/unit/models/multi_channel_channel_list_mms_object_spec.rb 100.00 % 114 49 49 0 1.08
spec/unit/models/multi_channel_channel_list_mms_response_object_spec.rb 100.00 % 126 53 53 0 1.08
spec/unit/models/multi_channel_channel_list_object_base_spec.rb 100.00 % 101 44 44 0 1.09
spec/unit/models/multi_channel_channel_list_owner_object_spec.rb 100.00 % 77 36 36 0 1.11
spec/unit/models/multi_channel_channel_list_rbm_object_all_of_content_spec.rb 100.00 % 28 13 13 0 1.00
spec/unit/models/multi_channel_channel_list_rbm_object_spec.rb 100.00 % 114 49 49 0 1.08
spec/unit/models/multi_channel_channel_list_rbm_response_object_spec.rb 100.00 % 126 53 53 0 1.08
spec/unit/models/multi_channel_channel_list_request_object_spec.rb 100.00 % 70 36 36 0 1.17
spec/unit/models/multi_channel_channel_list_response_object_spec.rb 100.00 % 70 36 36 0 1.17
spec/unit/models/multi_channel_channel_list_sms_object_spec.rb 100.00 % 114 49 49 0 1.08
spec/unit/models/multi_channel_channel_list_sms_response_object_spec.rb 100.00 % 126 53 53 0 1.08
spec/unit/models/multi_channel_error_spec.rb 100.00 % 76 37 37 0 1.11
spec/unit/models/multi_channel_message_channel_enum_spec.rb 100.00 % 40 19 19 0 1.00
spec/unit/models/multi_channel_message_content_spec.rb 100.00 % 69 33 33 0 1.12
spec/unit/models/multi_channel_message_request_spec.rb 100.00 % 125 48 48 0 1.19
spec/unit/models/multi_channel_message_response_data_spec.rb 100.00 % 168 62 62 0 1.18
spec/unit/models/opt_in_workflow_spec.rb 100.00 % 111 50 50 0 1.12
spec/unit/models/page_info_spec.rb 100.00 % 76 34 34 0 1.12
spec/unit/models/page_spec.rb 100.00 % 121 56 56 0 1.13
spec/unit/models/priority_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/product_type_enum_spec.rb 100.00 % 76 37 37 0 1.00
spec/unit/models/rbm_action_base_spec.rb 100.00 % 109 48 48 0 1.08
spec/unit/models/rbm_action_dial_spec.rb 100.00 % 121 52 52 0 1.08
spec/unit/models/rbm_action_open_url_spec.rb 100.00 % 133 56 56 0 1.07
spec/unit/models/rbm_action_type_enum_spec.rb 100.00 % 58 28 28 0 1.00
spec/unit/models/rbm_action_view_location_spec.rb 100.00 % 147 62 62 0 1.08
spec/unit/models/rbm_card_content_media_spec.rb 100.00 % 107 48 48 0 1.10
spec/unit/models/rbm_card_content_spec.rb 100.00 % 122 51 51 0 1.18
spec/unit/models/rbm_location_response_spec.rb 100.00 % 68 32 32 0 1.13
spec/unit/models/rbm_media_height_enum_spec.rb 100.00 % 40 19 19 0 1.00
spec/unit/models/rbm_message_carousel_card_spec.rb 100.00 % 123 52 52 0 1.31
spec/unit/models/rbm_message_content_file_spec.rb 100.00 % 95 44 44 0 1.11
spec/unit/models/rbm_message_content_rich_card_spec.rb 100.00 % 32 14 14 0 1.07
spec/unit/models/rbm_message_content_text_spec.rb 100.00 % 100 45 45 0 1.20
spec/unit/models/rbm_message_media_spec.rb 100.00 % 103 46 46 0 1.35
spec/unit/models/rbm_open_url_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/rbm_standalone_card_spec.rb 100.00 % 118 49 49 0 1.27
spec/unit/models/rbm_suggestion_response_spec.rb 100.00 % 80 38 38 0 1.13
spec/unit/models/rbm_web_view_enum_spec.rb 100.00 % 40 19 19 0 1.00
spec/unit/models/recording_available_callback_spec.rb 100.00 % 152 52 52 0 1.08
spec/unit/models/recording_complete_callback_spec.rb 100.00 % 153 52 52 0 1.08
spec/unit/models/recording_state_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/recording_transcription_metadata_spec.rb 100.00 % 76 34 34 0 1.12
spec/unit/models/recording_transcriptions_spec.rb 100.00 % 69 34 34 0 1.12
spec/unit/models/redirect_callback_spec.rb 100.00 % 128 46 46 0 1.09
spec/unit/models/redirect_method_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/sip_connection_metadata_spec.rb 100.00 % 78 36 36 0 1.11
spec/unit/models/sip_credentials_spec.rb 100.00 % 68 32 32 0 1.13
spec/unit/models/sms_message_content_spec.rb 100.00 % 81 38 38 0 1.11
spec/unit/models/standalone_card_orientation_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/status_callback_message_spec.rb 100.00 % 181 69 69 0 1.17
spec/unit/models/status_callback_spec.rb 100.00 % 169 57 57 0 1.16
spec/unit/models/status_callback_type_enum_spec.rb 100.00 % 46 22 22 0 1.00
spec/unit/models/stir_shaken_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/sync_lookup_request_spec.rb 100.00 % 91 42 42 0 1.12
spec/unit/models/telephone_number_spec.rb 100.00 % 64 31 31 0 1.13
spec/unit/models/tfv_basic_authentication_spec.rb 100.00 % 97 44 44 0 1.09
spec/unit/models/tfv_callback_status_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/tfv_error_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/tfv_status_enum_spec.rb 100.00 % 40 19 19 0 1.00
spec/unit/models/tfv_status_spec.rb 100.00 % 130 54 54 0 1.07
spec/unit/models/tfv_submission_info_spec.rb 100.00 % 224 93 93 0 1.04
spec/unit/models/tfv_submission_wrapper_spec.rb 100.00 % 76 32 32 0 1.13
spec/unit/models/thumbnail_alignment_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/transcribe_recording_spec.rb 100.00 % 119 49 49 0 1.08
spec/unit/models/transcription_available_callback_spec.rb 100.00 % 150 53 53 0 1.08
spec/unit/models/transcription_spec.rb 100.00 % 68 32 32 0 1.13
spec/unit/models/transfer_answer_callback_spec.rb 100.00 % 124 45 45 0 1.09
spec/unit/models/transfer_complete_callback_spec.rb 100.00 % 138 48 48 0 1.08
spec/unit/models/transfer_disconnect_callback_spec.rb 100.00 % 146 50 50 0 1.08
spec/unit/models/update_call_recording_spec.rb 100.00 % 77 36 36 0 1.11
spec/unit/models/update_call_spec.rb 100.00 % 143 56 56 0 1.07
spec/unit/models/update_conference_member_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/update_conference_spec.rb 100.00 % 132 52 52 0 1.08
spec/unit/models/verification_denial_webhook_spec.rb 100.00 % 123 51 51 0 1.08
spec/unit/models/verification_request_spec.rb 100.00 % 313 123 123 0 1.26
spec/unit/models/verification_update_request_spec.rb 100.00 % 285 112 112 0 1.17
spec/unit/models/verification_webhook_spec.rb 100.00 % 96 44 44 0 1.09
spec/unit/models/verify_code_request_spec.rb 100.00 % 125 55 55 0 1.07
spec/unit/models/verify_code_response_spec.rb 100.00 % 64 31 31 0 1.13
spec/unit/models/voice_api_error_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/voice_code_response_spec.rb 100.00 % 64 31 31 0 1.13
spec/unit/models/webhook_subscription_basic_authentication_spec.rb 100.00 % 97 44 44 0 1.09
spec/unit/models/webhook_subscription_error_spec.rb 100.00 % 76 35 35 0 1.11
spec/unit/models/webhook_subscription_request_schema_spec.rb 100.00 % 99 46 46 0 1.13
spec/unit/models/webhook_subscription_spec.rb 100.00 % 100 43 43 0 1.12
spec/unit/models/webhook_subscription_type_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/webhook_subscriptions_list_body_spec.rb 100.00 % 91 40 40 0 1.13

Models ( 79.03% covered at 5.64 hits/line )

231 files in total.
16645 relevant lines, 13155 lines covered and 3490 lines missed. ( 79.03% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
lib/bandwidth-sdk/models/account_statistics.rb 82.81 % 156 64 53 11 2.84
lib/bandwidth-sdk/models/additional_denial_reason.rb 74.73 % 217 91 68 23 4.86
lib/bandwidth-sdk/models/address.rb 60.71 % 434 196 119 77 9.69
lib/bandwidth-sdk/models/answer_callback.rb 84.68 % 301 111 94 17 4.94
lib/bandwidth-sdk/models/async_lookup_request.rb 78.57 % 165 70 55 15 2.66
lib/bandwidth-sdk/models/blocked_webhook.rb 75.00 % 256 108 81 27 3.37
lib/bandwidth-sdk/models/bridge_complete_callback.rb 85.47 % 323 117 100 17 5.25
lib/bandwidth-sdk/models/bridge_target_complete_callback.rb 84.26 % 291 108 91 17 4.77
lib/bandwidth-sdk/models/brtc_error.rb 80.90 % 219 89 72 17 13.53
lib/bandwidth-sdk/models/brtc_error_response.rb 80.23 % 204 86 69 17 3.30
lib/bandwidth-sdk/models/brtc_error_source.rb 87.14 % 176 70 61 9 4.77
lib/bandwidth-sdk/models/brtc_link.rb 83.58 % 166 67 56 11 15.69
lib/bandwidth-sdk/models/business_entity_type_enum.rb 100.00 % 43 16 16 0 2.75
lib/bandwidth-sdk/models/business_registration_type_enum.rb 100.00 % 56 29 29 0 3.31
lib/bandwidth-sdk/models/bxml/bxml.rb 100.00 % 11 5 5 0 2.00
lib/bandwidth-sdk/models/bxml/nestable_verb.rb 90.91 % 46 22 20 2 33.00
lib/bandwidth-sdk/models/bxml/response.rb 100.00 % 11 5 5 0 2.00
lib/bandwidth-sdk/models/bxml/root.rb 100.00 % 47 25 25 0 6.40
lib/bandwidth-sdk/models/bxml/verb.rb 95.45 % 50 22 21 1 58.59
lib/bandwidth-sdk/models/bxml/verbs/bridge.rb 100.00 % 28 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/conference.rb 100.00 % 28 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/custom_param.rb 100.00 % 16 6 6 0 3.00
lib/bandwidth-sdk/models/bxml/verbs/forward.rb 100.00 % 20 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/gather.rb 100.00 % 42 11 11 0 3.00
lib/bandwidth-sdk/models/bxml/verbs/hangup.rb 100.00 % 10 5 5 0 1.20
lib/bandwidth-sdk/models/bxml/verbs/pause.rb 100.00 % 15 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/pause_recording.rb 100.00 % 10 5 5 0 2.80
lib/bandwidth-sdk/models/bxml/verbs/phone_number.rb 100.00 % 27 6 6 0 2.67
lib/bandwidth-sdk/models/bxml/verbs/play_audio.rb 100.00 % 17 6 6 0 2.67
lib/bandwidth-sdk/models/bxml/verbs/record.rb 100.00 % 32 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/redirect.rb 100.00 % 23 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/resume_recording.rb 100.00 % 10 5 5 0 1.20
lib/bandwidth-sdk/models/bxml/verbs/ring.rb 100.00 % 16 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/send_dtmf.rb 100.00 % 17 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/sip_uri.rb 100.00 % 27 6 6 0 2.00
lib/bandwidth-sdk/models/bxml/verbs/speak_sentence.rb 100.00 % 25 9 9 0 2.11
lib/bandwidth-sdk/models/bxml/verbs/start_gather.rb 100.00 % 19 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/start_recording.rb 100.00 % 24 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/start_stream.rb 100.00 % 31 8 8 0 2.38
lib/bandwidth-sdk/models/bxml/verbs/start_transcription.rb 100.00 % 29 8 8 0 2.38
lib/bandwidth-sdk/models/bxml/verbs/stop_gather.rb 100.00 % 10 5 5 0 1.20
lib/bandwidth-sdk/models/bxml/verbs/stop_recording.rb 100.00 % 10 5 5 0 1.20
lib/bandwidth-sdk/models/bxml/verbs/stop_stream.rb 100.00 % 16 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/stop_transcription.rb 100.00 % 15 6 6 0 1.67
lib/bandwidth-sdk/models/bxml/verbs/stream_param.rb 100.00 % 16 6 6 0 3.00
lib/bandwidth-sdk/models/bxml/verbs/tag.rb 100.00 % 11 5 5 0 1.20
lib/bandwidth-sdk/models/bxml/verbs/transfer.rb 100.00 % 35 8 8 0 2.38
lib/bandwidth-sdk/models/call_direction_enum.rb 100.00 % 40 13 13 0 6.69
lib/bandwidth-sdk/models/call_recording_metadata.rb 86.51 % 347 126 109 17 9.40
lib/bandwidth-sdk/models/call_state.rb 88.71 % 349 124 110 14 9.10
lib/bandwidth-sdk/models/call_state_enum.rb 100.00 % 40 13 13 0 1.77
lib/bandwidth-sdk/models/call_transcription.rb 75.79 % 224 95 72 23 5.40
lib/bandwidth-sdk/models/call_transcription_detected_language_enum.rb 100.00 % 41 14 14 0 2.43
lib/bandwidth-sdk/models/call_transcription_metadata.rb 83.58 % 166 67 56 11 3.39
lib/bandwidth-sdk/models/call_transcription_response.rb 87.32 % 177 71 62 9 3.93
lib/bandwidth-sdk/models/call_transcription_track_enum.rb 100.00 % 40 13 13 0 2.31
lib/bandwidth-sdk/models/callback.rb 100.00 % 61 17 17 0 4.76
lib/bandwidth-sdk/models/callback_method_enum.rb 100.00 % 40 13 13 0 5.38
lib/bandwidth-sdk/models/card_width_enum.rb 100.00 % 40 13 13 0 2.00
lib/bandwidth-sdk/models/code_request.rb 66.46 % 367 164 109 55 6.41
lib/bandwidth-sdk/models/completed_lookup_status_enum.rb 100.00 % 41 14 14 0 2.36
lib/bandwidth-sdk/models/conference.rb 84.21 % 246 95 80 15 5.97
lib/bandwidth-sdk/models/conference_completed_callback.rb 84.93 % 188 73 62 11 3.37
lib/bandwidth-sdk/models/conference_created_callback.rb 84.93 % 188 73 62 11 3.37
lib/bandwidth-sdk/models/conference_member.rb 90.91 % 199 77 70 7 8.10
lib/bandwidth-sdk/models/conference_member_exit_callback.rb 86.59 % 218 82 71 11 4.21
lib/bandwidth-sdk/models/conference_member_join_callback.rb 86.59 % 218 82 71 11 4.21
lib/bandwidth-sdk/models/conference_recording_available_callback.rb 84.68 % 300 111 94 17 4.94
lib/bandwidth-sdk/models/conference_recording_metadata.rb 83.81 % 278 105 88 17 7.54
lib/bandwidth-sdk/models/conference_redirect_callback.rb 84.93 % 188 73 62 11 3.37
lib/bandwidth-sdk/models/conference_state_enum.rb 100.00 % 40 13 13 0 1.77
lib/bandwidth-sdk/models/contact.rb 62.42 % 326 149 93 56 7.89
lib/bandwidth-sdk/models/create_async_bulk_lookup_response.rb 86.96 % 168 69 60 9 3.48
lib/bandwidth-sdk/models/create_async_bulk_lookup_response_data.rb 77.33 % 178 75 58 17 3.75
lib/bandwidth-sdk/models/create_call.rb 71.54 % 661 267 191 76 7.55
lib/bandwidth-sdk/models/create_call_response.rb 73.97 % 562 219 162 57 8.02
lib/bandwidth-sdk/models/create_endpoint_request_base.rb 75.96 % 250 104 79 25 3.39
lib/bandwidth-sdk/models/create_endpoint_response.rb 77.42 % 218 93 72 21 4.17
lib/bandwidth-sdk/models/create_endpoint_response_data.rb 74.32 % 356 148 110 38 8.52
lib/bandwidth-sdk/models/create_message_request_error.rb 79.76 % 199 84 67 17 3.01
lib/bandwidth-sdk/models/create_multi_channel_message_response.rb 89.86 % 167 69 62 7 3.30
lib/bandwidth-sdk/models/create_sync_lookup_response.rb 86.96 % 167 69 60 9 3.46
lib/bandwidth-sdk/models/create_sync_lookup_response_data.rb 83.54 % 190 79 66 13 4.49
lib/bandwidth-sdk/models/create_web_rtc_connection_request.rb 76.15 % 266 109 83 26 4.07
lib/bandwidth-sdk/models/deactivation_event_enum.rb 100.00 % 39 12 12 0 2.58
lib/bandwidth-sdk/models/device.rb 75.23 % 258 109 82 27 7.02
lib/bandwidth-sdk/models/device_status_enum.rb 100.00 % 40 13 13 0 2.46
lib/bandwidth-sdk/models/disconnect_callback.rb 85.83 % 333 120 103 17 5.39
lib/bandwidth-sdk/models/diversion.rb 86.08 % 206 79 68 11 4.77
lib/bandwidth-sdk/models/dtmf_callback.rb 85.83 % 331 120 103 17 5.39
lib/bandwidth-sdk/models/endpoint.rb 75.18 % 329 137 103 34 7.82
lib/bandwidth-sdk/models/endpoint_direction_enum.rb 100.00 % 41 14 14 0 2.14
lib/bandwidth-sdk/models/endpoint_event.rb 70.89 % 381 158 112 46 5.18
lib/bandwidth-sdk/models/endpoint_event_type_enum.rb 100.00 % 40 13 13 0 1.77
lib/bandwidth-sdk/models/endpoint_response.rb 77.42 % 218 93 72 21 4.17
lib/bandwidth-sdk/models/endpoint_status_enum.rb 100.00 % 40 13 13 0 4.31
lib/bandwidth-sdk/models/endpoint_type_enum.rb 100.00 % 39 12 12 0 4.83
lib/bandwidth-sdk/models/endpoints.rb 73.28 % 311 131 96 35 8.30
lib/bandwidth-sdk/models/error_object.rb 74.73 % 216 91 68 23 6.42
lib/bandwidth-sdk/models/error_source.rb 87.14 % 177 70 61 9 6.94
lib/bandwidth-sdk/models/failure_webhook.rb 80.61 % 237 98 79 19 3.71
lib/bandwidth-sdk/models/field_error.rb 82.81 % 156 64 53 11 3.77
lib/bandwidth-sdk/models/file_format_enum.rb 100.00 % 40 13 13 0 4.15
lib/bandwidth-sdk/models/gather_callback.rb 86.18 % 341 123 106 17 5.53
lib/bandwidth-sdk/models/get_async_bulk_lookup_response.rb 86.96 % 167 69 60 9 3.46
lib/bandwidth-sdk/models/get_async_bulk_lookup_response_data.rb 83.54 % 190 79 66 13 4.35
lib/bandwidth-sdk/models/in_progress_lookup_status_enum.rb 100.00 % 42 15 15 0 2.87
lib/bandwidth-sdk/models/inbound_callback.rb 70.87 % 301 127 90 37 4.60
lib/bandwidth-sdk/models/inbound_callback_message.rb 73.51 % 457 185 136 49 8.46
lib/bandwidth-sdk/models/inbound_callback_type_enum.rb 100.00 % 41 14 14 0 1.93
lib/bandwidth-sdk/models/initiate_callback.rb 81.20 % 305 117 95 22 4.51
lib/bandwidth-sdk/models/latest_message_delivery_status_enum.rb 100.00 % 42 15 15 0 3.67
lib/bandwidth-sdk/models/line_type_enum.rb 100.00 % 42 15 15 0 3.67
lib/bandwidth-sdk/models/link.rb 82.81 % 154 64 53 11 5.23
lib/bandwidth-sdk/models/link_schema.rb 83.58 % 166 67 56 11 10.79
lib/bandwidth-sdk/models/links_object.rb 84.29 % 176 70 59 11 4.39
lib/bandwidth-sdk/models/list_endpoints_response.rb 78.35 % 229 97 76 21 4.73
lib/bandwidth-sdk/models/list_message_direction_enum.rb 100.00 % 40 13 13 0 2.08
lib/bandwidth-sdk/models/list_message_item.rb 89.13 % 397 138 123 15 11.78
lib/bandwidth-sdk/models/lookup_error_response.rb 86.96 % 168 69 60 9 2.75
lib/bandwidth-sdk/models/lookup_error_schema.rb 77.66 % 226 94 73 21 10.52
lib/bandwidth-sdk/models/lookup_error_schema_meta.rb 86.76 % 167 68 59 9 4.62
lib/bandwidth-sdk/models/lookup_result.rb 85.71 % 276 105 90 15 19.77
lib/bandwidth-sdk/models/machine_detection_complete_callback.rb 84.68 % 301 111 94 17 4.94
lib/bandwidth-sdk/models/machine_detection_configuration.rb 78.66 % 426 164 129 35 5.79
lib/bandwidth-sdk/models/machine_detection_mode_enum.rb 100.00 % 40 13 13 0 1.77
lib/bandwidth-sdk/models/machine_detection_result.rb 82.81 % 157 64 53 11 3.39
lib/bandwidth-sdk/models/media.rb 83.58 % 163 67 56 11 3.39
lib/bandwidth-sdk/models/message.rb 87.29 % 310 118 103 15 7.19
lib/bandwidth-sdk/models/message_direction_enum.rb 100.00 % 40 13 13 0 3.54
lib/bandwidth-sdk/models/message_request.rb 78.13 % 311 128 100 28 5.01
lib/bandwidth-sdk/models/message_status_enum.rb 100.00 % 46 19 19 0 2.68
lib/bandwidth-sdk/models/message_type_enum.rb 100.00 % 41 14 14 0 2.21
lib/bandwidth-sdk/models/messages_list.rb 86.76 % 166 68 59 9 3.44
lib/bandwidth-sdk/models/messaging_code_response.rb 81.97 % 146 61 50 11 2.25
lib/bandwidth-sdk/models/messaging_request_error.rb 76.25 % 188 80 61 19 2.66
lib/bandwidth-sdk/models/mfa_forbidden_request_error.rb 81.97 % 146 61 50 11 1.87
lib/bandwidth-sdk/models/mfa_request_error.rb 82.81 % 156 64 53 11 2.30
lib/bandwidth-sdk/models/mfa_unauthorized_request_error.rb 81.97 % 146 61 50 11 1.87
lib/bandwidth-sdk/models/mms_message_content.rb 86.49 % 176 74 64 10 5.86
lib/bandwidth-sdk/models/mms_message_content_file.rb 75.68 % 172 74 56 18 3.22
lib/bandwidth-sdk/models/multi_channel_action.rb 100.00 % 61 17 17 0 6.59
lib/bandwidth-sdk/models/multi_channel_action_calendar_event.rb 67.07 % 382 164 110 54 4.63
lib/bandwidth-sdk/models/multi_channel_channel_list_mms_object.rb 70.43 % 271 115 81 34 3.26
lib/bandwidth-sdk/models/multi_channel_channel_list_mms_response_object.rb 69.84 % 299 126 88 38 3.67
lib/bandwidth-sdk/models/multi_channel_channel_list_object_base.rb 71.57 % 238 102 73 29 2.87
lib/bandwidth-sdk/models/multi_channel_channel_list_owner_object.rb 78.26 % 163 69 54 15 2.09
lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_object.rb 70.43 % 271 115 81 34 3.26
lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_object_all_of_content.rb 67.50 % 105 40 27 13 4.20
lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_response_object.rb 69.84 % 299 126 88 38 4.31
lib/bandwidth-sdk/models/multi_channel_channel_list_request_object.rb 100.00 % 56 17 17 0 3.18
lib/bandwidth-sdk/models/multi_channel_channel_list_response_object.rb 100.00 % 56 17 17 0 3.59
lib/bandwidth-sdk/models/multi_channel_channel_list_sms_object.rb 70.43 % 271 115 81 34 5.52
lib/bandwidth-sdk/models/multi_channel_channel_list_sms_response_object.rb 69.84 % 299 126 88 38 6.00
lib/bandwidth-sdk/models/multi_channel_error.rb 86.96 % 168 69 60 9 2.75
lib/bandwidth-sdk/models/multi_channel_message_channel_enum.rb 100.00 % 41 14 14 0 4.29
lib/bandwidth-sdk/models/multi_channel_message_content.rb 82.81 % 155 64 53 11 2.30
lib/bandwidth-sdk/models/multi_channel_message_request.rb 77.36 % 253 106 82 24 3.89
lib/bandwidth-sdk/models/multi_channel_message_response_data.rb 74.29 % 335 140 104 36 5.76
lib/bandwidth-sdk/models/opt_in_workflow.rb 74.53 % 242 106 79 27 6.49
lib/bandwidth-sdk/models/page.rb 75.45 % 259 110 83 27 7.15
lib/bandwidth-sdk/models/page_info.rb 84.29 % 176 70 59 11 6.09
lib/bandwidth-sdk/models/priority_enum.rb 100.00 % 40 13 13 0 3.54
lib/bandwidth-sdk/models/product_type_enum.rb 100.00 % 47 20 20 0 2.45
lib/bandwidth-sdk/models/rbm_action_base.rb 68.75 % 256 112 77 35 12.13
lib/bandwidth-sdk/models/rbm_action_dial.rb 68.00 % 290 125 85 40 3.46
lib/bandwidth-sdk/models/rbm_action_open_url.rb 68.38 % 317 136 93 43 3.95
lib/bandwidth-sdk/models/rbm_action_type_enum.rb 100.00 % 44 17 17 0 4.06
lib/bandwidth-sdk/models/rbm_action_view_location.rb 68.24 % 346 148 101 47 4.17
lib/bandwidth-sdk/models/rbm_card_content.rb 83.67 % 235 98 82 16 8.95
lib/bandwidth-sdk/models/rbm_card_content_media.rb 72.73 % 256 110 80 30 4.25
lib/bandwidth-sdk/models/rbm_location_response.rb 82.81 % 156 64 53 11 2.30
lib/bandwidth-sdk/models/rbm_media_height_enum.rb 100.00 % 41 14 14 0 2.14
lib/bandwidth-sdk/models/rbm_message_carousel_card.rb 72.17 % 261 115 83 32 3.74
lib/bandwidth-sdk/models/rbm_message_content_file.rb 77.91 % 201 86 67 19 5.58
lib/bandwidth-sdk/models/rbm_message_content_rich_card.rb 60.00 % 103 40 24 16 4.95
lib/bandwidth-sdk/models/rbm_message_content_text.rb 80.46 % 203 87 70 17 6.63
lib/bandwidth-sdk/models/rbm_message_media.rb 79.52 % 195 83 66 17 3.45
lib/bandwidth-sdk/models/rbm_open_url_enum.rb 100.00 % 40 13 13 0 1.77
lib/bandwidth-sdk/models/rbm_standalone_card.rb 75.70 % 250 107 81 26 3.99
lib/bandwidth-sdk/models/rbm_suggestion_response.rb 80.82 % 175 73 59 14 2.48
lib/bandwidth-sdk/models/rbm_web_view_enum.rb 100.00 % 41 14 14 0 1.93
lib/bandwidth-sdk/models/recording_available_callback.rb 87.41 % 380 135 118 17 6.01
lib/bandwidth-sdk/models/recording_complete_callback.rb 87.41 % 381 135 118 17 6.01
lib/bandwidth-sdk/models/recording_state_enum.rb 100.00 % 40 13 13 0 1.77
lib/bandwidth-sdk/models/recording_transcription_metadata.rb 84.29 % 177 70 59 11 4.73
lib/bandwidth-sdk/models/recording_transcriptions.rb 82.26 % 147 62 51 11 2.32
lib/bandwidth-sdk/models/redirect_callback.rb 85.47 % 321 117 100 17 5.25
lib/bandwidth-sdk/models/redirect_method_enum.rb 100.00 % 40 13 13 0 2.46
lib/bandwidth-sdk/models/sip_connection_metadata.rb 84.29 % 175 70 59 11 3.04
lib/bandwidth-sdk/models/sip_credentials.rb 82.81 % 156 64 53 11 3.77
lib/bandwidth-sdk/models/sms_message_content.rb 75.68 % 172 74 56 18 7.74
lib/bandwidth-sdk/models/standalone_card_orientation_enum.rb 100.00 % 40 13 13 0 2.00
lib/bandwidth-sdk/models/status_callback.rb 72.18 % 321 133 96 37 5.19
lib/bandwidth-sdk/models/status_callback_message.rb 72.99 % 424 174 127 47 8.37
lib/bandwidth-sdk/models/status_callback_type_enum.rb 100.00 % 42 15 15 0 2.07
lib/bandwidth-sdk/models/stir_shaken.rb 83.58 % 166 67 56 11 3.39
lib/bandwidth-sdk/models/sync_lookup_request.rb 79.76 % 196 84 67 17 3.58
lib/bandwidth-sdk/models/telephone_number.rb 81.97 % 146 61 50 11 3.30
lib/bandwidth-sdk/models/tfv_basic_authentication.rb 72.22 % 206 90 65 25 4.63
lib/bandwidth-sdk/models/tfv_callback_status_enum.rb 100.00 % 40 13 13 0 2.00
lib/bandwidth-sdk/models/tfv_error.rb 83.58 % 165 67 56 11 2.69
lib/bandwidth-sdk/models/tfv_status.rb 74.81 % 330 135 101 34 5.27
lib/bandwidth-sdk/models/tfv_status_enum.rb 100.00 % 41 14 14 0 2.21
lib/bandwidth-sdk/models/tfv_submission_info.rb 69.70 % 550 231 161 70 6.19
lib/bandwidth-sdk/models/tfv_submission_wrapper.rb 81.97 % 145 61 50 11 2.13
lib/bandwidth-sdk/models/thumbnail_alignment_enum.rb 100.00 % 40 13 13 0 2.00
lib/bandwidth-sdk/models/transcribe_recording.rb 77.31 % 293 119 92 27 4.01
lib/bandwidth-sdk/models/transcription.rb 82.81 % 156 64 53 11 4.86
lib/bandwidth-sdk/models/transcription_available_callback.rb 87.12 % 369 132 115 17 5.90
lib/bandwidth-sdk/models/transfer_answer_callback.rb 85.09 % 311 114 97 17 5.10
lib/bandwidth-sdk/models/transfer_complete_callback.rb 86.18 % 343 123 106 17 5.53
lib/bandwidth-sdk/models/transfer_disconnect_callback.rb 86.82 % 363 129 112 17 5.78
lib/bandwidth-sdk/models/update_call.rb 78.10 % 346 137 107 30 4.78
lib/bandwidth-sdk/models/update_call_recording.rb 73.75 % 184 80 59 21 2.09
lib/bandwidth-sdk/models/update_conference.rb 77.17 % 320 127 98 29 4.57
lib/bandwidth-sdk/models/update_conference_member.rb 89.71 % 169 68 61 7 3.13
lib/bandwidth-sdk/models/verification_denial_webhook.rb 82.88 % 278 111 92 19 4.63
lib/bandwidth-sdk/models/verification_request.rb 64.13 % 763 329 211 118 11.06
lib/bandwidth-sdk/models/verification_update_request.rb 64.55 % 700 299 193 106 11.04
lib/bandwidth-sdk/models/verification_webhook.rb 73.53 % 236 102 75 27 2.92
lib/bandwidth-sdk/models/verify_code_request.rb 67.77 % 274 121 82 39 4.37
lib/bandwidth-sdk/models/verify_code_response.rb 81.97 % 146 61 50 11 2.89
lib/bandwidth-sdk/models/voice_api_error.rb 83.58 % 164 67 56 11 2.69
lib/bandwidth-sdk/models/voice_code_response.rb 81.97 % 146 61 50 11 2.25
lib/bandwidth-sdk/models/webhook_subscription.rb 76.36 % 261 110 84 26 8.49
lib/bandwidth-sdk/models/webhook_subscription_basic_authentication.rb 72.22 % 207 90 65 25 5.79
lib/bandwidth-sdk/models/webhook_subscription_error.rb 89.71 % 165 68 61 7 5.31
lib/bandwidth-sdk/models/webhook_subscription_request_schema.rb 68.87 % 239 106 73 33 3.58
lib/bandwidth-sdk/models/webhook_subscription_type_enum.rb 100.00 % 40 13 13 0 2.69
lib/bandwidth-sdk/models/webhook_subscriptions_list_body.rb 83.12 % 185 77 64 13 3.73

APIs ( 95.65% covered at 1.32 hits/line )

12 files in total.
1495 relevant lines, 1430 lines covered and 65 lines missed. ( 95.65% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
lib/bandwidth-sdk/api/calls_api.rb 95.04 % 417 141 134 7 1.27
lib/bandwidth-sdk/api/conferences_api.rb 97.50 % 717 240 234 6 1.48
lib/bandwidth-sdk/api/endpoints_api.rb 96.24 % 397 133 128 5 1.27
lib/bandwidth-sdk/api/media_api.rb 98.04 % 312 102 100 2 1.30
lib/bandwidth-sdk/api/messages_api.rb 97.50 % 240 80 78 2 1.11
lib/bandwidth-sdk/api/mfa_api.rb 96.43 % 244 84 81 3 1.25
lib/bandwidth-sdk/api/multi_channel_api.rb 96.88 % 96 32 31 1 1.22
lib/bandwidth-sdk/api/phone_number_lookup_api.rb 96.30 % 239 81 78 3 1.26
lib/bandwidth-sdk/api/recordings_api.rb 93.00 % 782 257 239 18 1.42
lib/bandwidth-sdk/api/statistics_api.rb 96.30 % 85 27 26 1 1.07
lib/bandwidth-sdk/api/toll_free_verification_api.rb 93.75 % 696 240 225 15 1.25
lib/bandwidth-sdk/api/transcriptions_api.rb 97.44 % 241 78 76 2 1.44

Client ( 94.22% covered at 32.28 hits/line )

6 files in total.
658 relevant lines, 620 lines covered and 38 lines missed. ( 94.22% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
lib/bandwidth-sdk.rb 99.61 % 285 254 253 1 1.09
lib/bandwidth-sdk/api_client.rb 84.66 % 441 189 160 29 19.23
lib/bandwidth-sdk/api_error.rb 95.45 % 58 22 21 1 1.64
lib/bandwidth-sdk/api_model_base.rb 94.29 % 88 35 33 2 429.60
lib/bandwidth-sdk/configuration.rb 96.79 % 771 156 151 5 14.44
lib/bandwidth-sdk/version.rb 100.00 % 15 2 2 0 1.00

Tests ( 100.0% covered at 1.12 hits/line )

245 files in total.
9922 relevant lines, 9922 lines covered and 0 lines missed. ( 100.0% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
spec/unit/api/calls_api_spec.rb 100.00 % 233 128 128 0 1.02
spec/unit/api/conferences_api_spec.rb 100.00 % 331 184 184 0 1.07
spec/unit/api/endpoints_api_spec.rb 100.00 % 172 100 100 0 1.03
spec/unit/api/media_api_spec.rb 100.00 % 115 61 61 0 1.07
spec/unit/api/messages_api_spec.rb 100.00 % 109 77 77 0 1.00
spec/unit/api/mfa_api_spec.rb 100.00 % 114 53 53 0 1.08
spec/unit/api/multi_channel_api_spec.rb 100.00 % 70 36 36 0 1.00
spec/unit/api/phone_number_lookup_api_spec.rb 100.00 % 131 84 84 0 1.10
spec/unit/api/recordings_api_spec.rb 100.00 % 371 194 194 0 1.07
spec/unit/api/statistics_api_spec.rb 100.00 % 37 22 22 0 1.00
spec/unit/api/toll_free_verification_api_spec.rb 100.00 % 306 164 164 0 1.10
spec/unit/api/transcriptions_api_spec.rb 100.00 % 112 65 65 0 1.08
spec/unit/client/api_client_spec.rb 100.00 % 377 122 122 0 1.16
spec/unit/client/api_error_spec.rb 100.00 % 23 13 13 0 1.00
spec/unit/client/configuration_spec.rb 100.00 % 277 166 166 0 1.43
spec/unit/models/account_statistics_spec.rb 100.00 % 68 32 32 0 1.13
spec/unit/models/additional_denial_reason_spec.rb 100.00 % 101 44 44 0 1.09
spec/unit/models/address_spec.rb 100.00 % 187 80 80 0 1.05
spec/unit/models/answer_callback_spec.rb 100.00 % 123 46 46 0 1.09
spec/unit/models/async_lookup_request_spec.rb 100.00 % 77 36 36 0 1.14
spec/unit/models/blocked_webhook_spec.rb 100.00 % 104 46 46 0 1.09
spec/unit/models/bridge_complete_callback_spec.rb 100.00 % 130 46 46 0 1.09
spec/unit/models/bridge_target_complete_callback_spec.rb 100.00 % 116 43 43 0 1.09
spec/unit/models/brtc_error_response_spec.rb 100.00 % 93 41 41 0 1.15
spec/unit/models/brtc_error_source_spec.rb 100.00 % 76 34 34 0 1.12
spec/unit/models/brtc_error_spec.rb 100.00 % 101 43 43 0 1.09
spec/unit/models/brtc_link_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/business_entity_type_enum_spec.rb 100.00 % 52 25 25 0 1.00
spec/unit/models/business_registration_type_enum_spec.rb 100.00 % 130 64 64 0 1.00
spec/unit/models/bxml/bxml_spec.rb 100.00 % 41 26 26 0 1.31
spec/unit/models/bxml/nestable_verb_spec.rb 100.00 % 11 6 6 0 1.17
spec/unit/models/bxml/response_spec.rb 100.00 % 41 26 26 0 1.31
spec/unit/models/bxml/verb_spec.rb 100.00 % 15 8 8 0 1.25
spec/unit/models/bxml/verbs/bridge_spec.rb 100.00 % 58 17 17 0 1.29
spec/unit/models/bxml/verbs/conference_spec.rb 100.00 % 58 17 17 0 1.29
spec/unit/models/bxml/verbs/custom_param_spec.rb 100.00 % 36 17 17 0 1.29
spec/unit/models/bxml/verbs/forward_spec.rb 100.00 % 44 17 17 0 1.29
spec/unit/models/bxml/verbs/gather_spec.rb 100.00 % 86 34 34 0 1.44
spec/unit/models/bxml/verbs/hangup_spec.rb 100.00 % 16 9 9 0 1.22
spec/unit/models/bxml/verbs/pause_recording_spec.rb 100.00 % 16 9 9 0 1.22
spec/unit/models/bxml/verbs/pause_spec.rb 100.00 % 34 17 17 0 1.29
spec/unit/models/bxml/verbs/phone_number_spec.rb 100.00 % 56 17 17 0 1.29
spec/unit/models/bxml/verbs/play_audio_spec.rb 100.00 % 36 17 17 0 1.29
spec/unit/models/bxml/verbs/record_spec.rb 100.00 % 68 17 17 0 1.29
spec/unit/models/bxml/verbs/redirect_spec.rb 100.00 % 50 17 17 0 1.29
spec/unit/models/bxml/verbs/resume_recording_spec.rb 100.00 % 16 9 9 0 1.22
spec/unit/models/bxml/verbs/ring_spec.rb 100.00 % 36 17 17 0 1.29
spec/unit/models/bxml/verbs/send_dtmf_spec.rb 100.00 % 36 17 17 0 1.29
spec/unit/models/bxml/verbs/sip_uri_spec.rb 100.00 % 56 17 17 0 1.29
spec/unit/models/bxml/verbs/speak_sentence_spec.rb 100.00 % 38 17 17 0 1.29
spec/unit/models/bxml/verbs/start_gather_spec.rb 100.00 % 42 17 17 0 1.29
spec/unit/models/bxml/verbs/start_recording_spec.rb 100.00 % 52 17 17 0 1.29
spec/unit/models/bxml/verbs/start_stream_spec.rb 100.00 % 78 34 34 0 1.44
spec/unit/models/bxml/verbs/start_transcription_spec.rb 100.00 % 74 34 34 0 1.44
spec/unit/models/bxml/verbs/stop_gather_spec.rb 100.00 % 16 9 9 0 1.22
spec/unit/models/bxml/verbs/stop_recording_spec.rb 100.00 % 16 9 9 0 1.22
spec/unit/models/bxml/verbs/stop_stream_spec.rb 100.00 % 36 17 17 0 1.29
spec/unit/models/bxml/verbs/stop_transcription_spec.rb 100.00 % 34 17 17 0 1.29
spec/unit/models/bxml/verbs/stream_param_spec.rb 100.00 % 36 17 17 0 1.29
spec/unit/models/bxml/verbs/tag_spec.rb 100.00 % 16 9 9 0 1.22
spec/unit/models/bxml/verbs/transfer_spec.rb 100.00 % 86 34 34 0 1.44
spec/unit/models/call_direction_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/call_recording_metadata_spec.rb 100.00 % 137 48 48 0 1.08
spec/unit/models/call_state_enum_spec.rb 100.00 % 31 16 16 0 1.00
spec/unit/models/call_state_spec.rb 100.00 % 159 48 48 0 1.08
spec/unit/models/call_transcription_detected_language_enum_spec.rb 100.00 % 40 19 19 0 1.00
spec/unit/models/call_transcription_metadata_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/call_transcription_response_spec.rb 100.00 % 76 34 34 0 1.12
spec/unit/models/call_transcription_spec.rb 100.00 % 92 42 42 0 1.10
spec/unit/models/call_transcription_track_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/callback_method_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/callback_spec.rb 100.00 % 65 30 30 0 2.07
spec/unit/models/card_width_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/code_request_spec.rb 100.00 % 167 72 72 0 1.06
spec/unit/models/completed_lookup_status_enum_spec.rb 100.00 % 40 19 19 0 1.00
spec/unit/models/conference_completed_callback_spec.rb 100.00 % 82 35 35 0 1.11
spec/unit/models/conference_created_callback_spec.rb 100.00 % 82 35 35 0 1.11
spec/unit/models/conference_member_exit_callback_spec.rb 100.00 % 94 38 38 0 1.11
spec/unit/models/conference_member_join_callback_spec.rb 100.00 % 94 38 38 0 1.11
spec/unit/models/conference_member_spec.rb 100.00 % 84 36 36 0 1.11
spec/unit/models/conference_recording_available_callback_spec.rb 100.00 % 119 44 44 0 1.09
spec/unit/models/conference_recording_metadata_spec.rb 100.00 % 108 42 42 0 1.10
spec/unit/models/conference_redirect_callback_spec.rb 100.00 % 82 35 35 0 1.11
spec/unit/models/conference_spec.rb 100.00 % 98 38 38 0 1.11
spec/unit/models/conference_state_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/contact_spec.rb 100.00 % 145 64 64 0 1.06
spec/unit/models/create_async_bulk_lookup_response_data_spec.rb 100.00 % 68 32 32 0 1.13
spec/unit/models/create_async_bulk_lookup_response_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/create_call_response_spec.rb 100.00 % 242 86 86 0 1.05
spec/unit/models/create_call_spec.rb 100.00 % 278 105 105 0 1.04
spec/unit/models/create_endpoint_request_base_spec.rb 100.00 % 107 46 46 0 1.09
spec/unit/models/create_endpoint_response_data_spec.rb 100.00 % 151 61 61 0 1.07
spec/unit/models/create_endpoint_response_spec.rb 100.00 % 122 44 44 0 1.16
spec/unit/models/create_message_request_error_spec.rb 100.00 % 93 41 41 0 1.10
spec/unit/models/create_multi_channel_message_response_spec.rb 100.00 % 68 32 32 0 1.13
spec/unit/models/create_sync_lookup_response_data_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/create_sync_lookup_response_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/create_web_rtc_connection_request_spec.rb 100.00 % 111 47 47 0 1.09
spec/unit/models/deactivation_event_enum_spec.rb 100.00 % 28 13 13 0 1.00
spec/unit/models/device_spec.rb 100.00 % 111 48 48 0 1.08
spec/unit/models/device_status_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/disconnect_callback_spec.rb 100.00 % 134 47 47 0 1.09
spec/unit/models/diversion_spec.rb 100.00 % 88 37 37 0 1.11
spec/unit/models/dtmf_callback_spec.rb 100.00 % 132 47 47 0 1.09
spec/unit/models/endpoint_direction_enum_spec.rb 100.00 % 40 19 19 0 1.00
spec/unit/models/endpoint_event_spec.rb 100.00 % 163 65 65 0 1.06
spec/unit/models/endpoint_event_type_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/endpoint_response_spec.rb 100.00 % 108 45 45 0 1.29
spec/unit/models/endpoint_spec.rb 100.00 % 140 58 58 0 1.09
spec/unit/models/endpoint_status_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/endpoint_type_enum_spec.rb 100.00 % 28 13 13 0 1.00
spec/unit/models/endpoints_spec.rb 100.00 % 135 56 56 0 1.09
spec/unit/models/error_object_spec.rb 100.00 % 103 46 46 0 1.15
spec/unit/models/error_source_spec.rb 100.00 % 76 34 34 0 1.12
spec/unit/models/failure_webhook_spec.rb 100.00 % 104 46 46 0 1.09
spec/unit/models/field_error_spec.rb 100.00 % 68 32 32 0 1.13
spec/unit/models/file_format_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/gather_callback_spec.rb 100.00 % 136 48 48 0 1.08
spec/unit/models/get_async_bulk_lookup_response_data_spec.rb 100.00 % 74 35 35 0 1.20
spec/unit/models/get_async_bulk_lookup_response_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/in_progress_lookup_status_enum_spec.rb 100.00 % 46 22 22 0 1.00
spec/unit/models/inbound_callback_message_spec.rb 100.00 % 181 69 69 0 1.17
spec/unit/models/inbound_callback_spec.rb 100.00 % 161 55 55 0 1.16
spec/unit/models/inbound_callback_type_enum_spec.rb 100.00 % 40 19 19 0 1.00
spec/unit/models/initiate_callback_spec.rb 100.00 % 114 45 45 0 1.09
spec/unit/models/latest_message_delivery_status_enum_spec.rb 100.00 % 46 22 22 0 1.00
spec/unit/models/line_type_enum_spec.rb 100.00 % 46 22 22 0 1.00
spec/unit/models/link_schema_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/link_spec.rb 100.00 % 68 32 32 0 1.13
spec/unit/models/links_object_spec.rb 100.00 % 76 34 34 0 1.12
spec/unit/models/list_endpoints_response_spec.rb 100.00 % 113 47 47 0 1.40
spec/unit/models/list_message_direction_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/list_message_item_spec.rb 100.00 % 165 53 53 0 1.08
spec/unit/models/lookup_error_response_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/lookup_error_schema_meta_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/lookup_error_schema_spec.rb 100.00 % 105 45 45 0 1.09
spec/unit/models/lookup_result_spec.rb 100.00 % 108 42 42 0 1.10
spec/unit/models/machine_detection_complete_callback_spec.rb 100.00 % 123 46 46 0 1.09
spec/unit/models/machine_detection_configuration_spec.rb 100.00 % 173 64 64 0 1.06
spec/unit/models/machine_detection_mode_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/machine_detection_result_spec.rb 100.00 % 68 32 32 0 1.13
spec/unit/models/media_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/message_direction_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/message_request_spec.rb 100.00 % 131 54 54 0 1.11
spec/unit/models/message_spec.rb 100.00 % 126 50 50 0 1.12
spec/unit/models/message_status_enum_spec.rb 100.00 % 70 34 34 0 1.00
spec/unit/models/message_type_enum_spec.rb 100.00 % 40 19 19 0 1.00
spec/unit/models/messages_list_spec.rb 100.00 % 79 35 35 0 1.29
spec/unit/models/messaging_code_response_spec.rb 100.00 % 64 31 31 0 1.13
spec/unit/models/messaging_request_error_spec.rb 100.00 % 89 40 40 0 1.10
spec/unit/models/mfa_forbidden_request_error_spec.rb 100.00 % 64 31 31 0 1.13
spec/unit/models/mfa_request_error_spec.rb 100.00 % 68 32 32 0 1.13
spec/unit/models/mfa_unauthorized_request_error_spec.rb 100.00 % 64 31 31 0 1.13
spec/unit/models/mms_message_content_file_spec.rb 100.00 % 81 38 38 0 1.11
spec/unit/models/mms_message_content_spec.rb 100.00 % 82 40 40 0 1.10
spec/unit/models/multi_channel_action_calendar_event_spec.rb 100.00 % 163 68 68 0 1.07
spec/unit/models/multi_channel_action_spec.rb 100.00 % 93 48 48 0 1.58
spec/unit/models/multi_channel_channel_list_mms_object_spec.rb 100.00 % 114 49 49 0 1.08
spec/unit/models/multi_channel_channel_list_mms_response_object_spec.rb 100.00 % 126 53 53 0 1.08
spec/unit/models/multi_channel_channel_list_object_base_spec.rb 100.00 % 101 44 44 0 1.09
spec/unit/models/multi_channel_channel_list_owner_object_spec.rb 100.00 % 77 36 36 0 1.11
spec/unit/models/multi_channel_channel_list_rbm_object_all_of_content_spec.rb 100.00 % 28 13 13 0 1.00
spec/unit/models/multi_channel_channel_list_rbm_object_spec.rb 100.00 % 114 49 49 0 1.08
spec/unit/models/multi_channel_channel_list_rbm_response_object_spec.rb 100.00 % 126 53 53 0 1.08
spec/unit/models/multi_channel_channel_list_request_object_spec.rb 100.00 % 70 36 36 0 1.17
spec/unit/models/multi_channel_channel_list_response_object_spec.rb 100.00 % 70 36 36 0 1.17
spec/unit/models/multi_channel_channel_list_sms_object_spec.rb 100.00 % 114 49 49 0 1.08
spec/unit/models/multi_channel_channel_list_sms_response_object_spec.rb 100.00 % 126 53 53 0 1.08
spec/unit/models/multi_channel_error_spec.rb 100.00 % 76 37 37 0 1.11
spec/unit/models/multi_channel_message_channel_enum_spec.rb 100.00 % 40 19 19 0 1.00
spec/unit/models/multi_channel_message_content_spec.rb 100.00 % 69 33 33 0 1.12
spec/unit/models/multi_channel_message_request_spec.rb 100.00 % 125 48 48 0 1.19
spec/unit/models/multi_channel_message_response_data_spec.rb 100.00 % 168 62 62 0 1.18
spec/unit/models/opt_in_workflow_spec.rb 100.00 % 111 50 50 0 1.12
spec/unit/models/page_info_spec.rb 100.00 % 76 34 34 0 1.12
spec/unit/models/page_spec.rb 100.00 % 121 56 56 0 1.13
spec/unit/models/priority_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/product_type_enum_spec.rb 100.00 % 76 37 37 0 1.00
spec/unit/models/rbm_action_base_spec.rb 100.00 % 109 48 48 0 1.08
spec/unit/models/rbm_action_dial_spec.rb 100.00 % 121 52 52 0 1.08
spec/unit/models/rbm_action_open_url_spec.rb 100.00 % 133 56 56 0 1.07
spec/unit/models/rbm_action_type_enum_spec.rb 100.00 % 58 28 28 0 1.00
spec/unit/models/rbm_action_view_location_spec.rb 100.00 % 147 62 62 0 1.08
spec/unit/models/rbm_card_content_media_spec.rb 100.00 % 107 48 48 0 1.10
spec/unit/models/rbm_card_content_spec.rb 100.00 % 122 51 51 0 1.18
spec/unit/models/rbm_location_response_spec.rb 100.00 % 68 32 32 0 1.13
spec/unit/models/rbm_media_height_enum_spec.rb 100.00 % 40 19 19 0 1.00
spec/unit/models/rbm_message_carousel_card_spec.rb 100.00 % 123 52 52 0 1.31
spec/unit/models/rbm_message_content_file_spec.rb 100.00 % 95 44 44 0 1.11
spec/unit/models/rbm_message_content_rich_card_spec.rb 100.00 % 32 14 14 0 1.07
spec/unit/models/rbm_message_content_text_spec.rb 100.00 % 100 45 45 0 1.20
spec/unit/models/rbm_message_media_spec.rb 100.00 % 103 46 46 0 1.35
spec/unit/models/rbm_open_url_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/rbm_standalone_card_spec.rb 100.00 % 118 49 49 0 1.27
spec/unit/models/rbm_suggestion_response_spec.rb 100.00 % 80 38 38 0 1.13
spec/unit/models/rbm_web_view_enum_spec.rb 100.00 % 40 19 19 0 1.00
spec/unit/models/recording_available_callback_spec.rb 100.00 % 152 52 52 0 1.08
spec/unit/models/recording_complete_callback_spec.rb 100.00 % 153 52 52 0 1.08
spec/unit/models/recording_state_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/recording_transcription_metadata_spec.rb 100.00 % 76 34 34 0 1.12
spec/unit/models/recording_transcriptions_spec.rb 100.00 % 69 34 34 0 1.12
spec/unit/models/redirect_callback_spec.rb 100.00 % 128 46 46 0 1.09
spec/unit/models/redirect_method_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/sip_connection_metadata_spec.rb 100.00 % 78 36 36 0 1.11
spec/unit/models/sip_credentials_spec.rb 100.00 % 68 32 32 0 1.13
spec/unit/models/sms_message_content_spec.rb 100.00 % 81 38 38 0 1.11
spec/unit/models/standalone_card_orientation_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/status_callback_message_spec.rb 100.00 % 181 69 69 0 1.17
spec/unit/models/status_callback_spec.rb 100.00 % 169 57 57 0 1.16
spec/unit/models/status_callback_type_enum_spec.rb 100.00 % 46 22 22 0 1.00
spec/unit/models/stir_shaken_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/sync_lookup_request_spec.rb 100.00 % 91 42 42 0 1.12
spec/unit/models/telephone_number_spec.rb 100.00 % 64 31 31 0 1.13
spec/unit/models/tfv_basic_authentication_spec.rb 100.00 % 97 44 44 0 1.09
spec/unit/models/tfv_callback_status_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/tfv_error_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/tfv_status_enum_spec.rb 100.00 % 40 19 19 0 1.00
spec/unit/models/tfv_status_spec.rb 100.00 % 130 54 54 0 1.07
spec/unit/models/tfv_submission_info_spec.rb 100.00 % 224 93 93 0 1.04
spec/unit/models/tfv_submission_wrapper_spec.rb 100.00 % 76 32 32 0 1.13
spec/unit/models/thumbnail_alignment_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/transcribe_recording_spec.rb 100.00 % 119 49 49 0 1.08
spec/unit/models/transcription_available_callback_spec.rb 100.00 % 150 53 53 0 1.08
spec/unit/models/transcription_spec.rb 100.00 % 68 32 32 0 1.13
spec/unit/models/transfer_answer_callback_spec.rb 100.00 % 124 45 45 0 1.09
spec/unit/models/transfer_complete_callback_spec.rb 100.00 % 138 48 48 0 1.08
spec/unit/models/transfer_disconnect_callback_spec.rb 100.00 % 146 50 50 0 1.08
spec/unit/models/update_call_recording_spec.rb 100.00 % 77 36 36 0 1.11
spec/unit/models/update_call_spec.rb 100.00 % 143 56 56 0 1.07
spec/unit/models/update_conference_member_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/update_conference_spec.rb 100.00 % 132 52 52 0 1.08
spec/unit/models/verification_denial_webhook_spec.rb 100.00 % 123 51 51 0 1.08
spec/unit/models/verification_request_spec.rb 100.00 % 313 123 123 0 1.26
spec/unit/models/verification_update_request_spec.rb 100.00 % 285 112 112 0 1.17
spec/unit/models/verification_webhook_spec.rb 100.00 % 96 44 44 0 1.09
spec/unit/models/verify_code_request_spec.rb 100.00 % 125 55 55 0 1.07
spec/unit/models/verify_code_response_spec.rb 100.00 % 64 31 31 0 1.13
spec/unit/models/voice_api_error_spec.rb 100.00 % 72 33 33 0 1.12
spec/unit/models/voice_code_response_spec.rb 100.00 % 64 31 31 0 1.13
spec/unit/models/webhook_subscription_basic_authentication_spec.rb 100.00 % 97 44 44 0 1.09
spec/unit/models/webhook_subscription_error_spec.rb 100.00 % 76 35 35 0 1.11
spec/unit/models/webhook_subscription_request_schema_spec.rb 100.00 % 99 46 46 0 1.13
spec/unit/models/webhook_subscription_spec.rb 100.00 % 100 43 43 0 1.12
spec/unit/models/webhook_subscription_type_enum_spec.rb 100.00 % 34 16 16 0 1.00
spec/unit/models/webhook_subscriptions_list_body_spec.rb 100.00 % 91 40 40 0 1.13

lib/bandwidth-sdk.rb

99.61% lines covered

254 relevant lines. 253 lines covered and 1 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. # Common files
  10. 1 require 'bandwidth-sdk/api_client'
  11. 1 require 'bandwidth-sdk/api_error'
  12. 1 require 'bandwidth-sdk/api_model_base'
  13. 1 require 'bandwidth-sdk/version'
  14. 1 require 'bandwidth-sdk/configuration'
  15. # Models
  16. 1 require 'bandwidth-sdk/models/account_statistics'
  17. 1 require 'bandwidth-sdk/models/additional_denial_reason'
  18. 1 require 'bandwidth-sdk/models/address'
  19. 1 require 'bandwidth-sdk/models/answer_callback'
  20. 1 require 'bandwidth-sdk/models/async_lookup_request'
  21. 1 require 'bandwidth-sdk/models/blocked_webhook'
  22. 1 require 'bandwidth-sdk/models/bridge_complete_callback'
  23. 1 require 'bandwidth-sdk/models/bridge_target_complete_callback'
  24. 1 require 'bandwidth-sdk/models/brtc_error'
  25. 1 require 'bandwidth-sdk/models/brtc_error_response'
  26. 1 require 'bandwidth-sdk/models/brtc_error_source'
  27. 1 require 'bandwidth-sdk/models/brtc_link'
  28. 1 require 'bandwidth-sdk/models/business_entity_type_enum'
  29. 1 require 'bandwidth-sdk/models/business_registration_type_enum'
  30. 1 require 'bandwidth-sdk/models/call_direction_enum'
  31. 1 require 'bandwidth-sdk/models/call_recording_metadata'
  32. 1 require 'bandwidth-sdk/models/call_state'
  33. 1 require 'bandwidth-sdk/models/call_state_enum'
  34. 1 require 'bandwidth-sdk/models/call_transcription'
  35. 1 require 'bandwidth-sdk/models/call_transcription_detected_language_enum'
  36. 1 require 'bandwidth-sdk/models/call_transcription_metadata'
  37. 1 require 'bandwidth-sdk/models/call_transcription_response'
  38. 1 require 'bandwidth-sdk/models/call_transcription_track_enum'
  39. 1 require 'bandwidth-sdk/models/callback'
  40. 1 require 'bandwidth-sdk/models/callback_method_enum'
  41. 1 require 'bandwidth-sdk/models/card_width_enum'
  42. 1 require 'bandwidth-sdk/models/code_request'
  43. 1 require 'bandwidth-sdk/models/completed_lookup_status_enum'
  44. 1 require 'bandwidth-sdk/models/conference'
  45. 1 require 'bandwidth-sdk/models/conference_completed_callback'
  46. 1 require 'bandwidth-sdk/models/conference_created_callback'
  47. 1 require 'bandwidth-sdk/models/conference_member'
  48. 1 require 'bandwidth-sdk/models/conference_member_exit_callback'
  49. 1 require 'bandwidth-sdk/models/conference_member_join_callback'
  50. 1 require 'bandwidth-sdk/models/conference_recording_available_callback'
  51. 1 require 'bandwidth-sdk/models/conference_recording_metadata'
  52. 1 require 'bandwidth-sdk/models/conference_redirect_callback'
  53. 1 require 'bandwidth-sdk/models/conference_state_enum'
  54. 1 require 'bandwidth-sdk/models/contact'
  55. 1 require 'bandwidth-sdk/models/create_async_bulk_lookup_response'
  56. 1 require 'bandwidth-sdk/models/create_async_bulk_lookup_response_data'
  57. 1 require 'bandwidth-sdk/models/create_call'
  58. 1 require 'bandwidth-sdk/models/create_call_response'
  59. 1 require 'bandwidth-sdk/models/create_endpoint_request_base'
  60. 1 require 'bandwidth-sdk/models/create_endpoint_response'
  61. 1 require 'bandwidth-sdk/models/create_endpoint_response_data'
  62. 1 require 'bandwidth-sdk/models/create_message_request_error'
  63. 1 require 'bandwidth-sdk/models/create_multi_channel_message_response'
  64. 1 require 'bandwidth-sdk/models/create_sync_lookup_response'
  65. 1 require 'bandwidth-sdk/models/create_sync_lookup_response_data'
  66. 1 require 'bandwidth-sdk/models/create_web_rtc_connection_request'
  67. 1 require 'bandwidth-sdk/models/deactivation_event_enum'
  68. 1 require 'bandwidth-sdk/models/device'
  69. 1 require 'bandwidth-sdk/models/device_status_enum'
  70. 1 require 'bandwidth-sdk/models/disconnect_callback'
  71. 1 require 'bandwidth-sdk/models/diversion'
  72. 1 require 'bandwidth-sdk/models/dtmf_callback'
  73. 1 require 'bandwidth-sdk/models/endpoint'
  74. 1 require 'bandwidth-sdk/models/endpoint_direction_enum'
  75. 1 require 'bandwidth-sdk/models/endpoint_event'
  76. 1 require 'bandwidth-sdk/models/endpoint_event_type_enum'
  77. 1 require 'bandwidth-sdk/models/endpoint_response'
  78. 1 require 'bandwidth-sdk/models/endpoint_status_enum'
  79. 1 require 'bandwidth-sdk/models/endpoint_type_enum'
  80. 1 require 'bandwidth-sdk/models/endpoints'
  81. 1 require 'bandwidth-sdk/models/error_object'
  82. 1 require 'bandwidth-sdk/models/error_source'
  83. 1 require 'bandwidth-sdk/models/failure_webhook'
  84. 1 require 'bandwidth-sdk/models/field_error'
  85. 1 require 'bandwidth-sdk/models/file_format_enum'
  86. 1 require 'bandwidth-sdk/models/gather_callback'
  87. 1 require 'bandwidth-sdk/models/get_async_bulk_lookup_response'
  88. 1 require 'bandwidth-sdk/models/get_async_bulk_lookup_response_data'
  89. 1 require 'bandwidth-sdk/models/in_progress_lookup_status_enum'
  90. 1 require 'bandwidth-sdk/models/inbound_callback'
  91. 1 require 'bandwidth-sdk/models/inbound_callback_message'
  92. 1 require 'bandwidth-sdk/models/inbound_callback_type_enum'
  93. 1 require 'bandwidth-sdk/models/initiate_callback'
  94. 1 require 'bandwidth-sdk/models/latest_message_delivery_status_enum'
  95. 1 require 'bandwidth-sdk/models/line_type_enum'
  96. 1 require 'bandwidth-sdk/models/link'
  97. 1 require 'bandwidth-sdk/models/link_schema'
  98. 1 require 'bandwidth-sdk/models/links_object'
  99. 1 require 'bandwidth-sdk/models/list_endpoints_response'
  100. 1 require 'bandwidth-sdk/models/list_message_direction_enum'
  101. 1 require 'bandwidth-sdk/models/list_message_item'
  102. 1 require 'bandwidth-sdk/models/lookup_error_response'
  103. 1 require 'bandwidth-sdk/models/lookup_error_schema'
  104. 1 require 'bandwidth-sdk/models/lookup_error_schema_meta'
  105. 1 require 'bandwidth-sdk/models/lookup_result'
  106. 1 require 'bandwidth-sdk/models/machine_detection_complete_callback'
  107. 1 require 'bandwidth-sdk/models/machine_detection_configuration'
  108. 1 require 'bandwidth-sdk/models/machine_detection_mode_enum'
  109. 1 require 'bandwidth-sdk/models/machine_detection_result'
  110. 1 require 'bandwidth-sdk/models/media'
  111. 1 require 'bandwidth-sdk/models/message'
  112. 1 require 'bandwidth-sdk/models/message_direction_enum'
  113. 1 require 'bandwidth-sdk/models/message_request'
  114. 1 require 'bandwidth-sdk/models/message_status_enum'
  115. 1 require 'bandwidth-sdk/models/message_type_enum'
  116. 1 require 'bandwidth-sdk/models/messages_list'
  117. 1 require 'bandwidth-sdk/models/messaging_code_response'
  118. 1 require 'bandwidth-sdk/models/messaging_request_error'
  119. 1 require 'bandwidth-sdk/models/mfa_forbidden_request_error'
  120. 1 require 'bandwidth-sdk/models/mfa_request_error'
  121. 1 require 'bandwidth-sdk/models/mfa_unauthorized_request_error'
  122. 1 require 'bandwidth-sdk/models/mms_message_content'
  123. 1 require 'bandwidth-sdk/models/mms_message_content_file'
  124. 1 require 'bandwidth-sdk/models/multi_channel_action'
  125. 1 require 'bandwidth-sdk/models/multi_channel_action_calendar_event'
  126. 1 require 'bandwidth-sdk/models/multi_channel_channel_list_mms_object'
  127. 1 require 'bandwidth-sdk/models/multi_channel_channel_list_mms_response_object'
  128. 1 require 'bandwidth-sdk/models/multi_channel_channel_list_object_base'
  129. 1 require 'bandwidth-sdk/models/multi_channel_channel_list_owner_object'
  130. 1 require 'bandwidth-sdk/models/multi_channel_channel_list_rbm_object'
  131. 1 require 'bandwidth-sdk/models/multi_channel_channel_list_rbm_object_all_of_content'
  132. 1 require 'bandwidth-sdk/models/multi_channel_channel_list_rbm_response_object'
  133. 1 require 'bandwidth-sdk/models/multi_channel_channel_list_request_object'
  134. 1 require 'bandwidth-sdk/models/multi_channel_channel_list_response_object'
  135. 1 require 'bandwidth-sdk/models/multi_channel_channel_list_sms_object'
  136. 1 require 'bandwidth-sdk/models/multi_channel_channel_list_sms_response_object'
  137. 1 require 'bandwidth-sdk/models/multi_channel_error'
  138. 1 require 'bandwidth-sdk/models/multi_channel_message_channel_enum'
  139. 1 require 'bandwidth-sdk/models/multi_channel_message_content'
  140. 1 require 'bandwidth-sdk/models/multi_channel_message_request'
  141. 1 require 'bandwidth-sdk/models/multi_channel_message_response_data'
  142. 1 require 'bandwidth-sdk/models/opt_in_workflow'
  143. 1 require 'bandwidth-sdk/models/page'
  144. 1 require 'bandwidth-sdk/models/page_info'
  145. 1 require 'bandwidth-sdk/models/priority_enum'
  146. 1 require 'bandwidth-sdk/models/product_type_enum'
  147. 1 require 'bandwidth-sdk/models/rbm_action_base'
  148. 1 require 'bandwidth-sdk/models/rbm_action_dial'
  149. 1 require 'bandwidth-sdk/models/rbm_action_open_url'
  150. 1 require 'bandwidth-sdk/models/rbm_action_type_enum'
  151. 1 require 'bandwidth-sdk/models/rbm_action_view_location'
  152. 1 require 'bandwidth-sdk/models/rbm_card_content'
  153. 1 require 'bandwidth-sdk/models/rbm_card_content_media'
  154. 1 require 'bandwidth-sdk/models/rbm_location_response'
  155. 1 require 'bandwidth-sdk/models/rbm_media_height_enum'
  156. 1 require 'bandwidth-sdk/models/rbm_message_carousel_card'
  157. 1 require 'bandwidth-sdk/models/rbm_message_content_file'
  158. 1 require 'bandwidth-sdk/models/rbm_message_content_rich_card'
  159. 1 require 'bandwidth-sdk/models/rbm_message_content_text'
  160. 1 require 'bandwidth-sdk/models/rbm_message_media'
  161. 1 require 'bandwidth-sdk/models/rbm_open_url_enum'
  162. 1 require 'bandwidth-sdk/models/rbm_standalone_card'
  163. 1 require 'bandwidth-sdk/models/rbm_suggestion_response'
  164. 1 require 'bandwidth-sdk/models/rbm_web_view_enum'
  165. 1 require 'bandwidth-sdk/models/recording_available_callback'
  166. 1 require 'bandwidth-sdk/models/recording_complete_callback'
  167. 1 require 'bandwidth-sdk/models/recording_state_enum'
  168. 1 require 'bandwidth-sdk/models/recording_transcription_metadata'
  169. 1 require 'bandwidth-sdk/models/recording_transcriptions'
  170. 1 require 'bandwidth-sdk/models/redirect_callback'
  171. 1 require 'bandwidth-sdk/models/redirect_method_enum'
  172. 1 require 'bandwidth-sdk/models/sip_connection_metadata'
  173. 1 require 'bandwidth-sdk/models/sip_credentials'
  174. 1 require 'bandwidth-sdk/models/sms_message_content'
  175. 1 require 'bandwidth-sdk/models/standalone_card_orientation_enum'
  176. 1 require 'bandwidth-sdk/models/status_callback'
  177. 1 require 'bandwidth-sdk/models/status_callback_message'
  178. 1 require 'bandwidth-sdk/models/status_callback_type_enum'
  179. 1 require 'bandwidth-sdk/models/stir_shaken'
  180. 1 require 'bandwidth-sdk/models/sync_lookup_request'
  181. 1 require 'bandwidth-sdk/models/telephone_number'
  182. 1 require 'bandwidth-sdk/models/tfv_basic_authentication'
  183. 1 require 'bandwidth-sdk/models/tfv_callback_status_enum'
  184. 1 require 'bandwidth-sdk/models/tfv_error'
  185. 1 require 'bandwidth-sdk/models/tfv_status'
  186. 1 require 'bandwidth-sdk/models/tfv_status_enum'
  187. 1 require 'bandwidth-sdk/models/tfv_submission_info'
  188. 1 require 'bandwidth-sdk/models/tfv_submission_wrapper'
  189. 1 require 'bandwidth-sdk/models/thumbnail_alignment_enum'
  190. 1 require 'bandwidth-sdk/models/transcribe_recording'
  191. 1 require 'bandwidth-sdk/models/transcription'
  192. 1 require 'bandwidth-sdk/models/transcription_available_callback'
  193. 1 require 'bandwidth-sdk/models/transfer_answer_callback'
  194. 1 require 'bandwidth-sdk/models/transfer_complete_callback'
  195. 1 require 'bandwidth-sdk/models/transfer_disconnect_callback'
  196. 1 require 'bandwidth-sdk/models/update_call'
  197. 1 require 'bandwidth-sdk/models/update_call_recording'
  198. 1 require 'bandwidth-sdk/models/update_conference'
  199. 1 require 'bandwidth-sdk/models/update_conference_member'
  200. 1 require 'bandwidth-sdk/models/verification_denial_webhook'
  201. 1 require 'bandwidth-sdk/models/verification_request'
  202. 1 require 'bandwidth-sdk/models/verification_update_request'
  203. 1 require 'bandwidth-sdk/models/verification_webhook'
  204. 1 require 'bandwidth-sdk/models/verify_code_request'
  205. 1 require 'bandwidth-sdk/models/verify_code_response'
  206. 1 require 'bandwidth-sdk/models/voice_api_error'
  207. 1 require 'bandwidth-sdk/models/voice_code_response'
  208. 1 require 'bandwidth-sdk/models/webhook_subscription'
  209. 1 require 'bandwidth-sdk/models/webhook_subscription_basic_authentication'
  210. 1 require 'bandwidth-sdk/models/webhook_subscription_error'
  211. 1 require 'bandwidth-sdk/models/webhook_subscription_request_schema'
  212. 1 require 'bandwidth-sdk/models/webhook_subscription_type_enum'
  213. 1 require 'bandwidth-sdk/models/webhook_subscriptions_list_body'
  214. # BXML
  215. 1 require 'bandwidth-sdk/models/bxml/root'
  216. 1 require 'bandwidth-sdk/models/bxml/bxml'
  217. 1 require 'bandwidth-sdk/models/bxml/response'
  218. 1 require 'bandwidth-sdk/models/bxml/verb'
  219. 1 require 'bandwidth-sdk/models/bxml/nestable_verb'
  220. 1 require 'bandwidth-sdk/models/bxml/verbs/bridge'
  221. 1 require 'bandwidth-sdk/models/bxml/verbs/conference'
  222. 1 require 'bandwidth-sdk/models/bxml/verbs/custom_param'
  223. 1 require 'bandwidth-sdk/models/bxml/verbs/forward'
  224. 1 require 'bandwidth-sdk/models/bxml/verbs/gather'
  225. 1 require 'bandwidth-sdk/models/bxml/verbs/hangup'
  226. 1 require 'bandwidth-sdk/models/bxml/verbs/pause_recording'
  227. 1 require 'bandwidth-sdk/models/bxml/verbs/pause'
  228. 1 require 'bandwidth-sdk/models/bxml/verbs/phone_number'
  229. 1 require 'bandwidth-sdk/models/bxml/verbs/play_audio'
  230. 1 require 'bandwidth-sdk/models/bxml/verbs/record'
  231. 1 require 'bandwidth-sdk/models/bxml/verbs/redirect'
  232. 1 require 'bandwidth-sdk/models/bxml/verbs/resume_recording'
  233. 1 require 'bandwidth-sdk/models/bxml/verbs/ring'
  234. 1 require 'bandwidth-sdk/models/bxml/verbs/send_dtmf'
  235. 1 require 'bandwidth-sdk/models/bxml/verbs/sip_uri'
  236. 1 require 'bandwidth-sdk/models/bxml/verbs/speak_sentence'
  237. 1 require 'bandwidth-sdk/models/bxml/verbs/start_gather'
  238. 1 require 'bandwidth-sdk/models/bxml/verbs/start_recording'
  239. 1 require 'bandwidth-sdk/models/bxml/verbs/start_stream'
  240. 1 require 'bandwidth-sdk/models/bxml/verbs/start_transcription'
  241. 1 require 'bandwidth-sdk/models/bxml/verbs/stop_gather'
  242. 1 require 'bandwidth-sdk/models/bxml/verbs/stop_recording'
  243. 1 require 'bandwidth-sdk/models/bxml/verbs/stop_stream'
  244. 1 require 'bandwidth-sdk/models/bxml/verbs/stop_transcription'
  245. 1 require 'bandwidth-sdk/models/bxml/verbs/stream_param'
  246. 1 require 'bandwidth-sdk/models/bxml/verbs/tag'
  247. 1 require 'bandwidth-sdk/models/bxml/verbs/transfer'
  248. # APIs
  249. 1 require 'bandwidth-sdk/api/calls_api'
  250. 1 require 'bandwidth-sdk/api/conferences_api'
  251. 1 require 'bandwidth-sdk/api/endpoints_api'
  252. 1 require 'bandwidth-sdk/api/mfa_api'
  253. 1 require 'bandwidth-sdk/api/media_api'
  254. 1 require 'bandwidth-sdk/api/messages_api'
  255. 1 require 'bandwidth-sdk/api/multi_channel_api'
  256. 1 require 'bandwidth-sdk/api/phone_number_lookup_api'
  257. 1 require 'bandwidth-sdk/api/recordings_api'
  258. 1 require 'bandwidth-sdk/api/statistics_api'
  259. 1 require 'bandwidth-sdk/api/toll_free_verification_api'
  260. 1 require 'bandwidth-sdk/api/transcriptions_api'
  261. 1 module Bandwidth
  262. 1 class << self
  263. # Customize default settings for the SDK using block.
  264. # Bandwidth.configure do |config|
  265. # config.username = "xxx"
  266. # config.password = "xxx"
  267. # end
  268. # If no block given, return the default Configuration object.
  269. 1 def configure
  270. 13 if block_given?
  271. 13 yield(Configuration.default)
  272. else
  273. Configuration.default
  274. end
  275. end
  276. end
  277. end

lib/bandwidth-sdk/api/calls_api.rb

95.04% lines covered

141 relevant lines. 134 lines covered and 7 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'cgi'
  10. 1 module Bandwidth
  11. 1 class CallsApi
  12. 1 attr_accessor :api_client
  13. 1 def initialize(api_client = ApiClient.default)
  14. 2 @api_client = api_client
  15. end
  16. # Create Call
  17. # Creates an outbound phone call. All calls are initially queued. Your outbound calls will initiated at a specific dequeueing rate, enabling your application to \"fire and forget\" when creating calls. Queued calls may not be modified until they are dequeued and placed, but may be removed from your queue on demand. <b>Please note:</b> Calls submitted to your queue will be placed approximately in order, but exact ordering is not guaranteed.
  18. # @param account_id [String] Your Bandwidth Account ID.
  19. # @param create_call [CreateCall] JSON object containing information to create an outbound call
  20. # @param [Hash] opts the optional parameters
  21. # @return [CreateCallResponse]
  22. 1 def create_call(account_id, create_call, opts = {})
  23. 2 data, _status_code, _headers = create_call_with_http_info(account_id, create_call, opts)
  24. data
  25. end
  26. # Create Call
  27. # Creates an outbound phone call. All calls are initially queued. Your outbound calls will initiated at a specific dequeueing rate, enabling your application to \&quot;fire and forget\&quot; when creating calls. Queued calls may not be modified until they are dequeued and placed, but may be removed from your queue on demand. &lt;b&gt;Please note:&lt;/b&gt; Calls submitted to your queue will be placed approximately in order, but exact ordering is not guaranteed.
  28. # @param account_id [String] Your Bandwidth Account ID.
  29. # @param create_call [CreateCall] JSON object containing information to create an outbound call
  30. # @param [Hash] opts the optional parameters
  31. # @return [Array<(CreateCallResponse, Integer, Hash)>] CreateCallResponse data, response status code and response headers
  32. 1 def create_call_with_http_info(account_id, create_call, opts = {})
  33. 3 if @api_client.config.debugging
  34. 3 @api_client.config.logger.debug 'Calling API: CallsApi.create_call ...'
  35. end
  36. # verify the required parameter 'account_id' is set
  37. 3 if @api_client.config.client_side_validation && account_id.nil?
  38. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling CallsApi.create_call"
  39. end
  40. # verify the required parameter 'create_call' is set
  41. 2 if @api_client.config.client_side_validation && create_call.nil?
  42. 1 fail ArgumentError, "Missing the required parameter 'create_call' when calling CallsApi.create_call"
  43. end
  44. # resource path
  45. 1 local_var_path = '/accounts/{accountId}/calls'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
  46. # query parameters
  47. 1 query_params = opts[:query_params] || {}
  48. # header parameters
  49. 1 header_params = opts[:header_params] || {}
  50. # HTTP header 'Accept' (if needed)
  51. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  52. # HTTP header 'Content-Type'
  53. 1 content_type = @api_client.select_header_content_type(['application/json'])
  54. 1 if !content_type.nil?
  55. 1 header_params['Content-Type'] = content_type
  56. end
  57. # form parameters
  58. 1 form_params = opts[:form_params] || {}
  59. # http body (model)
  60. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(create_call)
  61. # return_type
  62. 1 return_type = opts[:debug_return_type] || 'CreateCallResponse'
  63. # auth_names
  64. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  65. 1 new_options = opts.merge(
  66. :operation => :"CallsApi.create_call",
  67. :header_params => header_params,
  68. :query_params => query_params,
  69. :form_params => form_params,
  70. :body => post_body,
  71. :auth_names => auth_names,
  72. :return_type => return_type
  73. )
  74. 1 data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  75. 1 if @api_client.config.debugging
  76. 1 @api_client.config.logger.debug "API called: CallsApi#create_call\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  77. end
  78. 1 return data, status_code, headers
  79. end
  80. # Get Call State Information
  81. # Retrieve the current state of a specific call. This information is near-realtime, so it may take a few minutes for your call to be accessible using this endpoint. **Note**: Call information is kept for 7 days after the calls are hung up. If you attempt to retrieve information for a call that is older than 7 days, you will get an HTTP 404 response.
  82. # @param account_id [String] Your Bandwidth Account ID.
  83. # @param call_id [String] Programmable Voice API Call ID.
  84. # @param [Hash] opts the optional parameters
  85. # @return [CallState]
  86. 1 def get_call_state(account_id, call_id, opts = {})
  87. 2 data, _status_code, _headers = get_call_state_with_http_info(account_id, call_id, opts)
  88. data
  89. end
  90. # Get Call State Information
  91. # Retrieve the current state of a specific call. This information is near-realtime, so it may take a few minutes for your call to be accessible using this endpoint. **Note**: Call information is kept for 7 days after the calls are hung up. If you attempt to retrieve information for a call that is older than 7 days, you will get an HTTP 404 response.
  92. # @param account_id [String] Your Bandwidth Account ID.
  93. # @param call_id [String] Programmable Voice API Call ID.
  94. # @param [Hash] opts the optional parameters
  95. # @return [Array<(CallState, Integer, Hash)>] CallState data, response status code and response headers
  96. 1 def get_call_state_with_http_info(account_id, call_id, opts = {})
  97. 3 if @api_client.config.debugging
  98. 3 @api_client.config.logger.debug 'Calling API: CallsApi.get_call_state ...'
  99. end
  100. # verify the required parameter 'account_id' is set
  101. 3 if @api_client.config.client_side_validation && account_id.nil?
  102. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling CallsApi.get_call_state"
  103. end
  104. # verify the required parameter 'call_id' is set
  105. 2 if @api_client.config.client_side_validation && call_id.nil?
  106. 1 fail ArgumentError, "Missing the required parameter 'call_id' when calling CallsApi.get_call_state"
  107. end
  108. # resource path
  109. 1 local_var_path = '/accounts/{accountId}/calls/{callId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s))
  110. # query parameters
  111. 1 query_params = opts[:query_params] || {}
  112. # header parameters
  113. 1 header_params = opts[:header_params] || {}
  114. # HTTP header 'Accept' (if needed)
  115. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  116. # form parameters
  117. 1 form_params = opts[:form_params] || {}
  118. # http body (model)
  119. 1 post_body = opts[:debug_body]
  120. # return_type
  121. 1 return_type = opts[:debug_return_type] || 'CallState'
  122. # auth_names
  123. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  124. 1 new_options = opts.merge(
  125. :operation => :"CallsApi.get_call_state",
  126. :header_params => header_params,
  127. :query_params => query_params,
  128. :form_params => form_params,
  129. :body => post_body,
  130. :auth_names => auth_names,
  131. :return_type => return_type
  132. )
  133. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  134. 1 if @api_client.config.debugging
  135. 1 @api_client.config.logger.debug "API called: CallsApi#get_call_state\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  136. end
  137. 1 return data, status_code, headers
  138. end
  139. # Get Calls
  140. # Returns a max of 10000 calls, sorted by `createdTime` from oldest to newest. **NOTE:** If the number of calls in the account is bigger than `pageSize`, a `Link` header (with format `<{url}>; rel=\"next\"`) will be returned in the response. The url can be used to retrieve the next page of call records. Also, call information is kept for 7 days after the calls are hung up. If you attempt to retrieve information for a call that is older than 7 days, you will get an empty array [] in response.
  141. # @param account_id [String] Your Bandwidth Account ID.
  142. # @param [Hash] opts the optional parameters
  143. # @option opts [String] :to Filter results by the &#x60;to&#x60; field.
  144. # @option opts [String] :from Filter results by the &#x60;from&#x60; field.
  145. # @option opts [String] :min_start_time Filter results to calls which have a &#x60;startTime&#x60; after or including &#x60;minStartTime&#x60; (in ISO8601 format).
  146. # @option opts [String] :max_start_time Filter results to calls which have a &#x60;startTime&#x60; before or including &#x60;maxStartTime&#x60; (in ISO8601 format).
  147. # @option opts [String] :disconnect_cause Filter results to calls with specified call Disconnect Cause.
  148. # @option opts [Integer] :page_size Specifies the max number of calls that will be returned. (default to 1000)
  149. # @option opts [String] :page_token Not intended for explicit use. To use pagination, follow the links in the &#x60;Link&#x60; header of the response, as indicated in the endpoint description.
  150. # @return [Array<CallState>]
  151. 1 def list_calls(account_id, opts = {})
  152. data, _status_code, _headers = list_calls_with_http_info(account_id, opts)
  153. data
  154. end
  155. # Get Calls
  156. # Returns a max of 10000 calls, sorted by &#x60;createdTime&#x60; from oldest to newest. **NOTE:** If the number of calls in the account is bigger than &#x60;pageSize&#x60;, a &#x60;Link&#x60; header (with format &#x60;&lt;{url}&gt;; rel&#x3D;\&quot;next\&quot;&#x60;) will be returned in the response. The url can be used to retrieve the next page of call records. Also, call information is kept for 7 days after the calls are hung up. If you attempt to retrieve information for a call that is older than 7 days, you will get an empty array [] in response.
  157. # @param account_id [String] Your Bandwidth Account ID.
  158. # @param [Hash] opts the optional parameters
  159. # @option opts [String] :to Filter results by the &#x60;to&#x60; field.
  160. # @option opts [String] :from Filter results by the &#x60;from&#x60; field.
  161. # @option opts [String] :min_start_time Filter results to calls which have a &#x60;startTime&#x60; after or including &#x60;minStartTime&#x60; (in ISO8601 format).
  162. # @option opts [String] :max_start_time Filter results to calls which have a &#x60;startTime&#x60; before or including &#x60;maxStartTime&#x60; (in ISO8601 format).
  163. # @option opts [String] :disconnect_cause Filter results to calls with specified call Disconnect Cause.
  164. # @option opts [Integer] :page_size Specifies the max number of calls that will be returned. (default to 1000)
  165. # @option opts [String] :page_token Not intended for explicit use. To use pagination, follow the links in the &#x60;Link&#x60; header of the response, as indicated in the endpoint description.
  166. # @return [Array<(Array<CallState>, Integer, Hash)>] Array<CallState> data, response status code and response headers
  167. 1 def list_calls_with_http_info(account_id, opts = {})
  168. 1 if @api_client.config.debugging
  169. 1 @api_client.config.logger.debug 'Calling API: CallsApi.list_calls ...'
  170. end
  171. # verify the required parameter 'account_id' is set
  172. 1 if @api_client.config.client_side_validation && account_id.nil?
  173. fail ArgumentError, "Missing the required parameter 'account_id' when calling CallsApi.list_calls"
  174. end
  175. 1 if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 10000
  176. fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling CallsApi.list_calls, must be smaller than or equal to 10000.'
  177. end
  178. 1 if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1
  179. fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling CallsApi.list_calls, must be greater than or equal to 1.'
  180. end
  181. # resource path
  182. 1 local_var_path = '/accounts/{accountId}/calls'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
  183. # query parameters
  184. 1 query_params = opts[:query_params] || {}
  185. 1 query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil?
  186. 1 query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?
  187. 1 query_params[:'minStartTime'] = opts[:'min_start_time'] if !opts[:'min_start_time'].nil?
  188. 1 query_params[:'maxStartTime'] = opts[:'max_start_time'] if !opts[:'max_start_time'].nil?
  189. 1 query_params[:'disconnectCause'] = opts[:'disconnect_cause'] if !opts[:'disconnect_cause'].nil?
  190. 1 query_params[:'pageSize'] = opts[:'page_size'] if !opts[:'page_size'].nil?
  191. 1 query_params[:'pageToken'] = opts[:'page_token'] if !opts[:'page_token'].nil?
  192. # header parameters
  193. 1 header_params = opts[:header_params] || {}
  194. # HTTP header 'Accept' (if needed)
  195. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  196. # form parameters
  197. 1 form_params = opts[:form_params] || {}
  198. # http body (model)
  199. 1 post_body = opts[:debug_body]
  200. # return_type
  201. 1 return_type = opts[:debug_return_type] || 'Array<CallState>'
  202. # auth_names
  203. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  204. 1 new_options = opts.merge(
  205. :operation => :"CallsApi.list_calls",
  206. :header_params => header_params,
  207. :query_params => query_params,
  208. :form_params => form_params,
  209. :body => post_body,
  210. :auth_names => auth_names,
  211. :return_type => return_type
  212. )
  213. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  214. 1 if @api_client.config.debugging
  215. 1 @api_client.config.logger.debug "API called: CallsApi#list_calls\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  216. end
  217. 1 return data, status_code, headers
  218. end
  219. # Update Call
  220. # Interrupts and redirects a call to a different URL that should return a BXML document.
  221. # @param account_id [String] Your Bandwidth Account ID.
  222. # @param call_id [String] Programmable Voice API Call ID.
  223. # @param update_call [UpdateCall] JSON object containing information to redirect an existing call to a new BXML document
  224. # @param [Hash] opts the optional parameters
  225. # @return [nil]
  226. 1 def update_call(account_id, call_id, update_call, opts = {})
  227. 3 update_call_with_http_info(account_id, call_id, update_call, opts)
  228. nil
  229. end
  230. # Update Call
  231. # Interrupts and redirects a call to a different URL that should return a BXML document.
  232. # @param account_id [String] Your Bandwidth Account ID.
  233. # @param call_id [String] Programmable Voice API Call ID.
  234. # @param update_call [UpdateCall] JSON object containing information to redirect an existing call to a new BXML document
  235. # @param [Hash] opts the optional parameters
  236. # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
  237. 1 def update_call_with_http_info(account_id, call_id, update_call, opts = {})
  238. 4 if @api_client.config.debugging
  239. 4 @api_client.config.logger.debug 'Calling API: CallsApi.update_call ...'
  240. end
  241. # verify the required parameter 'account_id' is set
  242. 4 if @api_client.config.client_side_validation && account_id.nil?
  243. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling CallsApi.update_call"
  244. end
  245. # verify the required parameter 'call_id' is set
  246. 3 if @api_client.config.client_side_validation && call_id.nil?
  247. 1 fail ArgumentError, "Missing the required parameter 'call_id' when calling CallsApi.update_call"
  248. end
  249. # verify the required parameter 'update_call' is set
  250. 2 if @api_client.config.client_side_validation && update_call.nil?
  251. 1 fail ArgumentError, "Missing the required parameter 'update_call' when calling CallsApi.update_call"
  252. end
  253. # resource path
  254. 1 local_var_path = '/accounts/{accountId}/calls/{callId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s))
  255. # query parameters
  256. 1 query_params = opts[:query_params] || {}
  257. # header parameters
  258. 1 header_params = opts[:header_params] || {}
  259. # HTTP header 'Accept' (if needed)
  260. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  261. # HTTP header 'Content-Type'
  262. 1 content_type = @api_client.select_header_content_type(['application/json'])
  263. 1 if !content_type.nil?
  264. 1 header_params['Content-Type'] = content_type
  265. end
  266. # form parameters
  267. 1 form_params = opts[:form_params] || {}
  268. # http body (model)
  269. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(update_call)
  270. # return_type
  271. 1 return_type = opts[:debug_return_type]
  272. # auth_names
  273. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  274. 1 new_options = opts.merge(
  275. :operation => :"CallsApi.update_call",
  276. :header_params => header_params,
  277. :query_params => query_params,
  278. :form_params => form_params,
  279. :body => post_body,
  280. :auth_names => auth_names,
  281. :return_type => return_type
  282. )
  283. 1 data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  284. 1 if @api_client.config.debugging
  285. 1 @api_client.config.logger.debug "API called: CallsApi#update_call\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  286. end
  287. 1 return data, status_code, headers
  288. end
  289. # Update Call BXML
  290. # Interrupts and replaces an active call's BXML document.
  291. # @param account_id [String] Your Bandwidth Account ID.
  292. # @param call_id [String] Programmable Voice API Call ID.
  293. # @param body [String]
  294. # @param [Hash] opts the optional parameters
  295. # @return [nil]
  296. 1 def update_call_bxml(account_id, call_id, body, opts = {})
  297. 3 update_call_bxml_with_http_info(account_id, call_id, body, opts)
  298. nil
  299. end
  300. # Update Call BXML
  301. # Interrupts and replaces an active call&#39;s BXML document.
  302. # @param account_id [String] Your Bandwidth Account ID.
  303. # @param call_id [String] Programmable Voice API Call ID.
  304. # @param body [String]
  305. # @param [Hash] opts the optional parameters
  306. # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
  307. 1 def update_call_bxml_with_http_info(account_id, call_id, body, opts = {})
  308. 4 if @api_client.config.debugging
  309. 4 @api_client.config.logger.debug 'Calling API: CallsApi.update_call_bxml ...'
  310. end
  311. # verify the required parameter 'account_id' is set
  312. 4 if @api_client.config.client_side_validation && account_id.nil?
  313. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling CallsApi.update_call_bxml"
  314. end
  315. # verify the required parameter 'call_id' is set
  316. 3 if @api_client.config.client_side_validation && call_id.nil?
  317. 1 fail ArgumentError, "Missing the required parameter 'call_id' when calling CallsApi.update_call_bxml"
  318. end
  319. # verify the required parameter 'body' is set
  320. 2 if @api_client.config.client_side_validation && body.nil?
  321. 1 fail ArgumentError, "Missing the required parameter 'body' when calling CallsApi.update_call_bxml"
  322. end
  323. # resource path
  324. 1 local_var_path = '/accounts/{accountId}/calls/{callId}/bxml'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s))
  325. # query parameters
  326. 1 query_params = opts[:query_params] || {}
  327. # header parameters
  328. 1 header_params = opts[:header_params] || {}
  329. # HTTP header 'Accept' (if needed)
  330. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  331. # HTTP header 'Content-Type'
  332. 1 content_type = @api_client.select_header_content_type(['application/xml'])
  333. 1 if !content_type.nil?
  334. 1 header_params['Content-Type'] = content_type
  335. end
  336. # form parameters
  337. 1 form_params = opts[:form_params] || {}
  338. # http body (model)
  339. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(body)
  340. # return_type
  341. 1 return_type = opts[:debug_return_type]
  342. # auth_names
  343. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  344. 1 new_options = opts.merge(
  345. :operation => :"CallsApi.update_call_bxml",
  346. :header_params => header_params,
  347. :query_params => query_params,
  348. :form_params => form_params,
  349. :body => post_body,
  350. :auth_names => auth_names,
  351. :return_type => return_type
  352. )
  353. 1 data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  354. 1 if @api_client.config.debugging
  355. 1 @api_client.config.logger.debug "API called: CallsApi#update_call_bxml\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  356. end
  357. 1 return data, status_code, headers
  358. end
  359. end
  360. end

lib/bandwidth-sdk/api/conferences_api.rb

97.5% lines covered

240 relevant lines. 234 lines covered and 6 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'cgi'
  10. 1 module Bandwidth
  11. 1 class ConferencesApi
  12. 1 attr_accessor :api_client
  13. 1 def initialize(api_client = ApiClient.default)
  14. 1 @api_client = api_client
  15. end
  16. # Download Conference Recording
  17. # Downloads the specified recording file.
  18. # @param account_id [String] Your Bandwidth Account ID.
  19. # @param conference_id [String] Programmable Voice API Conference ID.
  20. # @param recording_id [String] Programmable Voice API Recording ID.
  21. # @param [Hash] opts the optional parameters
  22. # @return [File]
  23. 1 def download_conference_recording(account_id, conference_id, recording_id, opts = {})
  24. 3 data, _status_code, _headers = download_conference_recording_with_http_info(account_id, conference_id, recording_id, opts)
  25. data
  26. end
  27. # Download Conference Recording
  28. # Downloads the specified recording file.
  29. # @param account_id [String] Your Bandwidth Account ID.
  30. # @param conference_id [String] Programmable Voice API Conference ID.
  31. # @param recording_id [String] Programmable Voice API Recording ID.
  32. # @param [Hash] opts the optional parameters
  33. # @return [Array<(File, Integer, Hash)>] File data, response status code and response headers
  34. 1 def download_conference_recording_with_http_info(account_id, conference_id, recording_id, opts = {})
  35. 4 if @api_client.config.debugging
  36. 4 @api_client.config.logger.debug 'Calling API: ConferencesApi.download_conference_recording ...'
  37. end
  38. # verify the required parameter 'account_id' is set
  39. 4 if @api_client.config.client_side_validation && account_id.nil?
  40. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.download_conference_recording"
  41. end
  42. # verify the required parameter 'conference_id' is set
  43. 3 if @api_client.config.client_side_validation && conference_id.nil?
  44. 1 fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.download_conference_recording"
  45. end
  46. # verify the required parameter 'recording_id' is set
  47. 2 if @api_client.config.client_side_validation && recording_id.nil?
  48. 1 fail ArgumentError, "Missing the required parameter 'recording_id' when calling ConferencesApi.download_conference_recording"
  49. end
  50. # resource path
  51. 1 local_var_path = '/accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}/media'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s))
  52. # query parameters
  53. 1 query_params = opts[:query_params] || {}
  54. # header parameters
  55. 1 header_params = opts[:header_params] || {}
  56. # HTTP header 'Accept' (if needed)
  57. 1 header_params['Accept'] = @api_client.select_header_accept(['audio/vnd.wave', 'audio/mpeg', 'application/json']) unless header_params['Accept']
  58. # form parameters
  59. 1 form_params = opts[:form_params] || {}
  60. # http body (model)
  61. 1 post_body = opts[:debug_body]
  62. # return_type
  63. 1 return_type = opts[:debug_return_type] || 'File'
  64. # auth_names
  65. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  66. 1 new_options = opts.merge(
  67. :operation => :"ConferencesApi.download_conference_recording",
  68. :header_params => header_params,
  69. :query_params => query_params,
  70. :form_params => form_params,
  71. :body => post_body,
  72. :auth_names => auth_names,
  73. :return_type => return_type
  74. )
  75. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  76. 1 if @api_client.config.debugging
  77. 1 @api_client.config.logger.debug "API called: ConferencesApi#download_conference_recording\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  78. end
  79. 1 return data, status_code, headers
  80. end
  81. # Get Conference Information
  82. # Returns information about the specified conference.
  83. # @param account_id [String] Your Bandwidth Account ID.
  84. # @param conference_id [String] Programmable Voice API Conference ID.
  85. # @param [Hash] opts the optional parameters
  86. # @return [Conference]
  87. 1 def get_conference(account_id, conference_id, opts = {})
  88. 2 data, _status_code, _headers = get_conference_with_http_info(account_id, conference_id, opts)
  89. data
  90. end
  91. # Get Conference Information
  92. # Returns information about the specified conference.
  93. # @param account_id [String] Your Bandwidth Account ID.
  94. # @param conference_id [String] Programmable Voice API Conference ID.
  95. # @param [Hash] opts the optional parameters
  96. # @return [Array<(Conference, Integer, Hash)>] Conference data, response status code and response headers
  97. 1 def get_conference_with_http_info(account_id, conference_id, opts = {})
  98. 3 if @api_client.config.debugging
  99. 3 @api_client.config.logger.debug 'Calling API: ConferencesApi.get_conference ...'
  100. end
  101. # verify the required parameter 'account_id' is set
  102. 3 if @api_client.config.client_side_validation && account_id.nil?
  103. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.get_conference"
  104. end
  105. # verify the required parameter 'conference_id' is set
  106. 2 if @api_client.config.client_side_validation && conference_id.nil?
  107. 1 fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.get_conference"
  108. end
  109. # resource path
  110. 1 local_var_path = '/accounts/{accountId}/conferences/{conferenceId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s))
  111. # query parameters
  112. 1 query_params = opts[:query_params] || {}
  113. # header parameters
  114. 1 header_params = opts[:header_params] || {}
  115. # HTTP header 'Accept' (if needed)
  116. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  117. # form parameters
  118. 1 form_params = opts[:form_params] || {}
  119. # http body (model)
  120. 1 post_body = opts[:debug_body]
  121. # return_type
  122. 1 return_type = opts[:debug_return_type] || 'Conference'
  123. # auth_names
  124. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  125. 1 new_options = opts.merge(
  126. :operation => :"ConferencesApi.get_conference",
  127. :header_params => header_params,
  128. :query_params => query_params,
  129. :form_params => form_params,
  130. :body => post_body,
  131. :auth_names => auth_names,
  132. :return_type => return_type
  133. )
  134. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  135. 1 if @api_client.config.debugging
  136. 1 @api_client.config.logger.debug "API called: ConferencesApi#get_conference\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  137. end
  138. 1 return data, status_code, headers
  139. end
  140. # Get Conference Member
  141. # Returns information about the specified conference member.
  142. # @param account_id [String] Your Bandwidth Account ID.
  143. # @param conference_id [String] Programmable Voice API Conference ID.
  144. # @param member_id [String] Programmable Voice API Conference Member ID.
  145. # @param [Hash] opts the optional parameters
  146. # @return [ConferenceMember]
  147. 1 def get_conference_member(account_id, conference_id, member_id, opts = {})
  148. 3 data, _status_code, _headers = get_conference_member_with_http_info(account_id, conference_id, member_id, opts)
  149. data
  150. end
  151. # Get Conference Member
  152. # Returns information about the specified conference member.
  153. # @param account_id [String] Your Bandwidth Account ID.
  154. # @param conference_id [String] Programmable Voice API Conference ID.
  155. # @param member_id [String] Programmable Voice API Conference Member ID.
  156. # @param [Hash] opts the optional parameters
  157. # @return [Array<(ConferenceMember, Integer, Hash)>] ConferenceMember data, response status code and response headers
  158. 1 def get_conference_member_with_http_info(account_id, conference_id, member_id, opts = {})
  159. 4 if @api_client.config.debugging
  160. 4 @api_client.config.logger.debug 'Calling API: ConferencesApi.get_conference_member ...'
  161. end
  162. # verify the required parameter 'account_id' is set
  163. 4 if @api_client.config.client_side_validation && account_id.nil?
  164. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.get_conference_member"
  165. end
  166. # verify the required parameter 'conference_id' is set
  167. 3 if @api_client.config.client_side_validation && conference_id.nil?
  168. 1 fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.get_conference_member"
  169. end
  170. # verify the required parameter 'member_id' is set
  171. 2 if @api_client.config.client_side_validation && member_id.nil?
  172. 1 fail ArgumentError, "Missing the required parameter 'member_id' when calling ConferencesApi.get_conference_member"
  173. end
  174. # resource path
  175. 1 local_var_path = '/accounts/{accountId}/conferences/{conferenceId}/members/{memberId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s)).sub('{' + 'memberId' + '}', CGI.escape(member_id.to_s))
  176. # query parameters
  177. 1 query_params = opts[:query_params] || {}
  178. # header parameters
  179. 1 header_params = opts[:header_params] || {}
  180. # HTTP header 'Accept' (if needed)
  181. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  182. # form parameters
  183. 1 form_params = opts[:form_params] || {}
  184. # http body (model)
  185. 1 post_body = opts[:debug_body]
  186. # return_type
  187. 1 return_type = opts[:debug_return_type] || 'ConferenceMember'
  188. # auth_names
  189. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  190. 1 new_options = opts.merge(
  191. :operation => :"ConferencesApi.get_conference_member",
  192. :header_params => header_params,
  193. :query_params => query_params,
  194. :form_params => form_params,
  195. :body => post_body,
  196. :auth_names => auth_names,
  197. :return_type => return_type
  198. )
  199. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  200. 1 if @api_client.config.debugging
  201. 1 @api_client.config.logger.debug "API called: ConferencesApi#get_conference_member\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  202. end
  203. 1 return data, status_code, headers
  204. end
  205. # Get Conference Recording Information
  206. # Returns metadata for the specified recording.
  207. # @param account_id [String] Your Bandwidth Account ID.
  208. # @param conference_id [String] Programmable Voice API Conference ID.
  209. # @param recording_id [String] Programmable Voice API Recording ID.
  210. # @param [Hash] opts the optional parameters
  211. # @return [ConferenceRecordingMetadata]
  212. 1 def get_conference_recording(account_id, conference_id, recording_id, opts = {})
  213. 3 data, _status_code, _headers = get_conference_recording_with_http_info(account_id, conference_id, recording_id, opts)
  214. data
  215. end
  216. # Get Conference Recording Information
  217. # Returns metadata for the specified recording.
  218. # @param account_id [String] Your Bandwidth Account ID.
  219. # @param conference_id [String] Programmable Voice API Conference ID.
  220. # @param recording_id [String] Programmable Voice API Recording ID.
  221. # @param [Hash] opts the optional parameters
  222. # @return [Array<(ConferenceRecordingMetadata, Integer, Hash)>] ConferenceRecordingMetadata data, response status code and response headers
  223. 1 def get_conference_recording_with_http_info(account_id, conference_id, recording_id, opts = {})
  224. 4 if @api_client.config.debugging
  225. 4 @api_client.config.logger.debug 'Calling API: ConferencesApi.get_conference_recording ...'
  226. end
  227. # verify the required parameter 'account_id' is set
  228. 4 if @api_client.config.client_side_validation && account_id.nil?
  229. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.get_conference_recording"
  230. end
  231. # verify the required parameter 'conference_id' is set
  232. 3 if @api_client.config.client_side_validation && conference_id.nil?
  233. 1 fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.get_conference_recording"
  234. end
  235. # verify the required parameter 'recording_id' is set
  236. 2 if @api_client.config.client_side_validation && recording_id.nil?
  237. 1 fail ArgumentError, "Missing the required parameter 'recording_id' when calling ConferencesApi.get_conference_recording"
  238. end
  239. # resource path
  240. 1 local_var_path = '/accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s))
  241. # query parameters
  242. 1 query_params = opts[:query_params] || {}
  243. # header parameters
  244. 1 header_params = opts[:header_params] || {}
  245. # HTTP header 'Accept' (if needed)
  246. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  247. # form parameters
  248. 1 form_params = opts[:form_params] || {}
  249. # http body (model)
  250. 1 post_body = opts[:debug_body]
  251. # return_type
  252. 1 return_type = opts[:debug_return_type] || 'ConferenceRecordingMetadata'
  253. # auth_names
  254. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  255. 1 new_options = opts.merge(
  256. :operation => :"ConferencesApi.get_conference_recording",
  257. :header_params => header_params,
  258. :query_params => query_params,
  259. :form_params => form_params,
  260. :body => post_body,
  261. :auth_names => auth_names,
  262. :return_type => return_type
  263. )
  264. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  265. 1 if @api_client.config.debugging
  266. 1 @api_client.config.logger.debug "API called: ConferencesApi#get_conference_recording\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  267. end
  268. 1 return data, status_code, headers
  269. end
  270. # Get Conference Recordings
  271. # Returns a (potentially empty) list of metadata for the recordings that took place during the specified conference.
  272. # @param account_id [String] Your Bandwidth Account ID.
  273. # @param conference_id [String] Programmable Voice API Conference ID.
  274. # @param [Hash] opts the optional parameters
  275. # @return [Array<ConferenceRecordingMetadata>]
  276. 1 def list_conference_recordings(account_id, conference_id, opts = {})
  277. 2 data, _status_code, _headers = list_conference_recordings_with_http_info(account_id, conference_id, opts)
  278. data
  279. end
  280. # Get Conference Recordings
  281. # Returns a (potentially empty) list of metadata for the recordings that took place during the specified conference.
  282. # @param account_id [String] Your Bandwidth Account ID.
  283. # @param conference_id [String] Programmable Voice API Conference ID.
  284. # @param [Hash] opts the optional parameters
  285. # @return [Array<(Array<ConferenceRecordingMetadata>, Integer, Hash)>] Array<ConferenceRecordingMetadata> data, response status code and response headers
  286. 1 def list_conference_recordings_with_http_info(account_id, conference_id, opts = {})
  287. 3 if @api_client.config.debugging
  288. 3 @api_client.config.logger.debug 'Calling API: ConferencesApi.list_conference_recordings ...'
  289. end
  290. # verify the required parameter 'account_id' is set
  291. 3 if @api_client.config.client_side_validation && account_id.nil?
  292. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.list_conference_recordings"
  293. end
  294. # verify the required parameter 'conference_id' is set
  295. 2 if @api_client.config.client_side_validation && conference_id.nil?
  296. 1 fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.list_conference_recordings"
  297. end
  298. # resource path
  299. 1 local_var_path = '/accounts/{accountId}/conferences/{conferenceId}/recordings'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s))
  300. # query parameters
  301. 1 query_params = opts[:query_params] || {}
  302. # header parameters
  303. 1 header_params = opts[:header_params] || {}
  304. # HTTP header 'Accept' (if needed)
  305. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  306. # form parameters
  307. 1 form_params = opts[:form_params] || {}
  308. # http body (model)
  309. 1 post_body = opts[:debug_body]
  310. # return_type
  311. 1 return_type = opts[:debug_return_type] || 'Array<ConferenceRecordingMetadata>'
  312. # auth_names
  313. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  314. 1 new_options = opts.merge(
  315. :operation => :"ConferencesApi.list_conference_recordings",
  316. :header_params => header_params,
  317. :query_params => query_params,
  318. :form_params => form_params,
  319. :body => post_body,
  320. :auth_names => auth_names,
  321. :return_type => return_type
  322. )
  323. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  324. 1 if @api_client.config.debugging
  325. 1 @api_client.config.logger.debug "API called: ConferencesApi#list_conference_recordings\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  326. end
  327. 1 return data, status_code, headers
  328. end
  329. # Get Conferences
  330. # Returns a max of 1000 conferences, sorted by `createdTime` from oldest to newest. **NOTE:** If the number of conferences in the account is bigger than `pageSize`, a `Link` header (with format `<{url}>; rel=\"next\"`) will be returned in the response. The url can be used to retrieve the next page of conference records.
  331. # @param account_id [String] Your Bandwidth Account ID.
  332. # @param [Hash] opts the optional parameters
  333. # @option opts [String] :name Filter results by the &#x60;name&#x60; field.
  334. # @option opts [String] :min_created_time Filter results to conferences which have a &#x60;createdTime&#x60; after or at &#x60;minCreatedTime&#x60; (in ISO8601 format).
  335. # @option opts [String] :max_created_time Filter results to conferences which have a &#x60;createdTime&#x60; before or at &#x60;maxCreatedTime&#x60; (in ISO8601 format).
  336. # @option opts [Integer] :page_size Specifies the max number of conferences that will be returned. (default to 1000)
  337. # @option opts [String] :page_token Not intended for explicit use. To use pagination, follow the links in the &#x60;Link&#x60; header of the response, as indicated in the endpoint description.
  338. # @return [Array<Conference>]
  339. 1 def list_conferences(account_id, opts = {})
  340. 3 data, _status_code, _headers = list_conferences_with_http_info(account_id, opts)
  341. data
  342. end
  343. # Get Conferences
  344. # Returns a max of 1000 conferences, sorted by &#x60;createdTime&#x60; from oldest to newest. **NOTE:** If the number of conferences in the account is bigger than &#x60;pageSize&#x60;, a &#x60;Link&#x60; header (with format &#x60;&lt;{url}&gt;; rel&#x3D;\&quot;next\&quot;&#x60;) will be returned in the response. The url can be used to retrieve the next page of conference records.
  345. # @param account_id [String] Your Bandwidth Account ID.
  346. # @param [Hash] opts the optional parameters
  347. # @option opts [String] :name Filter results by the &#x60;name&#x60; field.
  348. # @option opts [String] :min_created_time Filter results to conferences which have a &#x60;createdTime&#x60; after or at &#x60;minCreatedTime&#x60; (in ISO8601 format).
  349. # @option opts [String] :max_created_time Filter results to conferences which have a &#x60;createdTime&#x60; before or at &#x60;maxCreatedTime&#x60; (in ISO8601 format).
  350. # @option opts [Integer] :page_size Specifies the max number of conferences that will be returned. (default to 1000)
  351. # @option opts [String] :page_token Not intended for explicit use. To use pagination, follow the links in the &#x60;Link&#x60; header of the response, as indicated in the endpoint description.
  352. # @return [Array<(Array<Conference>, Integer, Hash)>] Array<Conference> data, response status code and response headers
  353. 1 def list_conferences_with_http_info(account_id, opts = {})
  354. 4 if @api_client.config.debugging
  355. 4 @api_client.config.logger.debug 'Calling API: ConferencesApi.list_conferences ...'
  356. end
  357. # verify the required parameter 'account_id' is set
  358. 4 if @api_client.config.client_side_validation && account_id.nil?
  359. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.list_conferences"
  360. end
  361. 3 if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 1000
  362. 1 fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ConferencesApi.list_conferences, must be smaller than or equal to 1000.'
  363. end
  364. 2 if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1
  365. 1 fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ConferencesApi.list_conferences, must be greater than or equal to 1.'
  366. end
  367. # resource path
  368. 1 local_var_path = '/accounts/{accountId}/conferences'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
  369. # query parameters
  370. 1 query_params = opts[:query_params] || {}
  371. 1 query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?
  372. 1 query_params[:'minCreatedTime'] = opts[:'min_created_time'] if !opts[:'min_created_time'].nil?
  373. 1 query_params[:'maxCreatedTime'] = opts[:'max_created_time'] if !opts[:'max_created_time'].nil?
  374. 1 query_params[:'pageSize'] = opts[:'page_size'] if !opts[:'page_size'].nil?
  375. 1 query_params[:'pageToken'] = opts[:'page_token'] if !opts[:'page_token'].nil?
  376. # header parameters
  377. 1 header_params = opts[:header_params] || {}
  378. # HTTP header 'Accept' (if needed)
  379. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  380. # form parameters
  381. 1 form_params = opts[:form_params] || {}
  382. # http body (model)
  383. 1 post_body = opts[:debug_body]
  384. # return_type
  385. 1 return_type = opts[:debug_return_type] || 'Array<Conference>'
  386. # auth_names
  387. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  388. 1 new_options = opts.merge(
  389. :operation => :"ConferencesApi.list_conferences",
  390. :header_params => header_params,
  391. :query_params => query_params,
  392. :form_params => form_params,
  393. :body => post_body,
  394. :auth_names => auth_names,
  395. :return_type => return_type
  396. )
  397. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  398. 1 if @api_client.config.debugging
  399. 1 @api_client.config.logger.debug "API called: ConferencesApi#list_conferences\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  400. end
  401. 1 return data, status_code, headers
  402. end
  403. # Update Conference
  404. # Update the conference state.
  405. # @param account_id [String] Your Bandwidth Account ID.
  406. # @param conference_id [String] Programmable Voice API Conference ID.
  407. # @param update_conference [UpdateConference]
  408. # @param [Hash] opts the optional parameters
  409. # @return [nil]
  410. 1 def update_conference(account_id, conference_id, update_conference, opts = {})
  411. 3 update_conference_with_http_info(account_id, conference_id, update_conference, opts)
  412. nil
  413. end
  414. # Update Conference
  415. # Update the conference state.
  416. # @param account_id [String] Your Bandwidth Account ID.
  417. # @param conference_id [String] Programmable Voice API Conference ID.
  418. # @param update_conference [UpdateConference]
  419. # @param [Hash] opts the optional parameters
  420. # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
  421. 1 def update_conference_with_http_info(account_id, conference_id, update_conference, opts = {})
  422. 4 if @api_client.config.debugging
  423. 4 @api_client.config.logger.debug 'Calling API: ConferencesApi.update_conference ...'
  424. end
  425. # verify the required parameter 'account_id' is set
  426. 4 if @api_client.config.client_side_validation && account_id.nil?
  427. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.update_conference"
  428. end
  429. # verify the required parameter 'conference_id' is set
  430. 3 if @api_client.config.client_side_validation && conference_id.nil?
  431. 1 fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.update_conference"
  432. end
  433. # verify the required parameter 'update_conference' is set
  434. 2 if @api_client.config.client_side_validation && update_conference.nil?
  435. 1 fail ArgumentError, "Missing the required parameter 'update_conference' when calling ConferencesApi.update_conference"
  436. end
  437. # resource path
  438. 1 local_var_path = '/accounts/{accountId}/conferences/{conferenceId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s))
  439. # query parameters
  440. 1 query_params = opts[:query_params] || {}
  441. # header parameters
  442. 1 header_params = opts[:header_params] || {}
  443. # HTTP header 'Accept' (if needed)
  444. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  445. # HTTP header 'Content-Type'
  446. 1 content_type = @api_client.select_header_content_type(['application/json'])
  447. 1 if !content_type.nil?
  448. 1 header_params['Content-Type'] = content_type
  449. end
  450. # form parameters
  451. 1 form_params = opts[:form_params] || {}
  452. # http body (model)
  453. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(update_conference)
  454. # return_type
  455. 1 return_type = opts[:debug_return_type]
  456. # auth_names
  457. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  458. 1 new_options = opts.merge(
  459. :operation => :"ConferencesApi.update_conference",
  460. :header_params => header_params,
  461. :query_params => query_params,
  462. :form_params => form_params,
  463. :body => post_body,
  464. :auth_names => auth_names,
  465. :return_type => return_type
  466. )
  467. 1 data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  468. 1 if @api_client.config.debugging
  469. 1 @api_client.config.logger.debug "API called: ConferencesApi#update_conference\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  470. end
  471. 1 return data, status_code, headers
  472. end
  473. # Update Conference BXML
  474. # Update the conference BXML document.
  475. # @param account_id [String] Your Bandwidth Account ID.
  476. # @param conference_id [String] Programmable Voice API Conference ID.
  477. # @param body [String]
  478. # @param [Hash] opts the optional parameters
  479. # @return [nil]
  480. 1 def update_conference_bxml(account_id, conference_id, body, opts = {})
  481. 3 update_conference_bxml_with_http_info(account_id, conference_id, body, opts)
  482. nil
  483. end
  484. # Update Conference BXML
  485. # Update the conference BXML document.
  486. # @param account_id [String] Your Bandwidth Account ID.
  487. # @param conference_id [String] Programmable Voice API Conference ID.
  488. # @param body [String]
  489. # @param [Hash] opts the optional parameters
  490. # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
  491. 1 def update_conference_bxml_with_http_info(account_id, conference_id, body, opts = {})
  492. 4 if @api_client.config.debugging
  493. 4 @api_client.config.logger.debug 'Calling API: ConferencesApi.update_conference_bxml ...'
  494. end
  495. # verify the required parameter 'account_id' is set
  496. 4 if @api_client.config.client_side_validation && account_id.nil?
  497. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.update_conference_bxml"
  498. end
  499. # verify the required parameter 'conference_id' is set
  500. 3 if @api_client.config.client_side_validation && conference_id.nil?
  501. 1 fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.update_conference_bxml"
  502. end
  503. # verify the required parameter 'body' is set
  504. 2 if @api_client.config.client_side_validation && body.nil?
  505. 1 fail ArgumentError, "Missing the required parameter 'body' when calling ConferencesApi.update_conference_bxml"
  506. end
  507. # resource path
  508. 1 local_var_path = '/accounts/{accountId}/conferences/{conferenceId}/bxml'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s))
  509. # query parameters
  510. 1 query_params = opts[:query_params] || {}
  511. # header parameters
  512. 1 header_params = opts[:header_params] || {}
  513. # HTTP header 'Accept' (if needed)
  514. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  515. # HTTP header 'Content-Type'
  516. 1 content_type = @api_client.select_header_content_type(['application/xml'])
  517. 1 if !content_type.nil?
  518. 1 header_params['Content-Type'] = content_type
  519. end
  520. # form parameters
  521. 1 form_params = opts[:form_params] || {}
  522. # http body (model)
  523. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(body)
  524. # return_type
  525. 1 return_type = opts[:debug_return_type]
  526. # auth_names
  527. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  528. 1 new_options = opts.merge(
  529. :operation => :"ConferencesApi.update_conference_bxml",
  530. :header_params => header_params,
  531. :query_params => query_params,
  532. :form_params => form_params,
  533. :body => post_body,
  534. :auth_names => auth_names,
  535. :return_type => return_type
  536. )
  537. 1 data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  538. 1 if @api_client.config.debugging
  539. 1 @api_client.config.logger.debug "API called: ConferencesApi#update_conference_bxml\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  540. end
  541. 1 return data, status_code, headers
  542. end
  543. # Update Conference Member
  544. # Updates settings for a particular conference member.
  545. # @param account_id [String] Your Bandwidth Account ID.
  546. # @param conference_id [String] Programmable Voice API Conference ID.
  547. # @param member_id [String] Programmable Voice API Conference Member ID.
  548. # @param update_conference_member [UpdateConferenceMember]
  549. # @param [Hash] opts the optional parameters
  550. # @return [nil]
  551. 1 def update_conference_member(account_id, conference_id, member_id, update_conference_member, opts = {})
  552. 4 update_conference_member_with_http_info(account_id, conference_id, member_id, update_conference_member, opts)
  553. nil
  554. end
  555. # Update Conference Member
  556. # Updates settings for a particular conference member.
  557. # @param account_id [String] Your Bandwidth Account ID.
  558. # @param conference_id [String] Programmable Voice API Conference ID.
  559. # @param member_id [String] Programmable Voice API Conference Member ID.
  560. # @param update_conference_member [UpdateConferenceMember]
  561. # @param [Hash] opts the optional parameters
  562. # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
  563. 1 def update_conference_member_with_http_info(account_id, conference_id, member_id, update_conference_member, opts = {})
  564. 5 if @api_client.config.debugging
  565. 5 @api_client.config.logger.debug 'Calling API: ConferencesApi.update_conference_member ...'
  566. end
  567. # verify the required parameter 'account_id' is set
  568. 5 if @api_client.config.client_side_validation && account_id.nil?
  569. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.update_conference_member"
  570. end
  571. # verify the required parameter 'conference_id' is set
  572. 4 if @api_client.config.client_side_validation && conference_id.nil?
  573. 1 fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.update_conference_member"
  574. end
  575. # verify the required parameter 'member_id' is set
  576. 3 if @api_client.config.client_side_validation && member_id.nil?
  577. 1 fail ArgumentError, "Missing the required parameter 'member_id' when calling ConferencesApi.update_conference_member"
  578. end
  579. # verify the required parameter 'update_conference_member' is set
  580. 2 if @api_client.config.client_side_validation && update_conference_member.nil?
  581. 1 fail ArgumentError, "Missing the required parameter 'update_conference_member' when calling ConferencesApi.update_conference_member"
  582. end
  583. # resource path
  584. 1 local_var_path = '/accounts/{accountId}/conferences/{conferenceId}/members/{memberId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s)).sub('{' + 'memberId' + '}', CGI.escape(member_id.to_s))
  585. # query parameters
  586. 1 query_params = opts[:query_params] || {}
  587. # header parameters
  588. 1 header_params = opts[:header_params] || {}
  589. # HTTP header 'Accept' (if needed)
  590. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  591. # HTTP header 'Content-Type'
  592. 1 content_type = @api_client.select_header_content_type(['application/json'])
  593. 1 if !content_type.nil?
  594. 1 header_params['Content-Type'] = content_type
  595. end
  596. # form parameters
  597. 1 form_params = opts[:form_params] || {}
  598. # http body (model)
  599. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(update_conference_member)
  600. # return_type
  601. 1 return_type = opts[:debug_return_type]
  602. # auth_names
  603. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  604. 1 new_options = opts.merge(
  605. :operation => :"ConferencesApi.update_conference_member",
  606. :header_params => header_params,
  607. :query_params => query_params,
  608. :form_params => form_params,
  609. :body => post_body,
  610. :auth_names => auth_names,
  611. :return_type => return_type
  612. )
  613. 1 data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  614. 1 if @api_client.config.debugging
  615. 1 @api_client.config.logger.debug "API called: ConferencesApi#update_conference_member\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  616. end
  617. 1 return data, status_code, headers
  618. end
  619. end
  620. end

lib/bandwidth-sdk/api/endpoints_api.rb

96.24% lines covered

133 relevant lines. 128 lines covered and 5 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'cgi'
  10. 1 module Bandwidth
  11. 1 class EndpointsApi
  12. 1 attr_accessor :api_client
  13. 1 def initialize(api_client = ApiClient.default)
  14. 1 @api_client = api_client
  15. end
  16. # Create Endpoint
  17. # Creates a new Endpoint for the specified account.
  18. # @param account_id [String] Your Bandwidth Account ID.
  19. # @param body [CreateWebRtcConnectionRequest]
  20. # @param [Hash] opts the optional parameters
  21. # @return [CreateEndpointResponse]
  22. 1 def create_endpoint(account_id, body, opts = {})
  23. 2 data, _status_code, _headers = create_endpoint_with_http_info(account_id, body, opts)
  24. data
  25. end
  26. # Create Endpoint
  27. # Creates a new Endpoint for the specified account.
  28. # @param account_id [String] Your Bandwidth Account ID.
  29. # @param body [CreateWebRtcConnectionRequest]
  30. # @param [Hash] opts the optional parameters
  31. # @return [Array<(CreateEndpointResponse, Integer, Hash)>] CreateEndpointResponse data, response status code and response headers
  32. 1 def create_endpoint_with_http_info(account_id, body, opts = {})
  33. 3 if @api_client.config.debugging
  34. 3 @api_client.config.logger.debug 'Calling API: EndpointsApi.create_endpoint ...'
  35. end
  36. # verify the required parameter 'account_id' is set
  37. 3 if @api_client.config.client_side_validation && account_id.nil?
  38. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling EndpointsApi.create_endpoint"
  39. end
  40. # verify the required parameter 'body' is set
  41. 2 if @api_client.config.client_side_validation && body.nil?
  42. 1 fail ArgumentError, "Missing the required parameter 'body' when calling EndpointsApi.create_endpoint"
  43. end
  44. # resource path
  45. 1 local_var_path = '/accounts/{accountId}/endpoints'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
  46. # query parameters
  47. 1 query_params = opts[:query_params] || {}
  48. # header parameters
  49. 1 header_params = opts[:header_params] || {}
  50. # HTTP header 'Accept' (if needed)
  51. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  52. # HTTP header 'Content-Type'
  53. 1 content_type = @api_client.select_header_content_type(['application/json'])
  54. 1 if !content_type.nil?
  55. 1 header_params['Content-Type'] = content_type
  56. end
  57. # form parameters
  58. 1 form_params = opts[:form_params] || {}
  59. # http body (model)
  60. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(body)
  61. # return_type
  62. 1 return_type = opts[:debug_return_type] || 'CreateEndpointResponse'
  63. # auth_names
  64. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  65. 1 new_options = opts.merge(
  66. :operation => :"EndpointsApi.create_endpoint",
  67. :header_params => header_params,
  68. :query_params => query_params,
  69. :form_params => form_params,
  70. :body => post_body,
  71. :auth_names => auth_names,
  72. :return_type => return_type
  73. )
  74. 1 data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  75. 1 if @api_client.config.debugging
  76. 1 @api_client.config.logger.debug "API called: EndpointsApi#create_endpoint\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  77. end
  78. 1 return data, status_code, headers
  79. end
  80. # Delete Endpoint
  81. # Deletes the specified endpoint. If the endpoint is actively streaming media, the media stream will be terminated.
  82. # @param account_id [String] Your Bandwidth Account ID.
  83. # @param endpoint_id [String] BRTC Endpoint ID.
  84. # @param [Hash] opts the optional parameters
  85. # @return [nil]
  86. 1 def delete_endpoint(account_id, endpoint_id, opts = {})
  87. 2 delete_endpoint_with_http_info(account_id, endpoint_id, opts)
  88. nil
  89. end
  90. # Delete Endpoint
  91. # Deletes the specified endpoint. If the endpoint is actively streaming media, the media stream will be terminated.
  92. # @param account_id [String] Your Bandwidth Account ID.
  93. # @param endpoint_id [String] BRTC Endpoint ID.
  94. # @param [Hash] opts the optional parameters
  95. # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
  96. 1 def delete_endpoint_with_http_info(account_id, endpoint_id, opts = {})
  97. 3 if @api_client.config.debugging
  98. 3 @api_client.config.logger.debug 'Calling API: EndpointsApi.delete_endpoint ...'
  99. end
  100. # verify the required parameter 'account_id' is set
  101. 3 if @api_client.config.client_side_validation && account_id.nil?
  102. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling EndpointsApi.delete_endpoint"
  103. end
  104. # verify the required parameter 'endpoint_id' is set
  105. 2 if @api_client.config.client_side_validation && endpoint_id.nil?
  106. 1 fail ArgumentError, "Missing the required parameter 'endpoint_id' when calling EndpointsApi.delete_endpoint"
  107. end
  108. # resource path
  109. 1 local_var_path = '/accounts/{accountId}/endpoints/{endpointId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'endpointId' + '}', CGI.escape(endpoint_id.to_s))
  110. # query parameters
  111. 1 query_params = opts[:query_params] || {}
  112. # header parameters
  113. 1 header_params = opts[:header_params] || {}
  114. # HTTP header 'Accept' (if needed)
  115. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  116. # form parameters
  117. 1 form_params = opts[:form_params] || {}
  118. # http body (model)
  119. 1 post_body = opts[:debug_body]
  120. # return_type
  121. 1 return_type = opts[:debug_return_type]
  122. # auth_names
  123. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  124. 1 new_options = opts.merge(
  125. :operation => :"EndpointsApi.delete_endpoint",
  126. :header_params => header_params,
  127. :query_params => query_params,
  128. :form_params => form_params,
  129. :body => post_body,
  130. :auth_names => auth_names,
  131. :return_type => return_type
  132. )
  133. 1 data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  134. 1 if @api_client.config.debugging
  135. 1 @api_client.config.logger.debug "API called: EndpointsApi#delete_endpoint\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  136. end
  137. 1 return data, status_code, headers
  138. end
  139. # Get Endpoint
  140. # Returns information about the specified endpoint.
  141. # @param account_id [String] Your Bandwidth Account ID.
  142. # @param endpoint_id [String] BRTC Endpoint ID.
  143. # @param [Hash] opts the optional parameters
  144. # @return [EndpointResponse]
  145. 1 def get_endpoint(account_id, endpoint_id, opts = {})
  146. 2 data, _status_code, _headers = get_endpoint_with_http_info(account_id, endpoint_id, opts)
  147. data
  148. end
  149. # Get Endpoint
  150. # Returns information about the specified endpoint.
  151. # @param account_id [String] Your Bandwidth Account ID.
  152. # @param endpoint_id [String] BRTC Endpoint ID.
  153. # @param [Hash] opts the optional parameters
  154. # @return [Array<(EndpointResponse, Integer, Hash)>] EndpointResponse data, response status code and response headers
  155. 1 def get_endpoint_with_http_info(account_id, endpoint_id, opts = {})
  156. 3 if @api_client.config.debugging
  157. 3 @api_client.config.logger.debug 'Calling API: EndpointsApi.get_endpoint ...'
  158. end
  159. # verify the required parameter 'account_id' is set
  160. 3 if @api_client.config.client_side_validation && account_id.nil?
  161. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling EndpointsApi.get_endpoint"
  162. end
  163. # verify the required parameter 'endpoint_id' is set
  164. 2 if @api_client.config.client_side_validation && endpoint_id.nil?
  165. 1 fail ArgumentError, "Missing the required parameter 'endpoint_id' when calling EndpointsApi.get_endpoint"
  166. end
  167. # resource path
  168. 1 local_var_path = '/accounts/{accountId}/endpoints/{endpointId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'endpointId' + '}', CGI.escape(endpoint_id.to_s))
  169. # query parameters
  170. 1 query_params = opts[:query_params] || {}
  171. # header parameters
  172. 1 header_params = opts[:header_params] || {}
  173. # HTTP header 'Accept' (if needed)
  174. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  175. # form parameters
  176. 1 form_params = opts[:form_params] || {}
  177. # http body (model)
  178. 1 post_body = opts[:debug_body]
  179. # return_type
  180. 1 return_type = opts[:debug_return_type] || 'EndpointResponse'
  181. # auth_names
  182. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  183. 1 new_options = opts.merge(
  184. :operation => :"EndpointsApi.get_endpoint",
  185. :header_params => header_params,
  186. :query_params => query_params,
  187. :form_params => form_params,
  188. :body => post_body,
  189. :auth_names => auth_names,
  190. :return_type => return_type
  191. )
  192. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  193. 1 if @api_client.config.debugging
  194. 1 @api_client.config.logger.debug "API called: EndpointsApi#get_endpoint\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  195. end
  196. 1 return data, status_code, headers
  197. end
  198. # List Endpoints
  199. # Returns a list of endpoints associated with the specified account.
  200. # @param account_id [String] Your Bandwidth Account ID.
  201. # @param [Hash] opts the optional parameters
  202. # @option opts [EndpointTypeEnum] :type The type of endpoint.
  203. # @option opts [EndpointStatusEnum] :status The status of the endpoint.
  204. # @option opts [String] :after_cursor The cursor to use for pagination. This is the value of the &#x60;next&#x60; link in the previous response.
  205. # @option opts [Integer] :limit The maximum number of endpoints to return in the response. (default to 100)
  206. # @return [ListEndpointsResponse]
  207. 1 def list_endpoints(account_id, opts = {})
  208. 1 data, _status_code, _headers = list_endpoints_with_http_info(account_id, opts)
  209. data
  210. end
  211. # List Endpoints
  212. # Returns a list of endpoints associated with the specified account.
  213. # @param account_id [String] Your Bandwidth Account ID.
  214. # @param [Hash] opts the optional parameters
  215. # @option opts [EndpointTypeEnum] :type The type of endpoint.
  216. # @option opts [EndpointStatusEnum] :status The status of the endpoint.
  217. # @option opts [String] :after_cursor The cursor to use for pagination. This is the value of the &#x60;next&#x60; link in the previous response.
  218. # @option opts [Integer] :limit The maximum number of endpoints to return in the response. (default to 100)
  219. # @return [Array<(ListEndpointsResponse, Integer, Hash)>] ListEndpointsResponse data, response status code and response headers
  220. 1 def list_endpoints_with_http_info(account_id, opts = {})
  221. 2 if @api_client.config.debugging
  222. 2 @api_client.config.logger.debug 'Calling API: EndpointsApi.list_endpoints ...'
  223. end
  224. # verify the required parameter 'account_id' is set
  225. 2 if @api_client.config.client_side_validation && account_id.nil?
  226. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling EndpointsApi.list_endpoints"
  227. end
  228. 1 if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 1000
  229. fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling EndpointsApi.list_endpoints, must be smaller than or equal to 1000.'
  230. end
  231. 1 if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
  232. fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling EndpointsApi.list_endpoints, must be greater than or equal to 1.'
  233. end
  234. # resource path
  235. 1 local_var_path = '/accounts/{accountId}/endpoints'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
  236. # query parameters
  237. 1 query_params = opts[:query_params] || {}
  238. 1 query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil?
  239. 1 query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?
  240. 1 query_params[:'afterCursor'] = opts[:'after_cursor'] if !opts[:'after_cursor'].nil?
  241. 1 query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  242. # header parameters
  243. 1 header_params = opts[:header_params] || {}
  244. # HTTP header 'Accept' (if needed)
  245. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  246. # form parameters
  247. 1 form_params = opts[:form_params] || {}
  248. # http body (model)
  249. 1 post_body = opts[:debug_body]
  250. # return_type
  251. 1 return_type = opts[:debug_return_type] || 'ListEndpointsResponse'
  252. # auth_names
  253. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  254. 1 new_options = opts.merge(
  255. :operation => :"EndpointsApi.list_endpoints",
  256. :header_params => header_params,
  257. :query_params => query_params,
  258. :form_params => form_params,
  259. :body => post_body,
  260. :auth_names => auth_names,
  261. :return_type => return_type
  262. )
  263. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  264. 1 if @api_client.config.debugging
  265. 1 @api_client.config.logger.debug "API called: EndpointsApi#list_endpoints\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  266. end
  267. 1 return data, status_code, headers
  268. end
  269. # Update Endpoint BXML
  270. # Updates the BXML for the specified endpoint.
  271. # @param account_id [String] Your Bandwidth Account ID.
  272. # @param endpoint_id [String] BRTC Endpoint ID.
  273. # @param body [String]
  274. # @param [Hash] opts the optional parameters
  275. # @return [nil]
  276. 1 def update_endpoint_bxml(account_id, endpoint_id, body, opts = {})
  277. 3 update_endpoint_bxml_with_http_info(account_id, endpoint_id, body, opts)
  278. nil
  279. end
  280. # Update Endpoint BXML
  281. # Updates the BXML for the specified endpoint.
  282. # @param account_id [String] Your Bandwidth Account ID.
  283. # @param endpoint_id [String] BRTC Endpoint ID.
  284. # @param body [String]
  285. # @param [Hash] opts the optional parameters
  286. # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
  287. 1 def update_endpoint_bxml_with_http_info(account_id, endpoint_id, body, opts = {})
  288. 4 if @api_client.config.debugging
  289. 4 @api_client.config.logger.debug 'Calling API: EndpointsApi.update_endpoint_bxml ...'
  290. end
  291. # verify the required parameter 'account_id' is set
  292. 4 if @api_client.config.client_side_validation && account_id.nil?
  293. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling EndpointsApi.update_endpoint_bxml"
  294. end
  295. # verify the required parameter 'endpoint_id' is set
  296. 3 if @api_client.config.client_side_validation && endpoint_id.nil?
  297. 1 fail ArgumentError, "Missing the required parameter 'endpoint_id' when calling EndpointsApi.update_endpoint_bxml"
  298. end
  299. # verify the required parameter 'body' is set
  300. 2 if @api_client.config.client_side_validation && body.nil?
  301. 1 fail ArgumentError, "Missing the required parameter 'body' when calling EndpointsApi.update_endpoint_bxml"
  302. end
  303. # resource path
  304. 1 local_var_path = '/accounts/{accountId}/endpoints/{endpointId}/bxml'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'endpointId' + '}', CGI.escape(endpoint_id.to_s))
  305. # query parameters
  306. 1 query_params = opts[:query_params] || {}
  307. # header parameters
  308. 1 header_params = opts[:header_params] || {}
  309. # HTTP header 'Accept' (if needed)
  310. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  311. # HTTP header 'Content-Type'
  312. 1 content_type = @api_client.select_header_content_type(['application/xml'])
  313. 1 if !content_type.nil?
  314. 1 header_params['Content-Type'] = content_type
  315. end
  316. # form parameters
  317. 1 form_params = opts[:form_params] || {}
  318. # http body (model)
  319. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(body)
  320. # return_type
  321. 1 return_type = opts[:debug_return_type]
  322. # auth_names
  323. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  324. 1 new_options = opts.merge(
  325. :operation => :"EndpointsApi.update_endpoint_bxml",
  326. :header_params => header_params,
  327. :query_params => query_params,
  328. :form_params => form_params,
  329. :body => post_body,
  330. :auth_names => auth_names,
  331. :return_type => return_type
  332. )
  333. 1 data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  334. 1 if @api_client.config.debugging
  335. 1 @api_client.config.logger.debug "API called: EndpointsApi#update_endpoint_bxml\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  336. end
  337. 1 return data, status_code, headers
  338. end
  339. end
  340. end

lib/bandwidth-sdk/api/media_api.rb

98.04% lines covered

102 relevant lines. 100 lines covered and 2 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'cgi'
  10. 1 module Bandwidth
  11. 1 class MediaApi
  12. 1 attr_accessor :api_client
  13. 1 def initialize(api_client = ApiClient.default)
  14. 1 @api_client = api_client
  15. end
  16. # Delete Media
  17. # Deletes a media file from Bandwidth API server. Make sure you don't have any application scripts still using the media before you delete. If you accidentally delete a media file you can immediately upload a new file with the same name.
  18. # @param account_id [String] Your Bandwidth Account ID.
  19. # @param media_id [String] Media ID to retrieve.
  20. # @param [Hash] opts the optional parameters
  21. # @return [nil]
  22. 1 def delete_media(account_id, media_id, opts = {})
  23. 2 delete_media_with_http_info(account_id, media_id, opts)
  24. nil
  25. end
  26. # Delete Media
  27. # Deletes a media file from Bandwidth API server. Make sure you don&#39;t have any application scripts still using the media before you delete. If you accidentally delete a media file you can immediately upload a new file with the same name.
  28. # @param account_id [String] Your Bandwidth Account ID.
  29. # @param media_id [String] Media ID to retrieve.
  30. # @param [Hash] opts the optional parameters
  31. # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
  32. 1 def delete_media_with_http_info(account_id, media_id, opts = {})
  33. 3 if @api_client.config.debugging
  34. 3 @api_client.config.logger.debug 'Calling API: MediaApi.delete_media ...'
  35. end
  36. # verify the required parameter 'account_id' is set
  37. 3 if @api_client.config.client_side_validation && account_id.nil?
  38. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling MediaApi.delete_media"
  39. end
  40. # verify the required parameter 'media_id' is set
  41. 2 if @api_client.config.client_side_validation && media_id.nil?
  42. 1 fail ArgumentError, "Missing the required parameter 'media_id' when calling MediaApi.delete_media"
  43. end
  44. # resource path
  45. 1 local_var_path = '/users/{accountId}/media/{mediaId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'mediaId' + '}', CGI.escape(media_id.to_s))
  46. # query parameters
  47. 1 query_params = opts[:query_params] || {}
  48. # header parameters
  49. 1 header_params = opts[:header_params] || {}
  50. # HTTP header 'Accept' (if needed)
  51. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  52. # form parameters
  53. 1 form_params = opts[:form_params] || {}
  54. # http body (model)
  55. 1 post_body = opts[:debug_body]
  56. # return_type
  57. 1 return_type = opts[:debug_return_type]
  58. # auth_names
  59. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  60. 1 new_options = opts.merge(
  61. :operation => :"MediaApi.delete_media",
  62. :header_params => header_params,
  63. :query_params => query_params,
  64. :form_params => form_params,
  65. :body => post_body,
  66. :auth_names => auth_names,
  67. :return_type => return_type
  68. )
  69. 1 data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  70. 1 if @api_client.config.debugging
  71. 1 @api_client.config.logger.debug "API called: MediaApi#delete_media\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  72. end
  73. 1 return data, status_code, headers
  74. end
  75. # Get Media
  76. # Downloads a media file you previously uploaded.
  77. # @param account_id [String] Your Bandwidth Account ID.
  78. # @param media_id [String] Media ID to retrieve.
  79. # @param [Hash] opts the optional parameters
  80. # @return [File]
  81. 1 def get_media(account_id, media_id, opts = {})
  82. 2 data, _status_code, _headers = get_media_with_http_info(account_id, media_id, opts)
  83. data
  84. end
  85. # Get Media
  86. # Downloads a media file you previously uploaded.
  87. # @param account_id [String] Your Bandwidth Account ID.
  88. # @param media_id [String] Media ID to retrieve.
  89. # @param [Hash] opts the optional parameters
  90. # @return [Array<(File, Integer, Hash)>] File data, response status code and response headers
  91. 1 def get_media_with_http_info(account_id, media_id, opts = {})
  92. 3 if @api_client.config.debugging
  93. 3 @api_client.config.logger.debug 'Calling API: MediaApi.get_media ...'
  94. end
  95. # verify the required parameter 'account_id' is set
  96. 3 if @api_client.config.client_side_validation && account_id.nil?
  97. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling MediaApi.get_media"
  98. end
  99. # verify the required parameter 'media_id' is set
  100. 2 if @api_client.config.client_side_validation && media_id.nil?
  101. 1 fail ArgumentError, "Missing the required parameter 'media_id' when calling MediaApi.get_media"
  102. end
  103. # resource path
  104. 1 local_var_path = '/users/{accountId}/media/{mediaId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'mediaId' + '}', CGI.escape(media_id.to_s))
  105. # query parameters
  106. 1 query_params = opts[:query_params] || {}
  107. # header parameters
  108. 1 header_params = opts[:header_params] || {}
  109. # HTTP header 'Accept' (if needed)
  110. 1 header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream', 'application/json']) unless header_params['Accept']
  111. # form parameters
  112. 1 form_params = opts[:form_params] || {}
  113. # http body (model)
  114. 1 post_body = opts[:debug_body]
  115. # return_type
  116. 1 return_type = opts[:debug_return_type] || 'File'
  117. # auth_names
  118. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  119. 1 new_options = opts.merge(
  120. :operation => :"MediaApi.get_media",
  121. :header_params => header_params,
  122. :query_params => query_params,
  123. :form_params => form_params,
  124. :body => post_body,
  125. :auth_names => auth_names,
  126. :return_type => return_type
  127. )
  128. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  129. 1 if @api_client.config.debugging
  130. 1 @api_client.config.logger.debug "API called: MediaApi#get_media\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  131. end
  132. 1 return data, status_code, headers
  133. end
  134. # List Media
  135. # Gets a list of your media files. No query parameters are supported.
  136. # @param account_id [String] Your Bandwidth Account ID.
  137. # @param [Hash] opts the optional parameters
  138. # @option opts [String] :continuation_token Continuation token used to retrieve subsequent media.
  139. # @return [Array<Media>]
  140. 1 def list_media(account_id, opts = {})
  141. 1 data, _status_code, _headers = list_media_with_http_info(account_id, opts)
  142. data
  143. end
  144. # List Media
  145. # Gets a list of your media files. No query parameters are supported.
  146. # @param account_id [String] Your Bandwidth Account ID.
  147. # @param [Hash] opts the optional parameters
  148. # @option opts [String] :continuation_token Continuation token used to retrieve subsequent media.
  149. # @return [Array<(Array<Media>, Integer, Hash)>] Array<Media> data, response status code and response headers
  150. 1 def list_media_with_http_info(account_id, opts = {})
  151. 2 if @api_client.config.debugging
  152. 2 @api_client.config.logger.debug 'Calling API: MediaApi.list_media ...'
  153. end
  154. # verify the required parameter 'account_id' is set
  155. 2 if @api_client.config.client_side_validation && account_id.nil?
  156. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling MediaApi.list_media"
  157. end
  158. # resource path
  159. 1 local_var_path = '/users/{accountId}/media'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
  160. # query parameters
  161. 1 query_params = opts[:query_params] || {}
  162. # header parameters
  163. 1 header_params = opts[:header_params] || {}
  164. # HTTP header 'Accept' (if needed)
  165. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  166. 1 header_params[:'Continuation-Token'] = opts[:'continuation_token'] if !opts[:'continuation_token'].nil?
  167. # form parameters
  168. 1 form_params = opts[:form_params] || {}
  169. # http body (model)
  170. 1 post_body = opts[:debug_body]
  171. # return_type
  172. 1 return_type = opts[:debug_return_type] || 'Array<Media>'
  173. # auth_names
  174. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  175. 1 new_options = opts.merge(
  176. :operation => :"MediaApi.list_media",
  177. :header_params => header_params,
  178. :query_params => query_params,
  179. :form_params => form_params,
  180. :body => post_body,
  181. :auth_names => auth_names,
  182. :return_type => return_type
  183. )
  184. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  185. 1 if @api_client.config.debugging
  186. 1 @api_client.config.logger.debug "API called: MediaApi#list_media\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  187. end
  188. 1 return data, status_code, headers
  189. end
  190. # Upload Media
  191. # Upload a file. You may add headers to the request in order to provide some control to your media file. If a file is uploaded with the same name as a file that already exists under this account, the previous file will be overwritten. A list of supported media types can be found at [Bandwidth Support](https://www.bandwidth.com/support/en/articles/12823220-what-mms-file-types-are-supported).
  192. # @param account_id [String] Your Bandwidth Account ID.
  193. # @param media_id [String] Media ID to retrieve.
  194. # @param body [File]
  195. # @param [Hash] opts the optional parameters
  196. # @option opts [String] :content_type The media type of the entity-body.
  197. # @option opts [String] :cache_control General-header field is used to specify directives that MUST be obeyed by all caching mechanisms along the request/response chain.
  198. # @return [nil]
  199. 1 def upload_media(account_id, media_id, body, opts = {})
  200. 3 upload_media_with_http_info(account_id, media_id, body, opts)
  201. nil
  202. end
  203. # Upload Media
  204. # Upload a file. You may add headers to the request in order to provide some control to your media file. If a file is uploaded with the same name as a file that already exists under this account, the previous file will be overwritten. A list of supported media types can be found at [Bandwidth Support](https://www.bandwidth.com/support/en/articles/12823220-what-mms-file-types-are-supported).
  205. # @param account_id [String] Your Bandwidth Account ID.
  206. # @param media_id [String] Media ID to retrieve.
  207. # @param body [File]
  208. # @param [Hash] opts the optional parameters
  209. # @option opts [String] :content_type The media type of the entity-body.
  210. # @option opts [String] :cache_control General-header field is used to specify directives that MUST be obeyed by all caching mechanisms along the request/response chain.
  211. # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
  212. 1 def upload_media_with_http_info(account_id, media_id, body, opts = {})
  213. 4 if @api_client.config.debugging
  214. 4 @api_client.config.logger.debug 'Calling API: MediaApi.upload_media ...'
  215. end
  216. # verify the required parameter 'account_id' is set
  217. 4 if @api_client.config.client_side_validation && account_id.nil?
  218. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling MediaApi.upload_media"
  219. end
  220. # verify the required parameter 'media_id' is set
  221. 3 if @api_client.config.client_side_validation && media_id.nil?
  222. 1 fail ArgumentError, "Missing the required parameter 'media_id' when calling MediaApi.upload_media"
  223. end
  224. # verify the required parameter 'body' is set
  225. 2 if @api_client.config.client_side_validation && body.nil?
  226. 1 fail ArgumentError, "Missing the required parameter 'body' when calling MediaApi.upload_media"
  227. end
  228. # resource path
  229. 1 local_var_path = '/users/{accountId}/media/{mediaId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'mediaId' + '}', CGI.escape(media_id.to_s))
  230. # query parameters
  231. 1 query_params = opts[:query_params] || {}
  232. # header parameters
  233. 1 header_params = opts[:header_params] || {}
  234. # HTTP header 'Accept' (if needed)
  235. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  236. # HTTP header 'Content-Type'
  237. 1 content_type = @api_client.select_header_content_type(['application/json', 'application/ogg', 'application/pdf', 'application/rtf', 'application/zip', 'application/x-tar', 'application/xml', 'application/gzip', 'application/x-bzip2', 'application/x-gzip', 'application/smil', 'application/javascript', 'audio/mp4', 'audio/mpeg', 'audio/ogg', 'audio/flac', 'audio/webm', 'audio/wav', 'audio/amr', 'audio/3gpp', 'image/bmp', 'image/gif', 'image/heic', 'image/heif', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/svg+xml', 'image/tiff', 'image/webp', 'image/x-icon', 'text/css', 'text/csv', 'text/calendar', 'text/html', 'text/plain', 'text/javascript', 'text/vcard', 'text/vnd.wap.wml', 'text/xml', 'video/avi', 'video/mp4', 'video/mpeg', 'video/ogg', 'video/quicktime', 'video/webm', 'video/x-ms-wmv', 'video/x-flv'])
  238. 1 if !content_type.nil?
  239. 1 header_params['Content-Type'] = content_type
  240. end
  241. 1 header_params[:'Content-Type'] = opts[:'content_type'] if !opts[:'content_type'].nil?
  242. 1 header_params[:'Cache-Control'] = opts[:'cache_control'] if !opts[:'cache_control'].nil?
  243. # form parameters
  244. 1 form_params = opts[:form_params] || {}
  245. # http body (model)
  246. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(body)
  247. # return_type
  248. 1 return_type = opts[:debug_return_type]
  249. # auth_names
  250. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  251. 1 new_options = opts.merge(
  252. :operation => :"MediaApi.upload_media",
  253. :header_params => header_params,
  254. :query_params => query_params,
  255. :form_params => form_params,
  256. :body => post_body,
  257. :auth_names => auth_names,
  258. :return_type => return_type
  259. )
  260. 1 data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  261. 1 if @api_client.config.debugging
  262. 1 @api_client.config.logger.debug "API called: MediaApi#upload_media\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  263. end
  264. 1 return data, status_code, headers
  265. end
  266. end
  267. end

lib/bandwidth-sdk/api/messages_api.rb

97.5% lines covered

80 relevant lines. 78 lines covered and 2 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'cgi'
  10. 1 module Bandwidth
  11. 1 class MessagesApi
  12. 1 attr_accessor :api_client
  13. 1 def initialize(api_client = ApiClient.default)
  14. 1 @api_client = api_client
  15. end
  16. # Create Message
  17. # Endpoint for sending text messages and picture messages using V2 messaging.
  18. # @param account_id [String] Your Bandwidth Account ID.
  19. # @param message_request [MessageRequest]
  20. # @param [Hash] opts the optional parameters
  21. # @return [Message]
  22. 1 def create_message(account_id, message_request, opts = {})
  23. 2 data, _status_code, _headers = create_message_with_http_info(account_id, message_request, opts)
  24. data
  25. end
  26. # Create Message
  27. # Endpoint for sending text messages and picture messages using V2 messaging.
  28. # @param account_id [String] Your Bandwidth Account ID.
  29. # @param message_request [MessageRequest]
  30. # @param [Hash] opts the optional parameters
  31. # @return [Array<(Message, Integer, Hash)>] Message data, response status code and response headers
  32. 1 def create_message_with_http_info(account_id, message_request, opts = {})
  33. 3 if @api_client.config.debugging
  34. 3 @api_client.config.logger.debug 'Calling API: MessagesApi.create_message ...'
  35. end
  36. # verify the required parameter 'account_id' is set
  37. 3 if @api_client.config.client_side_validation && account_id.nil?
  38. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling MessagesApi.create_message"
  39. end
  40. # verify the required parameter 'message_request' is set
  41. 2 if @api_client.config.client_side_validation && message_request.nil?
  42. 1 fail ArgumentError, "Missing the required parameter 'message_request' when calling MessagesApi.create_message"
  43. end
  44. # resource path
  45. 1 local_var_path = '/users/{accountId}/messages'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
  46. # query parameters
  47. 1 query_params = opts[:query_params] || {}
  48. # header parameters
  49. 1 header_params = opts[:header_params] || {}
  50. # HTTP header 'Accept' (if needed)
  51. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  52. # HTTP header 'Content-Type'
  53. 1 content_type = @api_client.select_header_content_type(['application/json'])
  54. 1 if !content_type.nil?
  55. 1 header_params['Content-Type'] = content_type
  56. end
  57. # form parameters
  58. 1 form_params = opts[:form_params] || {}
  59. # http body (model)
  60. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(message_request)
  61. # return_type
  62. 1 return_type = opts[:debug_return_type] || 'Message'
  63. # auth_names
  64. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  65. 1 new_options = opts.merge(
  66. :operation => :"MessagesApi.create_message",
  67. :header_params => header_params,
  68. :query_params => query_params,
  69. :form_params => form_params,
  70. :body => post_body,
  71. :auth_names => auth_names,
  72. :return_type => return_type
  73. )
  74. 1 data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  75. 1 if @api_client.config.debugging
  76. 1 @api_client.config.logger.debug "API called: MessagesApi#create_message\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  77. end
  78. 1 return data, status_code, headers
  79. end
  80. # List Messages
  81. # Returns a list of messages based on query parameters. **Rate Limit:** This endpoint is rate limited to 3500 requests per 5 minutes per Source IP address. Exceeding the limit returns HTTP 429 with a `Retry-After` header.
  82. # @param account_id [String] Your Bandwidth Account ID.
  83. # @param [Hash] opts the optional parameters
  84. # @option opts [String] :message_id The ID of the message to search for. Special characters need to be encoded using URL encoding. Message IDs could come in different formats, e.g., 9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6 and 1589228074636lm4k2je7j7jklbn2 are valid message ID formats. Note that you must include at least one query parameter.
  85. # @option opts [String] :source_tn The phone number that sent the message. Accepted values are: a single full phone number a comma separated list of full phone numbers (maximum of 10) or a single partial phone number (minimum of 5 characters e.g. &#39;%2B1919&#39;).
  86. # @option opts [String] :destination_tn The phone number that received the message. Accepted values are: a single full phone number a comma separated list of full phone numbers (maximum of 10) or a single partial phone number (minimum of 5 characters e.g. &#39;%2B1919&#39;).
  87. # @option opts [MessageStatusEnum] :message_status The status of the message. One of RECEIVED QUEUED SENDING SENT FAILED DELIVERED ACCEPTED UNDELIVERED.
  88. # @option opts [ListMessageDirectionEnum] :message_direction The direction of the message. One of INBOUND OUTBOUND.
  89. # @option opts [String] :carrier_name The name of the carrier used for this message. Possible values include but are not limited to Verizon and TMobile. Special characters need to be encoded using URL encoding (i.e. AT&amp;T should be passed as AT%26T).
  90. # @option opts [MessageTypeEnum] :message_type The type of message. Either sms or mms.
  91. # @option opts [Integer] :error_code The error code of the message.
  92. # @option opts [String] :from_date_time The start of the date range to search in ISO 8601 format. Uses the message receive time. The date range to search in is currently 14 days.
  93. # @option opts [String] :to_date_time The end of the date range to search in ISO 8601 format. Uses the message receive time. The date range to search in is currently 14 days.
  94. # @option opts [String] :campaign_id The campaign ID of the message.
  95. # @option opts [Integer] :from_bw_latency The minimum Bandwidth latency of the message in seconds. Only available for accounts with the Advanced Quality Metrics feature enabled.
  96. # @option opts [Boolean] :bw_queued A boolean value indicating whether the message is queued in the Bandwidth network.
  97. # @option opts [ProductTypeEnum] :product Messaging product associated with the message.
  98. # @option opts [String] :location Location Id associated with the message.
  99. # @option opts [Boolean] :carrier_queued A boolean value indicating whether the message is queued in the carrier network. Only available for OUTBOUND messages from accounts with the Advanced Quality Metrics feature enabled.
  100. # @option opts [Integer] :from_carrier_latency The minimum carrier latency of the message in seconds. Only available for OUTBOUND messages from accounts with the Advanced Quality Metrics feature enabled.
  101. # @option opts [String] :calling_number_country_a3 Calling number country in A3 format.
  102. # @option opts [String] :called_number_country_a3 Called number country in A3 format.
  103. # @option opts [Integer] :from_segment_count Segment count (start range).
  104. # @option opts [Integer] :to_segment_count Segment count (end range).
  105. # @option opts [Integer] :from_message_size Message size (start range).
  106. # @option opts [Integer] :to_message_size Message size (end range).
  107. # @option opts [String] :sort The field and direction to sort by combined with a colon. Direction is either asc or desc.
  108. # @option opts [String] :page_token A base64 encoded value used for pagination of results.
  109. # @option opts [Integer] :limit The maximum records requested in search result. Default 100. The sum of limit and after cannot be more than 10000.
  110. # @option opts [Boolean] :limit_total_count When set to true, the response&#39;s totalCount field will have a maximum value of 10,000. When set to false, or excluded, this will give an accurate totalCount of all messages that match the provided filters. If you are experiencing latency, try using this parameter to limit your results.
  111. # @return [MessagesList]
  112. 1 def list_messages(account_id, opts = {})
  113. 1 data, _status_code, _headers = list_messages_with_http_info(account_id, opts)
  114. data
  115. end
  116. # List Messages
  117. # Returns a list of messages based on query parameters. **Rate Limit:** This endpoint is rate limited to 3500 requests per 5 minutes per Source IP address. Exceeding the limit returns HTTP 429 with a &#x60;Retry-After&#x60; header.
  118. # @param account_id [String] Your Bandwidth Account ID.
  119. # @param [Hash] opts the optional parameters
  120. # @option opts [String] :message_id The ID of the message to search for. Special characters need to be encoded using URL encoding. Message IDs could come in different formats, e.g., 9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6 and 1589228074636lm4k2je7j7jklbn2 are valid message ID formats. Note that you must include at least one query parameter.
  121. # @option opts [String] :source_tn The phone number that sent the message. Accepted values are: a single full phone number a comma separated list of full phone numbers (maximum of 10) or a single partial phone number (minimum of 5 characters e.g. &#39;%2B1919&#39;).
  122. # @option opts [String] :destination_tn The phone number that received the message. Accepted values are: a single full phone number a comma separated list of full phone numbers (maximum of 10) or a single partial phone number (minimum of 5 characters e.g. &#39;%2B1919&#39;).
  123. # @option opts [MessageStatusEnum] :message_status The status of the message. One of RECEIVED QUEUED SENDING SENT FAILED DELIVERED ACCEPTED UNDELIVERED.
  124. # @option opts [ListMessageDirectionEnum] :message_direction The direction of the message. One of INBOUND OUTBOUND.
  125. # @option opts [String] :carrier_name The name of the carrier used for this message. Possible values include but are not limited to Verizon and TMobile. Special characters need to be encoded using URL encoding (i.e. AT&amp;T should be passed as AT%26T).
  126. # @option opts [MessageTypeEnum] :message_type The type of message. Either sms or mms.
  127. # @option opts [Integer] :error_code The error code of the message.
  128. # @option opts [String] :from_date_time The start of the date range to search in ISO 8601 format. Uses the message receive time. The date range to search in is currently 14 days.
  129. # @option opts [String] :to_date_time The end of the date range to search in ISO 8601 format. Uses the message receive time. The date range to search in is currently 14 days.
  130. # @option opts [String] :campaign_id The campaign ID of the message.
  131. # @option opts [Integer] :from_bw_latency The minimum Bandwidth latency of the message in seconds. Only available for accounts with the Advanced Quality Metrics feature enabled.
  132. # @option opts [Boolean] :bw_queued A boolean value indicating whether the message is queued in the Bandwidth network.
  133. # @option opts [ProductTypeEnum] :product Messaging product associated with the message.
  134. # @option opts [String] :location Location Id associated with the message.
  135. # @option opts [Boolean] :carrier_queued A boolean value indicating whether the message is queued in the carrier network. Only available for OUTBOUND messages from accounts with the Advanced Quality Metrics feature enabled.
  136. # @option opts [Integer] :from_carrier_latency The minimum carrier latency of the message in seconds. Only available for OUTBOUND messages from accounts with the Advanced Quality Metrics feature enabled.
  137. # @option opts [String] :calling_number_country_a3 Calling number country in A3 format.
  138. # @option opts [String] :called_number_country_a3 Called number country in A3 format.
  139. # @option opts [Integer] :from_segment_count Segment count (start range).
  140. # @option opts [Integer] :to_segment_count Segment count (end range).
  141. # @option opts [Integer] :from_message_size Message size (start range).
  142. # @option opts [Integer] :to_message_size Message size (end range).
  143. # @option opts [String] :sort The field and direction to sort by combined with a colon. Direction is either asc or desc.
  144. # @option opts [String] :page_token A base64 encoded value used for pagination of results.
  145. # @option opts [Integer] :limit The maximum records requested in search result. Default 100. The sum of limit and after cannot be more than 10000.
  146. # @option opts [Boolean] :limit_total_count When set to true, the response&#39;s totalCount field will have a maximum value of 10,000. When set to false, or excluded, this will give an accurate totalCount of all messages that match the provided filters. If you are experiencing latency, try using this parameter to limit your results.
  147. # @return [Array<(MessagesList, Integer, Hash)>] MessagesList data, response status code and response headers
  148. 1 def list_messages_with_http_info(account_id, opts = {})
  149. 2 if @api_client.config.debugging
  150. 2 @api_client.config.logger.debug 'Calling API: MessagesApi.list_messages ...'
  151. end
  152. # verify the required parameter 'account_id' is set
  153. 2 if @api_client.config.client_side_validation && account_id.nil?
  154. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling MessagesApi.list_messages"
  155. end
  156. # resource path
  157. 1 local_var_path = '/users/{accountId}/messages'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
  158. # query parameters
  159. 1 query_params = opts[:query_params] || {}
  160. 1 query_params[:'messageId'] = opts[:'message_id'] if !opts[:'message_id'].nil?
  161. 1 query_params[:'sourceTn'] = opts[:'source_tn'] if !opts[:'source_tn'].nil?
  162. 1 query_params[:'destinationTn'] = opts[:'destination_tn'] if !opts[:'destination_tn'].nil?
  163. 1 query_params[:'messageStatus'] = opts[:'message_status'] if !opts[:'message_status'].nil?
  164. 1 query_params[:'messageDirection'] = opts[:'message_direction'] if !opts[:'message_direction'].nil?
  165. 1 query_params[:'carrierName'] = opts[:'carrier_name'] if !opts[:'carrier_name'].nil?
  166. 1 query_params[:'messageType'] = opts[:'message_type'] if !opts[:'message_type'].nil?
  167. 1 query_params[:'errorCode'] = opts[:'error_code'] if !opts[:'error_code'].nil?
  168. 1 query_params[:'fromDateTime'] = opts[:'from_date_time'] if !opts[:'from_date_time'].nil?
  169. 1 query_params[:'toDateTime'] = opts[:'to_date_time'] if !opts[:'to_date_time'].nil?
  170. 1 query_params[:'campaignId'] = opts[:'campaign_id'] if !opts[:'campaign_id'].nil?
  171. 1 query_params[:'fromBwLatency'] = opts[:'from_bw_latency'] if !opts[:'from_bw_latency'].nil?
  172. 1 query_params[:'bwQueued'] = opts[:'bw_queued'] if !opts[:'bw_queued'].nil?
  173. 1 query_params[:'product'] = opts[:'product'] if !opts[:'product'].nil?
  174. 1 query_params[:'location'] = opts[:'location'] if !opts[:'location'].nil?
  175. 1 query_params[:'carrierQueued'] = opts[:'carrier_queued'] if !opts[:'carrier_queued'].nil?
  176. 1 query_params[:'fromCarrierLatency'] = opts[:'from_carrier_latency'] if !opts[:'from_carrier_latency'].nil?
  177. 1 query_params[:'callingNumberCountryA3'] = opts[:'calling_number_country_a3'] if !opts[:'calling_number_country_a3'].nil?
  178. 1 query_params[:'calledNumberCountryA3'] = opts[:'called_number_country_a3'] if !opts[:'called_number_country_a3'].nil?
  179. 1 query_params[:'fromSegmentCount'] = opts[:'from_segment_count'] if !opts[:'from_segment_count'].nil?
  180. 1 query_params[:'toSegmentCount'] = opts[:'to_segment_count'] if !opts[:'to_segment_count'].nil?
  181. 1 query_params[:'fromMessageSize'] = opts[:'from_message_size'] if !opts[:'from_message_size'].nil?
  182. 1 query_params[:'toMessageSize'] = opts[:'to_message_size'] if !opts[:'to_message_size'].nil?
  183. 1 query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
  184. 1 query_params[:'pageToken'] = opts[:'page_token'] if !opts[:'page_token'].nil?
  185. 1 query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  186. 1 query_params[:'limitTotalCount'] = opts[:'limit_total_count'] if !opts[:'limit_total_count'].nil?
  187. # header parameters
  188. 1 header_params = opts[:header_params] || {}
  189. # HTTP header 'Accept' (if needed)
  190. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  191. # form parameters
  192. 1 form_params = opts[:form_params] || {}
  193. # http body (model)
  194. 1 post_body = opts[:debug_body]
  195. # return_type
  196. 1 return_type = opts[:debug_return_type] || 'MessagesList'
  197. # auth_names
  198. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  199. 1 new_options = opts.merge(
  200. :operation => :"MessagesApi.list_messages",
  201. :header_params => header_params,
  202. :query_params => query_params,
  203. :form_params => form_params,
  204. :body => post_body,
  205. :auth_names => auth_names,
  206. :return_type => return_type
  207. )
  208. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  209. 1 if @api_client.config.debugging
  210. 1 @api_client.config.logger.debug "API called: MessagesApi#list_messages\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  211. end
  212. 1 return data, status_code, headers
  213. end
  214. end
  215. end

lib/bandwidth-sdk/api/mfa_api.rb

96.43% lines covered

84 relevant lines. 81 lines covered and 3 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'cgi'
  10. 1 module Bandwidth
  11. 1 class MFAApi
  12. 1 attr_accessor :api_client
  13. 1 def initialize(api_client = ApiClient.default)
  14. 1 @api_client = api_client
  15. end
  16. # Messaging Authentication Code
  17. # Send an MFA code via text message (SMS).
  18. # @param account_id [String] Your Bandwidth Account ID.
  19. # @param code_request [CodeRequest] MFA code request body.
  20. # @param [Hash] opts the optional parameters
  21. # @return [MessagingCodeResponse]
  22. 1 def generate_messaging_code(account_id, code_request, opts = {})
  23. 2 data, _status_code, _headers = generate_messaging_code_with_http_info(account_id, code_request, opts)
  24. data
  25. end
  26. # Messaging Authentication Code
  27. # Send an MFA code via text message (SMS).
  28. # @param account_id [String] Your Bandwidth Account ID.
  29. # @param code_request [CodeRequest] MFA code request body.
  30. # @param [Hash] opts the optional parameters
  31. # @return [Array<(MessagingCodeResponse, Integer, Hash)>] MessagingCodeResponse data, response status code and response headers
  32. 1 def generate_messaging_code_with_http_info(account_id, code_request, opts = {})
  33. 3 if @api_client.config.debugging
  34. 3 @api_client.config.logger.debug 'Calling API: MFAApi.generate_messaging_code ...'
  35. end
  36. # verify the required parameter 'account_id' is set
  37. 3 if @api_client.config.client_side_validation && account_id.nil?
  38. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling MFAApi.generate_messaging_code"
  39. end
  40. # verify the required parameter 'code_request' is set
  41. 2 if @api_client.config.client_side_validation && code_request.nil?
  42. 1 fail ArgumentError, "Missing the required parameter 'code_request' when calling MFAApi.generate_messaging_code"
  43. end
  44. # resource path
  45. 1 local_var_path = '/accounts/{accountId}/code/messaging'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
  46. # query parameters
  47. 1 query_params = opts[:query_params] || {}
  48. # header parameters
  49. 1 header_params = opts[:header_params] || {}
  50. # HTTP header 'Accept' (if needed)
  51. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  52. # HTTP header 'Content-Type'
  53. 1 content_type = @api_client.select_header_content_type(['application/json'])
  54. 1 if !content_type.nil?
  55. 1 header_params['Content-Type'] = content_type
  56. end
  57. # form parameters
  58. 1 form_params = opts[:form_params] || {}
  59. # http body (model)
  60. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(code_request)
  61. # return_type
  62. 1 return_type = opts[:debug_return_type] || 'MessagingCodeResponse'
  63. # auth_names
  64. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  65. 1 new_options = opts.merge(
  66. :operation => :"MFAApi.generate_messaging_code",
  67. :header_params => header_params,
  68. :query_params => query_params,
  69. :form_params => form_params,
  70. :body => post_body,
  71. :auth_names => auth_names,
  72. :return_type => return_type
  73. )
  74. 1 data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  75. 1 if @api_client.config.debugging
  76. 1 @api_client.config.logger.debug "API called: MFAApi#generate_messaging_code\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  77. end
  78. 1 return data, status_code, headers
  79. end
  80. # Voice Authentication Code
  81. # Send an MFA Code via a phone call.
  82. # @param account_id [String] Your Bandwidth Account ID.
  83. # @param code_request [CodeRequest] MFA code request body.
  84. # @param [Hash] opts the optional parameters
  85. # @return [VoiceCodeResponse]
  86. 1 def generate_voice_code(account_id, code_request, opts = {})
  87. 2 data, _status_code, _headers = generate_voice_code_with_http_info(account_id, code_request, opts)
  88. data
  89. end
  90. # Voice Authentication Code
  91. # Send an MFA Code via a phone call.
  92. # @param account_id [String] Your Bandwidth Account ID.
  93. # @param code_request [CodeRequest] MFA code request body.
  94. # @param [Hash] opts the optional parameters
  95. # @return [Array<(VoiceCodeResponse, Integer, Hash)>] VoiceCodeResponse data, response status code and response headers
  96. 1 def generate_voice_code_with_http_info(account_id, code_request, opts = {})
  97. 3 if @api_client.config.debugging
  98. 3 @api_client.config.logger.debug 'Calling API: MFAApi.generate_voice_code ...'
  99. end
  100. # verify the required parameter 'account_id' is set
  101. 3 if @api_client.config.client_side_validation && account_id.nil?
  102. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling MFAApi.generate_voice_code"
  103. end
  104. # verify the required parameter 'code_request' is set
  105. 2 if @api_client.config.client_side_validation && code_request.nil?
  106. 1 fail ArgumentError, "Missing the required parameter 'code_request' when calling MFAApi.generate_voice_code"
  107. end
  108. # resource path
  109. 1 local_var_path = '/accounts/{accountId}/code/voice'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
  110. # query parameters
  111. 1 query_params = opts[:query_params] || {}
  112. # header parameters
  113. 1 header_params = opts[:header_params] || {}
  114. # HTTP header 'Accept' (if needed)
  115. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  116. # HTTP header 'Content-Type'
  117. 1 content_type = @api_client.select_header_content_type(['application/json'])
  118. 1 if !content_type.nil?
  119. 1 header_params['Content-Type'] = content_type
  120. end
  121. # form parameters
  122. 1 form_params = opts[:form_params] || {}
  123. # http body (model)
  124. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(code_request)
  125. # return_type
  126. 1 return_type = opts[:debug_return_type] || 'VoiceCodeResponse'
  127. # auth_names
  128. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  129. 1 new_options = opts.merge(
  130. :operation => :"MFAApi.generate_voice_code",
  131. :header_params => header_params,
  132. :query_params => query_params,
  133. :form_params => form_params,
  134. :body => post_body,
  135. :auth_names => auth_names,
  136. :return_type => return_type
  137. )
  138. 1 data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  139. 1 if @api_client.config.debugging
  140. 1 @api_client.config.logger.debug "API called: MFAApi#generate_voice_code\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  141. end
  142. 1 return data, status_code, headers
  143. end
  144. # Verify Authentication Code
  145. # Verify a previously sent MFA code.
  146. # @param account_id [String] Your Bandwidth Account ID.
  147. # @param verify_code_request [VerifyCodeRequest] MFA code verify request body.
  148. # @param [Hash] opts the optional parameters
  149. # @return [VerifyCodeResponse]
  150. 1 def verify_code(account_id, verify_code_request, opts = {})
  151. 2 data, _status_code, _headers = verify_code_with_http_info(account_id, verify_code_request, opts)
  152. data
  153. end
  154. # Verify Authentication Code
  155. # Verify a previously sent MFA code.
  156. # @param account_id [String] Your Bandwidth Account ID.
  157. # @param verify_code_request [VerifyCodeRequest] MFA code verify request body.
  158. # @param [Hash] opts the optional parameters
  159. # @return [Array<(VerifyCodeResponse, Integer, Hash)>] VerifyCodeResponse data, response status code and response headers
  160. 1 def verify_code_with_http_info(account_id, verify_code_request, opts = {})
  161. 3 if @api_client.config.debugging
  162. 3 @api_client.config.logger.debug 'Calling API: MFAApi.verify_code ...'
  163. end
  164. # verify the required parameter 'account_id' is set
  165. 3 if @api_client.config.client_side_validation && account_id.nil?
  166. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling MFAApi.verify_code"
  167. end
  168. # verify the required parameter 'verify_code_request' is set
  169. 2 if @api_client.config.client_side_validation && verify_code_request.nil?
  170. 1 fail ArgumentError, "Missing the required parameter 'verify_code_request' when calling MFAApi.verify_code"
  171. end
  172. # resource path
  173. 1 local_var_path = '/accounts/{accountId}/code/verify'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
  174. # query parameters
  175. 1 query_params = opts[:query_params] || {}
  176. # header parameters
  177. 1 header_params = opts[:header_params] || {}
  178. # HTTP header 'Accept' (if needed)
  179. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  180. # HTTP header 'Content-Type'
  181. 1 content_type = @api_client.select_header_content_type(['application/json'])
  182. 1 if !content_type.nil?
  183. 1 header_params['Content-Type'] = content_type
  184. end
  185. # form parameters
  186. 1 form_params = opts[:form_params] || {}
  187. # http body (model)
  188. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(verify_code_request)
  189. # return_type
  190. 1 return_type = opts[:debug_return_type] || 'VerifyCodeResponse'
  191. # auth_names
  192. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  193. 1 new_options = opts.merge(
  194. :operation => :"MFAApi.verify_code",
  195. :header_params => header_params,
  196. :query_params => query_params,
  197. :form_params => form_params,
  198. :body => post_body,
  199. :auth_names => auth_names,
  200. :return_type => return_type
  201. )
  202. 1 data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  203. 1 if @api_client.config.debugging
  204. 1 @api_client.config.logger.debug "API called: MFAApi#verify_code\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  205. end
  206. 1 return data, status_code, headers
  207. end
  208. end
  209. end

lib/bandwidth-sdk/api/multi_channel_api.rb

96.88% lines covered

32 relevant lines. 31 lines covered and 1 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'cgi'
  10. 1 module Bandwidth
  11. 1 class MultiChannelApi
  12. 1 attr_accessor :api_client
  13. 1 def initialize(api_client = ApiClient.default)
  14. 1 @api_client = api_client
  15. end
  16. # Create Multi-Channel Message
  17. # Endpoint for sending Multi-Channel messages.
  18. # @param account_id [String] Your Bandwidth Account ID.
  19. # @param multi_channel_message_request [MultiChannelMessageRequest]
  20. # @param [Hash] opts the optional parameters
  21. # @return [CreateMultiChannelMessageResponse]
  22. 1 def create_multi_channel_message(account_id, multi_channel_message_request, opts = {})
  23. 2 data, _status_code, _headers = create_multi_channel_message_with_http_info(account_id, multi_channel_message_request, opts)
  24. data
  25. end
  26. # Create Multi-Channel Message
  27. # Endpoint for sending Multi-Channel messages.
  28. # @param account_id [String] Your Bandwidth Account ID.
  29. # @param multi_channel_message_request [MultiChannelMessageRequest]
  30. # @param [Hash] opts the optional parameters
  31. # @return [Array<(CreateMultiChannelMessageResponse, Integer, Hash)>] CreateMultiChannelMessageResponse data, response status code and response headers
  32. 1 def create_multi_channel_message_with_http_info(account_id, multi_channel_message_request, opts = {})
  33. 3 if @api_client.config.debugging
  34. 3 @api_client.config.logger.debug 'Calling API: MultiChannelApi.create_multi_channel_message ...'
  35. end
  36. # verify the required parameter 'account_id' is set
  37. 3 if @api_client.config.client_side_validation && account_id.nil?
  38. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling MultiChannelApi.create_multi_channel_message"
  39. end
  40. # verify the required parameter 'multi_channel_message_request' is set
  41. 2 if @api_client.config.client_side_validation && multi_channel_message_request.nil?
  42. 1 fail ArgumentError, "Missing the required parameter 'multi_channel_message_request' when calling MultiChannelApi.create_multi_channel_message"
  43. end
  44. # resource path
  45. 1 local_var_path = '/users/{accountId}/messages/multiChannel'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
  46. # query parameters
  47. 1 query_params = opts[:query_params] || {}
  48. # header parameters
  49. 1 header_params = opts[:header_params] || {}
  50. # HTTP header 'Accept' (if needed)
  51. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  52. # HTTP header 'Content-Type'
  53. 1 content_type = @api_client.select_header_content_type(['application/json'])
  54. 1 if !content_type.nil?
  55. 1 header_params['Content-Type'] = content_type
  56. end
  57. # form parameters
  58. 1 form_params = opts[:form_params] || {}
  59. # http body (model)
  60. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(multi_channel_message_request)
  61. # return_type
  62. 1 return_type = opts[:debug_return_type] || 'CreateMultiChannelMessageResponse'
  63. # auth_names
  64. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  65. 1 new_options = opts.merge(
  66. :operation => :"MultiChannelApi.create_multi_channel_message",
  67. :header_params => header_params,
  68. :query_params => query_params,
  69. :form_params => form_params,
  70. :body => post_body,
  71. :auth_names => auth_names,
  72. :return_type => return_type
  73. )
  74. 1 data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  75. 1 if @api_client.config.debugging
  76. 1 @api_client.config.logger.debug "API called: MultiChannelApi#create_multi_channel_message\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  77. end
  78. 1 return data, status_code, headers
  79. end
  80. end
  81. end

lib/bandwidth-sdk/api/phone_number_lookup_api.rb

96.3% lines covered

81 relevant lines. 78 lines covered and 3 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'cgi'
  10. 1 module Bandwidth
  11. 1 class PhoneNumberLookupApi
  12. 1 attr_accessor :api_client
  13. 1 def initialize(api_client = ApiClient.default)
  14. 1 @api_client = api_client
  15. end
  16. # Create Asynchronous Bulk Number Lookup
  17. # Creates an asynchronous bulk phone number lookup request. Maximum of 15,000 telephone numbers per request. Use the [Get Asynchronous Bulk Number Lookup](#tag/Phone-Number-Lookup/operation/getAsyncBulkLookup) endpoint to check the status of the request and view the results.
  18. # @param account_id [String]
  19. # @param async_lookup_request [AsyncLookupRequest] Asynchronous bulk phone number lookup request.
  20. # @param [Hash] opts the optional parameters
  21. # @return [CreateAsyncBulkLookupResponse]
  22. 1 def create_async_bulk_lookup(account_id, async_lookup_request, opts = {})
  23. 2 data, _status_code, _headers = create_async_bulk_lookup_with_http_info(account_id, async_lookup_request, opts)
  24. data
  25. end
  26. # Create Asynchronous Bulk Number Lookup
  27. # Creates an asynchronous bulk phone number lookup request. Maximum of 15,000 telephone numbers per request. Use the [Get Asynchronous Bulk Number Lookup](#tag/Phone-Number-Lookup/operation/getAsyncBulkLookup) endpoint to check the status of the request and view the results.
  28. # @param account_id [String]
  29. # @param async_lookup_request [AsyncLookupRequest] Asynchronous bulk phone number lookup request.
  30. # @param [Hash] opts the optional parameters
  31. # @return [Array<(CreateAsyncBulkLookupResponse, Integer, Hash)>] CreateAsyncBulkLookupResponse data, response status code and response headers
  32. 1 def create_async_bulk_lookup_with_http_info(account_id, async_lookup_request, opts = {})
  33. 3 if @api_client.config.debugging
  34. 3 @api_client.config.logger.debug 'Calling API: PhoneNumberLookupApi.create_async_bulk_lookup ...'
  35. end
  36. # verify the required parameter 'account_id' is set
  37. 3 if @api_client.config.client_side_validation && account_id.nil?
  38. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling PhoneNumberLookupApi.create_async_bulk_lookup"
  39. end
  40. # verify the required parameter 'async_lookup_request' is set
  41. 2 if @api_client.config.client_side_validation && async_lookup_request.nil?
  42. 1 fail ArgumentError, "Missing the required parameter 'async_lookup_request' when calling PhoneNumberLookupApi.create_async_bulk_lookup"
  43. end
  44. # resource path
  45. 1 local_var_path = '/accounts/{accountId}/phoneNumberLookup/bulk'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
  46. # query parameters
  47. 1 query_params = opts[:query_params] || {}
  48. # header parameters
  49. 1 header_params = opts[:header_params] || {}
  50. # HTTP header 'Accept' (if needed)
  51. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  52. # HTTP header 'Content-Type'
  53. 1 content_type = @api_client.select_header_content_type(['application/json'])
  54. 1 if !content_type.nil?
  55. 1 header_params['Content-Type'] = content_type
  56. end
  57. # form parameters
  58. 1 form_params = opts[:form_params] || {}
  59. # http body (model)
  60. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(async_lookup_request)
  61. # return_type
  62. 1 return_type = opts[:debug_return_type] || 'CreateAsyncBulkLookupResponse'
  63. # auth_names
  64. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  65. 1 new_options = opts.merge(
  66. :operation => :"PhoneNumberLookupApi.create_async_bulk_lookup",
  67. :header_params => header_params,
  68. :query_params => query_params,
  69. :form_params => form_params,
  70. :body => post_body,
  71. :auth_names => auth_names,
  72. :return_type => return_type
  73. )
  74. 1 data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  75. 1 if @api_client.config.debugging
  76. 1 @api_client.config.logger.debug "API called: PhoneNumberLookupApi#create_async_bulk_lookup\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  77. end
  78. 1 return data, status_code, headers
  79. end
  80. # Create Synchronous Number Lookup
  81. # Creates a synchronous phone number lookup request. Maximum of 100 telephone numbers per request.
  82. # @param account_id [String]
  83. # @param sync_lookup_request [SyncLookupRequest] Synchronous phone number lookup request.
  84. # @param [Hash] opts the optional parameters
  85. # @return [CreateSyncLookupResponse]
  86. 1 def create_sync_lookup(account_id, sync_lookup_request, opts = {})
  87. 2 data, _status_code, _headers = create_sync_lookup_with_http_info(account_id, sync_lookup_request, opts)
  88. data
  89. end
  90. # Create Synchronous Number Lookup
  91. # Creates a synchronous phone number lookup request. Maximum of 100 telephone numbers per request.
  92. # @param account_id [String]
  93. # @param sync_lookup_request [SyncLookupRequest] Synchronous phone number lookup request.
  94. # @param [Hash] opts the optional parameters
  95. # @return [Array<(CreateSyncLookupResponse, Integer, Hash)>] CreateSyncLookupResponse data, response status code and response headers
  96. 1 def create_sync_lookup_with_http_info(account_id, sync_lookup_request, opts = {})
  97. 3 if @api_client.config.debugging
  98. 3 @api_client.config.logger.debug 'Calling API: PhoneNumberLookupApi.create_sync_lookup ...'
  99. end
  100. # verify the required parameter 'account_id' is set
  101. 3 if @api_client.config.client_side_validation && account_id.nil?
  102. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling PhoneNumberLookupApi.create_sync_lookup"
  103. end
  104. # verify the required parameter 'sync_lookup_request' is set
  105. 2 if @api_client.config.client_side_validation && sync_lookup_request.nil?
  106. 1 fail ArgumentError, "Missing the required parameter 'sync_lookup_request' when calling PhoneNumberLookupApi.create_sync_lookup"
  107. end
  108. # resource path
  109. 1 local_var_path = '/accounts/{accountId}/phoneNumberLookup'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
  110. # query parameters
  111. 1 query_params = opts[:query_params] || {}
  112. # header parameters
  113. 1 header_params = opts[:header_params] || {}
  114. # HTTP header 'Accept' (if needed)
  115. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  116. # HTTP header 'Content-Type'
  117. 1 content_type = @api_client.select_header_content_type(['application/json'])
  118. 1 if !content_type.nil?
  119. 1 header_params['Content-Type'] = content_type
  120. end
  121. # form parameters
  122. 1 form_params = opts[:form_params] || {}
  123. # http body (model)
  124. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(sync_lookup_request)
  125. # return_type
  126. 1 return_type = opts[:debug_return_type] || 'CreateSyncLookupResponse'
  127. # auth_names
  128. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  129. 1 new_options = opts.merge(
  130. :operation => :"PhoneNumberLookupApi.create_sync_lookup",
  131. :header_params => header_params,
  132. :query_params => query_params,
  133. :form_params => form_params,
  134. :body => post_body,
  135. :auth_names => auth_names,
  136. :return_type => return_type
  137. )
  138. 1 data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  139. 1 if @api_client.config.debugging
  140. 1 @api_client.config.logger.debug "API called: PhoneNumberLookupApi#create_sync_lookup\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  141. end
  142. 1 return data, status_code, headers
  143. end
  144. # Get Asynchronous Bulk Number Lookup
  145. # Get an existing [Asynchronous Bulk Number Lookup](#tag/Phone-Number-Lookup/operation/createAsyncBulkLookup). Use this endpoint to check the status of the request and view the results.
  146. # @param account_id [String]
  147. # @param request_id [String]
  148. # @param [Hash] opts the optional parameters
  149. # @return [GetAsyncBulkLookupResponse]
  150. 1 def get_async_bulk_lookup(account_id, request_id, opts = {})
  151. 2 data, _status_code, _headers = get_async_bulk_lookup_with_http_info(account_id, request_id, opts)
  152. data
  153. end
  154. # Get Asynchronous Bulk Number Lookup
  155. # Get an existing [Asynchronous Bulk Number Lookup](#tag/Phone-Number-Lookup/operation/createAsyncBulkLookup). Use this endpoint to check the status of the request and view the results.
  156. # @param account_id [String]
  157. # @param request_id [String]
  158. # @param [Hash] opts the optional parameters
  159. # @return [Array<(GetAsyncBulkLookupResponse, Integer, Hash)>] GetAsyncBulkLookupResponse data, response status code and response headers
  160. 1 def get_async_bulk_lookup_with_http_info(account_id, request_id, opts = {})
  161. 3 if @api_client.config.debugging
  162. 3 @api_client.config.logger.debug 'Calling API: PhoneNumberLookupApi.get_async_bulk_lookup ...'
  163. end
  164. # verify the required parameter 'account_id' is set
  165. 3 if @api_client.config.client_side_validation && account_id.nil?
  166. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling PhoneNumberLookupApi.get_async_bulk_lookup"
  167. end
  168. # verify the required parameter 'request_id' is set
  169. 2 if @api_client.config.client_side_validation && request_id.nil?
  170. 1 fail ArgumentError, "Missing the required parameter 'request_id' when calling PhoneNumberLookupApi.get_async_bulk_lookup"
  171. end
  172. # resource path
  173. 1 local_var_path = '/accounts/{accountId}/phoneNumberLookup/bulk/{requestId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'requestId' + '}', CGI.escape(request_id.to_s))
  174. # query parameters
  175. 1 query_params = opts[:query_params] || {}
  176. # header parameters
  177. 1 header_params = opts[:header_params] || {}
  178. # HTTP header 'Accept' (if needed)
  179. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  180. # form parameters
  181. 1 form_params = opts[:form_params] || {}
  182. # http body (model)
  183. 1 post_body = opts[:debug_body]
  184. # return_type
  185. 1 return_type = opts[:debug_return_type] || 'GetAsyncBulkLookupResponse'
  186. # auth_names
  187. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  188. 1 new_options = opts.merge(
  189. :operation => :"PhoneNumberLookupApi.get_async_bulk_lookup",
  190. :header_params => header_params,
  191. :query_params => query_params,
  192. :form_params => form_params,
  193. :body => post_body,
  194. :auth_names => auth_names,
  195. :return_type => return_type
  196. )
  197. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  198. 1 if @api_client.config.debugging
  199. 1 @api_client.config.logger.debug "API called: PhoneNumberLookupApi#get_async_bulk_lookup\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  200. end
  201. 1 return data, status_code, headers
  202. end
  203. end
  204. end

lib/bandwidth-sdk/api/recordings_api.rb

93.0% lines covered

257 relevant lines. 239 lines covered and 18 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'cgi'
  10. 1 module Bandwidth
  11. 1 class RecordingsApi
  12. 1 attr_accessor :api_client
  13. 1 def initialize(api_client = ApiClient.default)
  14. 1 @api_client = api_client
  15. end
  16. # Delete Recording
  17. # Delete the recording information, media and transcription. Note: After the deletion is requested and a `204` is returned, neither the recording metadata nor the actual media nor its transcription will be accessible anymore. However, the media of the specified recording is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours.
  18. # @param account_id [String] Your Bandwidth Account ID.
  19. # @param call_id [String] Programmable Voice API Call ID.
  20. # @param recording_id [String] Programmable Voice API Recording ID.
  21. # @param [Hash] opts the optional parameters
  22. # @return [nil]
  23. 1 def delete_recording(account_id, call_id, recording_id, opts = {})
  24. 3 delete_recording_with_http_info(account_id, call_id, recording_id, opts)
  25. nil
  26. end
  27. # Delete Recording
  28. # Delete the recording information, media and transcription. Note: After the deletion is requested and a &#x60;204&#x60; is returned, neither the recording metadata nor the actual media nor its transcription will be accessible anymore. However, the media of the specified recording is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours.
  29. # @param account_id [String] Your Bandwidth Account ID.
  30. # @param call_id [String] Programmable Voice API Call ID.
  31. # @param recording_id [String] Programmable Voice API Recording ID.
  32. # @param [Hash] opts the optional parameters
  33. # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
  34. 1 def delete_recording_with_http_info(account_id, call_id, recording_id, opts = {})
  35. 4 if @api_client.config.debugging
  36. 4 @api_client.config.logger.debug 'Calling API: RecordingsApi.delete_recording ...'
  37. end
  38. # verify the required parameter 'account_id' is set
  39. 4 if @api_client.config.client_side_validation && account_id.nil?
  40. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.delete_recording"
  41. end
  42. # verify the required parameter 'call_id' is set
  43. 3 if @api_client.config.client_side_validation && call_id.nil?
  44. 1 fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.delete_recording"
  45. end
  46. # verify the required parameter 'recording_id' is set
  47. 2 if @api_client.config.client_side_validation && recording_id.nil?
  48. 1 fail ArgumentError, "Missing the required parameter 'recording_id' when calling RecordingsApi.delete_recording"
  49. end
  50. # resource path
  51. 1 local_var_path = '/accounts/{accountId}/calls/{callId}/recordings/{recordingId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s))
  52. # query parameters
  53. 1 query_params = opts[:query_params] || {}
  54. # header parameters
  55. 1 header_params = opts[:header_params] || {}
  56. # HTTP header 'Accept' (if needed)
  57. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  58. # form parameters
  59. 1 form_params = opts[:form_params] || {}
  60. # http body (model)
  61. 1 post_body = opts[:debug_body]
  62. # return_type
  63. 1 return_type = opts[:debug_return_type]
  64. # auth_names
  65. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  66. 1 new_options = opts.merge(
  67. :operation => :"RecordingsApi.delete_recording",
  68. :header_params => header_params,
  69. :query_params => query_params,
  70. :form_params => form_params,
  71. :body => post_body,
  72. :auth_names => auth_names,
  73. :return_type => return_type
  74. )
  75. 1 data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  76. 1 if @api_client.config.debugging
  77. 1 @api_client.config.logger.debug "API called: RecordingsApi#delete_recording\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  78. end
  79. 1 return data, status_code, headers
  80. end
  81. # Delete Recording Media
  82. # Deletes the specified recording's media.
  83. # @param account_id [String] Your Bandwidth Account ID.
  84. # @param call_id [String] Programmable Voice API Call ID.
  85. # @param recording_id [String] Programmable Voice API Recording ID.
  86. # @param [Hash] opts the optional parameters
  87. # @return [nil]
  88. 1 def delete_recording_media(account_id, call_id, recording_id, opts = {})
  89. 3 delete_recording_media_with_http_info(account_id, call_id, recording_id, opts)
  90. nil
  91. end
  92. # Delete Recording Media
  93. # Deletes the specified recording&#39;s media.
  94. # @param account_id [String] Your Bandwidth Account ID.
  95. # @param call_id [String] Programmable Voice API Call ID.
  96. # @param recording_id [String] Programmable Voice API Recording ID.
  97. # @param [Hash] opts the optional parameters
  98. # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
  99. 1 def delete_recording_media_with_http_info(account_id, call_id, recording_id, opts = {})
  100. 4 if @api_client.config.debugging
  101. 4 @api_client.config.logger.debug 'Calling API: RecordingsApi.delete_recording_media ...'
  102. end
  103. # verify the required parameter 'account_id' is set
  104. 4 if @api_client.config.client_side_validation && account_id.nil?
  105. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.delete_recording_media"
  106. end
  107. # verify the required parameter 'call_id' is set
  108. 3 if @api_client.config.client_side_validation && call_id.nil?
  109. 1 fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.delete_recording_media"
  110. end
  111. # verify the required parameter 'recording_id' is set
  112. 2 if @api_client.config.client_side_validation && recording_id.nil?
  113. 1 fail ArgumentError, "Missing the required parameter 'recording_id' when calling RecordingsApi.delete_recording_media"
  114. end
  115. # resource path
  116. 1 local_var_path = '/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s))
  117. # query parameters
  118. 1 query_params = opts[:query_params] || {}
  119. # header parameters
  120. 1 header_params = opts[:header_params] || {}
  121. # HTTP header 'Accept' (if needed)
  122. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  123. # form parameters
  124. 1 form_params = opts[:form_params] || {}
  125. # http body (model)
  126. 1 post_body = opts[:debug_body]
  127. # return_type
  128. 1 return_type = opts[:debug_return_type]
  129. # auth_names
  130. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  131. 1 new_options = opts.merge(
  132. :operation => :"RecordingsApi.delete_recording_media",
  133. :header_params => header_params,
  134. :query_params => query_params,
  135. :form_params => form_params,
  136. :body => post_body,
  137. :auth_names => auth_names,
  138. :return_type => return_type
  139. )
  140. 1 data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  141. 1 if @api_client.config.debugging
  142. 1 @api_client.config.logger.debug "API called: RecordingsApi#delete_recording_media\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  143. end
  144. 1 return data, status_code, headers
  145. end
  146. # Delete Transcription
  147. # Deletes the specified recording's transcription. Note: After the deletion is requested and a `204` is returned, the transcription will not be accessible anymore. However, it is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours.
  148. # @param account_id [String] Your Bandwidth Account ID.
  149. # @param call_id [String] Programmable Voice API Call ID.
  150. # @param recording_id [String] Programmable Voice API Recording ID.
  151. # @param [Hash] opts the optional parameters
  152. # @return [nil]
  153. 1 def delete_recording_transcription(account_id, call_id, recording_id, opts = {})
  154. 3 delete_recording_transcription_with_http_info(account_id, call_id, recording_id, opts)
  155. nil
  156. end
  157. # Delete Transcription
  158. # Deletes the specified recording&#39;s transcription. Note: After the deletion is requested and a &#x60;204&#x60; is returned, the transcription will not be accessible anymore. However, it is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours.
  159. # @param account_id [String] Your Bandwidth Account ID.
  160. # @param call_id [String] Programmable Voice API Call ID.
  161. # @param recording_id [String] Programmable Voice API Recording ID.
  162. # @param [Hash] opts the optional parameters
  163. # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
  164. 1 def delete_recording_transcription_with_http_info(account_id, call_id, recording_id, opts = {})
  165. 4 if @api_client.config.debugging
  166. 4 @api_client.config.logger.debug 'Calling API: RecordingsApi.delete_recording_transcription ...'
  167. end
  168. # verify the required parameter 'account_id' is set
  169. 4 if @api_client.config.client_side_validation && account_id.nil?
  170. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.delete_recording_transcription"
  171. end
  172. # verify the required parameter 'call_id' is set
  173. 3 if @api_client.config.client_side_validation && call_id.nil?
  174. 1 fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.delete_recording_transcription"
  175. end
  176. # verify the required parameter 'recording_id' is set
  177. 2 if @api_client.config.client_side_validation && recording_id.nil?
  178. 1 fail ArgumentError, "Missing the required parameter 'recording_id' when calling RecordingsApi.delete_recording_transcription"
  179. end
  180. # resource path
  181. 1 local_var_path = '/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s))
  182. # query parameters
  183. 1 query_params = opts[:query_params] || {}
  184. # header parameters
  185. 1 header_params = opts[:header_params] || {}
  186. # HTTP header 'Accept' (if needed)
  187. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  188. # form parameters
  189. 1 form_params = opts[:form_params] || {}
  190. # http body (model)
  191. 1 post_body = opts[:debug_body]
  192. # return_type
  193. 1 return_type = opts[:debug_return_type]
  194. # auth_names
  195. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  196. 1 new_options = opts.merge(
  197. :operation => :"RecordingsApi.delete_recording_transcription",
  198. :header_params => header_params,
  199. :query_params => query_params,
  200. :form_params => form_params,
  201. :body => post_body,
  202. :auth_names => auth_names,
  203. :return_type => return_type
  204. )
  205. 1 data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  206. 1 if @api_client.config.debugging
  207. 1 @api_client.config.logger.debug "API called: RecordingsApi#delete_recording_transcription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  208. end
  209. 1 return data, status_code, headers
  210. end
  211. # Download Recording
  212. # Downloads the specified recording.
  213. # @param account_id [String] Your Bandwidth Account ID.
  214. # @param call_id [String] Programmable Voice API Call ID.
  215. # @param recording_id [String] Programmable Voice API Recording ID.
  216. # @param [Hash] opts the optional parameters
  217. # @return [File]
  218. 1 def download_call_recording(account_id, call_id, recording_id, opts = {})
  219. 3 data, _status_code, _headers = download_call_recording_with_http_info(account_id, call_id, recording_id, opts)
  220. data
  221. end
  222. # Download Recording
  223. # Downloads the specified recording.
  224. # @param account_id [String] Your Bandwidth Account ID.
  225. # @param call_id [String] Programmable Voice API Call ID.
  226. # @param recording_id [String] Programmable Voice API Recording ID.
  227. # @param [Hash] opts the optional parameters
  228. # @return [Array<(File, Integer, Hash)>] File data, response status code and response headers
  229. 1 def download_call_recording_with_http_info(account_id, call_id, recording_id, opts = {})
  230. 4 if @api_client.config.debugging
  231. 4 @api_client.config.logger.debug 'Calling API: RecordingsApi.download_call_recording ...'
  232. end
  233. # verify the required parameter 'account_id' is set
  234. 4 if @api_client.config.client_side_validation && account_id.nil?
  235. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.download_call_recording"
  236. end
  237. # verify the required parameter 'call_id' is set
  238. 3 if @api_client.config.client_side_validation && call_id.nil?
  239. 1 fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.download_call_recording"
  240. end
  241. # verify the required parameter 'recording_id' is set
  242. 2 if @api_client.config.client_side_validation && recording_id.nil?
  243. 1 fail ArgumentError, "Missing the required parameter 'recording_id' when calling RecordingsApi.download_call_recording"
  244. end
  245. # resource path
  246. 1 local_var_path = '/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s))
  247. # query parameters
  248. 1 query_params = opts[:query_params] || {}
  249. # header parameters
  250. 1 header_params = opts[:header_params] || {}
  251. # HTTP header 'Accept' (if needed)
  252. 1 header_params['Accept'] = @api_client.select_header_accept(['audio/vnd.wave', 'audio/mpeg', 'application/json']) unless header_params['Accept']
  253. # form parameters
  254. 1 form_params = opts[:form_params] || {}
  255. # http body (model)
  256. 1 post_body = opts[:debug_body]
  257. # return_type
  258. 1 return_type = opts[:debug_return_type] || 'File'
  259. # auth_names
  260. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  261. 1 new_options = opts.merge(
  262. :operation => :"RecordingsApi.download_call_recording",
  263. :header_params => header_params,
  264. :query_params => query_params,
  265. :form_params => form_params,
  266. :body => post_body,
  267. :auth_names => auth_names,
  268. :return_type => return_type
  269. )
  270. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  271. 1 if @api_client.config.debugging
  272. 1 @api_client.config.logger.debug "API called: RecordingsApi#download_call_recording\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  273. end
  274. 1 return data, status_code, headers
  275. end
  276. # Get Call Recording
  277. # Returns metadata for the specified recording.
  278. # @param account_id [String] Your Bandwidth Account ID.
  279. # @param call_id [String] Programmable Voice API Call ID.
  280. # @param recording_id [String] Programmable Voice API Recording ID.
  281. # @param [Hash] opts the optional parameters
  282. # @return [CallRecordingMetadata]
  283. 1 def get_call_recording(account_id, call_id, recording_id, opts = {})
  284. 3 data, _status_code, _headers = get_call_recording_with_http_info(account_id, call_id, recording_id, opts)
  285. data
  286. end
  287. # Get Call Recording
  288. # Returns metadata for the specified recording.
  289. # @param account_id [String] Your Bandwidth Account ID.
  290. # @param call_id [String] Programmable Voice API Call ID.
  291. # @param recording_id [String] Programmable Voice API Recording ID.
  292. # @param [Hash] opts the optional parameters
  293. # @return [Array<(CallRecordingMetadata, Integer, Hash)>] CallRecordingMetadata data, response status code and response headers
  294. 1 def get_call_recording_with_http_info(account_id, call_id, recording_id, opts = {})
  295. 3 if @api_client.config.debugging
  296. 3 @api_client.config.logger.debug 'Calling API: RecordingsApi.get_call_recording ...'
  297. end
  298. # verify the required parameter 'account_id' is set
  299. 3 if @api_client.config.client_side_validation && account_id.nil?
  300. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.get_call_recording"
  301. end
  302. # verify the required parameter 'call_id' is set
  303. 2 if @api_client.config.client_side_validation && call_id.nil?
  304. 1 fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.get_call_recording"
  305. end
  306. # verify the required parameter 'recording_id' is set
  307. 1 if @api_client.config.client_side_validation && recording_id.nil?
  308. 1 fail ArgumentError, "Missing the required parameter 'recording_id' when calling RecordingsApi.get_call_recording"
  309. end
  310. # resource path
  311. local_var_path = '/accounts/{accountId}/calls/{callId}/recordings/{recordingId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s))
  312. # query parameters
  313. query_params = opts[:query_params] || {}
  314. # header parameters
  315. header_params = opts[:header_params] || {}
  316. # HTTP header 'Accept' (if needed)
  317. header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  318. # form parameters
  319. form_params = opts[:form_params] || {}
  320. # http body (model)
  321. post_body = opts[:debug_body]
  322. # return_type
  323. return_type = opts[:debug_return_type] || 'CallRecordingMetadata'
  324. # auth_names
  325. auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  326. new_options = opts.merge(
  327. :operation => :"RecordingsApi.get_call_recording",
  328. :header_params => header_params,
  329. :query_params => query_params,
  330. :form_params => form_params,
  331. :body => post_body,
  332. :auth_names => auth_names,
  333. :return_type => return_type
  334. )
  335. data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  336. if @api_client.config.debugging
  337. @api_client.config.logger.debug "API called: RecordingsApi#get_call_recording\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  338. end
  339. return data, status_code, headers
  340. end
  341. # Get Transcription
  342. # Downloads the specified transcription. If the recording was multi-channel, then there will be 2 transcripts. The caller/called party transcript will be the first item while [`<PlayAudio>`](/docs/voice/bxml/playAudio) and [`<SpeakSentence>`](/docs/voice/bxml/speakSentence) transcript will be the second item. During a [`<Transfer>`](/docs/voice/bxml/transfer) the A-leg transcript will be the first item while the B-leg transcript will be the second item.
  343. # @param account_id [String] Your Bandwidth Account ID.
  344. # @param call_id [String] Programmable Voice API Call ID.
  345. # @param recording_id [String] Programmable Voice API Recording ID.
  346. # @param [Hash] opts the optional parameters
  347. # @return [RecordingTranscriptions]
  348. 1 def get_recording_transcription(account_id, call_id, recording_id, opts = {})
  349. 3 data, _status_code, _headers = get_recording_transcription_with_http_info(account_id, call_id, recording_id, opts)
  350. data
  351. end
  352. # Get Transcription
  353. # Downloads the specified transcription. If the recording was multi-channel, then there will be 2 transcripts. The caller/called party transcript will be the first item while [&#x60;&lt;PlayAudio&gt;&#x60;](/docs/voice/bxml/playAudio) and [&#x60;&lt;SpeakSentence&gt;&#x60;](/docs/voice/bxml/speakSentence) transcript will be the second item. During a [&#x60;&lt;Transfer&gt;&#x60;](/docs/voice/bxml/transfer) the A-leg transcript will be the first item while the B-leg transcript will be the second item.
  354. # @param account_id [String] Your Bandwidth Account ID.
  355. # @param call_id [String] Programmable Voice API Call ID.
  356. # @param recording_id [String] Programmable Voice API Recording ID.
  357. # @param [Hash] opts the optional parameters
  358. # @return [Array<(RecordingTranscriptions, Integer, Hash)>] RecordingTranscriptions data, response status code and response headers
  359. 1 def get_recording_transcription_with_http_info(account_id, call_id, recording_id, opts = {})
  360. 4 if @api_client.config.debugging
  361. 4 @api_client.config.logger.debug 'Calling API: RecordingsApi.get_recording_transcription ...'
  362. end
  363. # verify the required parameter 'account_id' is set
  364. 4 if @api_client.config.client_side_validation && account_id.nil?
  365. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.get_recording_transcription"
  366. end
  367. # verify the required parameter 'call_id' is set
  368. 3 if @api_client.config.client_side_validation && call_id.nil?
  369. 1 fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.get_recording_transcription"
  370. end
  371. # verify the required parameter 'recording_id' is set
  372. 2 if @api_client.config.client_side_validation && recording_id.nil?
  373. 1 fail ArgumentError, "Missing the required parameter 'recording_id' when calling RecordingsApi.get_recording_transcription"
  374. end
  375. # resource path
  376. 1 local_var_path = '/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s))
  377. # query parameters
  378. 1 query_params = opts[:query_params] || {}
  379. # header parameters
  380. 1 header_params = opts[:header_params] || {}
  381. # HTTP header 'Accept' (if needed)
  382. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  383. # form parameters
  384. 1 form_params = opts[:form_params] || {}
  385. # http body (model)
  386. 1 post_body = opts[:debug_body]
  387. # return_type
  388. 1 return_type = opts[:debug_return_type] || 'RecordingTranscriptions'
  389. # auth_names
  390. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  391. 1 new_options = opts.merge(
  392. :operation => :"RecordingsApi.get_recording_transcription",
  393. :header_params => header_params,
  394. :query_params => query_params,
  395. :form_params => form_params,
  396. :body => post_body,
  397. :auth_names => auth_names,
  398. :return_type => return_type
  399. )
  400. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  401. 1 if @api_client.config.debugging
  402. 1 @api_client.config.logger.debug "API called: RecordingsApi#get_recording_transcription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  403. end
  404. 1 return data, status_code, headers
  405. end
  406. # Get Call Recordings
  407. # Returns a list of metadata for the recordings associated with the specified account. The list can be filtered by the optional from, to, minStartTime, and maxStartTime arguments. The list is capped at 1000 entries and may be empty if no recordings match the specified criteria.
  408. # @param account_id [String] Your Bandwidth Account ID.
  409. # @param [Hash] opts the optional parameters
  410. # @option opts [String] :to Filter results by the &#x60;to&#x60; field.
  411. # @option opts [String] :from Filter results by the &#x60;from&#x60; field.
  412. # @option opts [String] :min_start_time Filter results to recordings which have a &#x60;startTime&#x60; after or including &#x60;minStartTime&#x60; (in ISO8601 format).
  413. # @option opts [String] :max_start_time Filter results to recordings which have a &#x60;startTime&#x60; before &#x60;maxStartTime&#x60; (in ISO8601 format).
  414. # @return [Array<CallRecordingMetadata>]
  415. 1 def list_account_call_recordings(account_id, opts = {})
  416. 1 data, _status_code, _headers = list_account_call_recordings_with_http_info(account_id, opts)
  417. data
  418. end
  419. # Get Call Recordings
  420. # Returns a list of metadata for the recordings associated with the specified account. The list can be filtered by the optional from, to, minStartTime, and maxStartTime arguments. The list is capped at 1000 entries and may be empty if no recordings match the specified criteria.
  421. # @param account_id [String] Your Bandwidth Account ID.
  422. # @param [Hash] opts the optional parameters
  423. # @option opts [String] :to Filter results by the &#x60;to&#x60; field.
  424. # @option opts [String] :from Filter results by the &#x60;from&#x60; field.
  425. # @option opts [String] :min_start_time Filter results to recordings which have a &#x60;startTime&#x60; after or including &#x60;minStartTime&#x60; (in ISO8601 format).
  426. # @option opts [String] :max_start_time Filter results to recordings which have a &#x60;startTime&#x60; before &#x60;maxStartTime&#x60; (in ISO8601 format).
  427. # @return [Array<(Array<CallRecordingMetadata>, Integer, Hash)>] Array<CallRecordingMetadata> data, response status code and response headers
  428. 1 def list_account_call_recordings_with_http_info(account_id, opts = {})
  429. 2 if @api_client.config.debugging
  430. 2 @api_client.config.logger.debug 'Calling API: RecordingsApi.list_account_call_recordings ...'
  431. end
  432. # verify the required parameter 'account_id' is set
  433. 2 if @api_client.config.client_side_validation && account_id.nil?
  434. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.list_account_call_recordings"
  435. end
  436. # resource path
  437. 1 local_var_path = '/accounts/{accountId}/recordings'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
  438. # query parameters
  439. 1 query_params = opts[:query_params] || {}
  440. 1 query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil?
  441. 1 query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?
  442. 1 query_params[:'minStartTime'] = opts[:'min_start_time'] if !opts[:'min_start_time'].nil?
  443. 1 query_params[:'maxStartTime'] = opts[:'max_start_time'] if !opts[:'max_start_time'].nil?
  444. # header parameters
  445. 1 header_params = opts[:header_params] || {}
  446. # HTTP header 'Accept' (if needed)
  447. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  448. # form parameters
  449. 1 form_params = opts[:form_params] || {}
  450. # http body (model)
  451. 1 post_body = opts[:debug_body]
  452. # return_type
  453. 1 return_type = opts[:debug_return_type] || 'Array<CallRecordingMetadata>'
  454. # auth_names
  455. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  456. 1 new_options = opts.merge(
  457. :operation => :"RecordingsApi.list_account_call_recordings",
  458. :header_params => header_params,
  459. :query_params => query_params,
  460. :form_params => form_params,
  461. :body => post_body,
  462. :auth_names => auth_names,
  463. :return_type => return_type
  464. )
  465. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  466. 1 if @api_client.config.debugging
  467. 1 @api_client.config.logger.debug "API called: RecordingsApi#list_account_call_recordings\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  468. end
  469. 1 return data, status_code, headers
  470. end
  471. # List Call Recordings
  472. # Returns a (potentially empty) list of metadata for the recordings that took place during the specified call.
  473. # @param account_id [String] Your Bandwidth Account ID.
  474. # @param call_id [String] Programmable Voice API Call ID.
  475. # @param [Hash] opts the optional parameters
  476. # @return [Array<CallRecordingMetadata>]
  477. 1 def list_call_recordings(account_id, call_id, opts = {})
  478. 2 data, _status_code, _headers = list_call_recordings_with_http_info(account_id, call_id, opts)
  479. data
  480. end
  481. # List Call Recordings
  482. # Returns a (potentially empty) list of metadata for the recordings that took place during the specified call.
  483. # @param account_id [String] Your Bandwidth Account ID.
  484. # @param call_id [String] Programmable Voice API Call ID.
  485. # @param [Hash] opts the optional parameters
  486. # @return [Array<(Array<CallRecordingMetadata>, Integer, Hash)>] Array<CallRecordingMetadata> data, response status code and response headers
  487. 1 def list_call_recordings_with_http_info(account_id, call_id, opts = {})
  488. 3 if @api_client.config.debugging
  489. 3 @api_client.config.logger.debug 'Calling API: RecordingsApi.list_call_recordings ...'
  490. end
  491. # verify the required parameter 'account_id' is set
  492. 3 if @api_client.config.client_side_validation && account_id.nil?
  493. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.list_call_recordings"
  494. end
  495. # verify the required parameter 'call_id' is set
  496. 2 if @api_client.config.client_side_validation && call_id.nil?
  497. 1 fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.list_call_recordings"
  498. end
  499. # resource path
  500. 1 local_var_path = '/accounts/{accountId}/calls/{callId}/recordings'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s))
  501. # query parameters
  502. 1 query_params = opts[:query_params] || {}
  503. # header parameters
  504. 1 header_params = opts[:header_params] || {}
  505. # HTTP header 'Accept' (if needed)
  506. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  507. # form parameters
  508. 1 form_params = opts[:form_params] || {}
  509. # http body (model)
  510. 1 post_body = opts[:debug_body]
  511. # return_type
  512. 1 return_type = opts[:debug_return_type] || 'Array<CallRecordingMetadata>'
  513. # auth_names
  514. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  515. 1 new_options = opts.merge(
  516. :operation => :"RecordingsApi.list_call_recordings",
  517. :header_params => header_params,
  518. :query_params => query_params,
  519. :form_params => form_params,
  520. :body => post_body,
  521. :auth_names => auth_names,
  522. :return_type => return_type
  523. )
  524. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  525. 1 if @api_client.config.debugging
  526. 1 @api_client.config.logger.debug "API called: RecordingsApi#list_call_recordings\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  527. end
  528. 1 return data, status_code, headers
  529. end
  530. # Create Transcription Request
  531. # Generate the transcription for a specific recording. Transcription can succeed only for recordings of length greater than 500 milliseconds and less than 4 hours.
  532. # @param account_id [String] Your Bandwidth Account ID.
  533. # @param call_id [String] Programmable Voice API Call ID.
  534. # @param recording_id [String] Programmable Voice API Recording ID.
  535. # @param transcribe_recording [TranscribeRecording]
  536. # @param [Hash] opts the optional parameters
  537. # @return [nil]
  538. 1 def transcribe_call_recording(account_id, call_id, recording_id, transcribe_recording, opts = {})
  539. 4 transcribe_call_recording_with_http_info(account_id, call_id, recording_id, transcribe_recording, opts)
  540. nil
  541. end
  542. # Create Transcription Request
  543. # Generate the transcription for a specific recording. Transcription can succeed only for recordings of length greater than 500 milliseconds and less than 4 hours.
  544. # @param account_id [String] Your Bandwidth Account ID.
  545. # @param call_id [String] Programmable Voice API Call ID.
  546. # @param recording_id [String] Programmable Voice API Recording ID.
  547. # @param transcribe_recording [TranscribeRecording]
  548. # @param [Hash] opts the optional parameters
  549. # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
  550. 1 def transcribe_call_recording_with_http_info(account_id, call_id, recording_id, transcribe_recording, opts = {})
  551. 5 if @api_client.config.debugging
  552. 5 @api_client.config.logger.debug 'Calling API: RecordingsApi.transcribe_call_recording ...'
  553. end
  554. # verify the required parameter 'account_id' is set
  555. 5 if @api_client.config.client_side_validation && account_id.nil?
  556. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.transcribe_call_recording"
  557. end
  558. # verify the required parameter 'call_id' is set
  559. 4 if @api_client.config.client_side_validation && call_id.nil?
  560. 1 fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.transcribe_call_recording"
  561. end
  562. # verify the required parameter 'recording_id' is set
  563. 3 if @api_client.config.client_side_validation && recording_id.nil?
  564. 1 fail ArgumentError, "Missing the required parameter 'recording_id' when calling RecordingsApi.transcribe_call_recording"
  565. end
  566. # verify the required parameter 'transcribe_recording' is set
  567. 2 if @api_client.config.client_side_validation && transcribe_recording.nil?
  568. 1 fail ArgumentError, "Missing the required parameter 'transcribe_recording' when calling RecordingsApi.transcribe_call_recording"
  569. end
  570. # resource path
  571. 1 local_var_path = '/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s))
  572. # query parameters
  573. 1 query_params = opts[:query_params] || {}
  574. # header parameters
  575. 1 header_params = opts[:header_params] || {}
  576. # HTTP header 'Accept' (if needed)
  577. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  578. # HTTP header 'Content-Type'
  579. 1 content_type = @api_client.select_header_content_type(['application/json'])
  580. 1 if !content_type.nil?
  581. 1 header_params['Content-Type'] = content_type
  582. end
  583. # form parameters
  584. 1 form_params = opts[:form_params] || {}
  585. # http body (model)
  586. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(transcribe_recording)
  587. # return_type
  588. 1 return_type = opts[:debug_return_type]
  589. # auth_names
  590. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  591. 1 new_options = opts.merge(
  592. :operation => :"RecordingsApi.transcribe_call_recording",
  593. :header_params => header_params,
  594. :query_params => query_params,
  595. :form_params => form_params,
  596. :body => post_body,
  597. :auth_names => auth_names,
  598. :return_type => return_type
  599. )
  600. 1 data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  601. 1 if @api_client.config.debugging
  602. 1 @api_client.config.logger.debug "API called: RecordingsApi#transcribe_call_recording\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  603. end
  604. 1 return data, status_code, headers
  605. end
  606. # Update Recording
  607. # Pause or resume a recording on an active phone call.
  608. # @param account_id [String] Your Bandwidth Account ID.
  609. # @param call_id [String] Programmable Voice API Call ID.
  610. # @param update_call_recording [UpdateCallRecording]
  611. # @param [Hash] opts the optional parameters
  612. # @return [nil]
  613. 1 def update_call_recording_state(account_id, call_id, update_call_recording, opts = {})
  614. 3 update_call_recording_state_with_http_info(account_id, call_id, update_call_recording, opts)
  615. nil
  616. end
  617. # Update Recording
  618. # Pause or resume a recording on an active phone call.
  619. # @param account_id [String] Your Bandwidth Account ID.
  620. # @param call_id [String] Programmable Voice API Call ID.
  621. # @param update_call_recording [UpdateCallRecording]
  622. # @param [Hash] opts the optional parameters
  623. # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
  624. 1 def update_call_recording_state_with_http_info(account_id, call_id, update_call_recording, opts = {})
  625. 4 if @api_client.config.debugging
  626. 4 @api_client.config.logger.debug 'Calling API: RecordingsApi.update_call_recording_state ...'
  627. end
  628. # verify the required parameter 'account_id' is set
  629. 4 if @api_client.config.client_side_validation && account_id.nil?
  630. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.update_call_recording_state"
  631. end
  632. # verify the required parameter 'call_id' is set
  633. 3 if @api_client.config.client_side_validation && call_id.nil?
  634. 1 fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.update_call_recording_state"
  635. end
  636. # verify the required parameter 'update_call_recording' is set
  637. 2 if @api_client.config.client_side_validation && update_call_recording.nil?
  638. 1 fail ArgumentError, "Missing the required parameter 'update_call_recording' when calling RecordingsApi.update_call_recording_state"
  639. end
  640. # resource path
  641. 1 local_var_path = '/accounts/{accountId}/calls/{callId}/recording'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s))
  642. # query parameters
  643. 1 query_params = opts[:query_params] || {}
  644. # header parameters
  645. 1 header_params = opts[:header_params] || {}
  646. # HTTP header 'Accept' (if needed)
  647. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  648. # HTTP header 'Content-Type'
  649. 1 content_type = @api_client.select_header_content_type(['application/json'])
  650. 1 if !content_type.nil?
  651. 1 header_params['Content-Type'] = content_type
  652. end
  653. # form parameters
  654. 1 form_params = opts[:form_params] || {}
  655. # http body (model)
  656. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(update_call_recording)
  657. # return_type
  658. 1 return_type = opts[:debug_return_type]
  659. # auth_names
  660. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  661. 1 new_options = opts.merge(
  662. :operation => :"RecordingsApi.update_call_recording_state",
  663. :header_params => header_params,
  664. :query_params => query_params,
  665. :form_params => form_params,
  666. :body => post_body,
  667. :auth_names => auth_names,
  668. :return_type => return_type
  669. )
  670. 1 data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  671. 1 if @api_client.config.debugging
  672. 1 @api_client.config.logger.debug "API called: RecordingsApi#update_call_recording_state\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  673. end
  674. 1 return data, status_code, headers
  675. end
  676. end
  677. end

lib/bandwidth-sdk/api/statistics_api.rb

96.3% lines covered

27 relevant lines. 26 lines covered and 1 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'cgi'
  10. 1 module Bandwidth
  11. 1 class StatisticsApi
  12. 1 attr_accessor :api_client
  13. 1 def initialize(api_client = ApiClient.default)
  14. 1 @api_client = api_client
  15. end
  16. # Get Account Statistics
  17. # Returns details about the current state of the account.
  18. # @param account_id [String] Your Bandwidth Account ID.
  19. # @param [Hash] opts the optional parameters
  20. # @return [AccountStatistics]
  21. 1 def get_statistics(account_id, opts = {})
  22. 1 data, _status_code, _headers = get_statistics_with_http_info(account_id, opts)
  23. data
  24. end
  25. # Get Account Statistics
  26. # Returns details about the current state of the account.
  27. # @param account_id [String] Your Bandwidth Account ID.
  28. # @param [Hash] opts the optional parameters
  29. # @return [Array<(AccountStatistics, Integer, Hash)>] AccountStatistics data, response status code and response headers
  30. 1 def get_statistics_with_http_info(account_id, opts = {})
  31. 2 if @api_client.config.debugging
  32. 2 @api_client.config.logger.debug 'Calling API: StatisticsApi.get_statistics ...'
  33. end
  34. # verify the required parameter 'account_id' is set
  35. 2 if @api_client.config.client_side_validation && account_id.nil?
  36. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling StatisticsApi.get_statistics"
  37. end
  38. # resource path
  39. 1 local_var_path = '/accounts/{accountId}/statistics'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
  40. # query parameters
  41. 1 query_params = opts[:query_params] || {}
  42. # header parameters
  43. 1 header_params = opts[:header_params] || {}
  44. # HTTP header 'Accept' (if needed)
  45. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  46. # form parameters
  47. 1 form_params = opts[:form_params] || {}
  48. # http body (model)
  49. 1 post_body = opts[:debug_body]
  50. # return_type
  51. 1 return_type = opts[:debug_return_type] || 'AccountStatistics'
  52. # auth_names
  53. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  54. 1 new_options = opts.merge(
  55. :operation => :"StatisticsApi.get_statistics",
  56. :header_params => header_params,
  57. :query_params => query_params,
  58. :form_params => form_params,
  59. :body => post_body,
  60. :auth_names => auth_names,
  61. :return_type => return_type
  62. )
  63. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  64. 1 if @api_client.config.debugging
  65. 1 @api_client.config.logger.debug "API called: StatisticsApi#get_statistics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  66. end
  67. 1 return data, status_code, headers
  68. end
  69. end
  70. end

lib/bandwidth-sdk/api/toll_free_verification_api.rb

93.75% lines covered

240 relevant lines. 225 lines covered and 15 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'cgi'
  10. 1 module Bandwidth
  11. 1 class TollFreeVerificationApi
  12. 1 attr_accessor :api_client
  13. 1 def initialize(api_client = ApiClient.default)
  14. 1 @api_client = api_client
  15. end
  16. # Create Webhook Subscription
  17. # Create a new webhook subscription (this webhook will be called for every update on every submission). In addition to a `callbackUrl`, this subscription can provide optional HTTP basic authentication credentials (a username and a password). The returned subscription object will contain an ID that can be used to modify or delete the subscription at a later time.
  18. # @param account_id [String] Your Bandwidth Account ID.
  19. # @param webhook_subscription_request_schema [WebhookSubscriptionRequestSchema] Information about a webhook that Bandwidth should send upon the completion of event customer is trying to subscribe to.
  20. # @param [Hash] opts the optional parameters
  21. # @return [WebhookSubscription]
  22. 1 def create_webhook_subscription(account_id, webhook_subscription_request_schema, opts = {})
  23. 2 data, _status_code, _headers = create_webhook_subscription_with_http_info(account_id, webhook_subscription_request_schema, opts)
  24. data
  25. end
  26. # Create Webhook Subscription
  27. # Create a new webhook subscription (this webhook will be called for every update on every submission). In addition to a &#x60;callbackUrl&#x60;, this subscription can provide optional HTTP basic authentication credentials (a username and a password). The returned subscription object will contain an ID that can be used to modify or delete the subscription at a later time.
  28. # @param account_id [String] Your Bandwidth Account ID.
  29. # @param webhook_subscription_request_schema [WebhookSubscriptionRequestSchema] Information about a webhook that Bandwidth should send upon the completion of event customer is trying to subscribe to.
  30. # @param [Hash] opts the optional parameters
  31. # @return [Array<(WebhookSubscription, Integer, Hash)>] WebhookSubscription data, response status code and response headers
  32. 1 def create_webhook_subscription_with_http_info(account_id, webhook_subscription_request_schema, opts = {})
  33. 3 if @api_client.config.debugging
  34. 3 @api_client.config.logger.debug 'Calling API: TollFreeVerificationApi.create_webhook_subscription ...'
  35. end
  36. # verify the required parameter 'account_id' is set
  37. 3 if @api_client.config.client_side_validation && account_id.nil?
  38. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling TollFreeVerificationApi.create_webhook_subscription"
  39. end
  40. # verify the required parameter 'webhook_subscription_request_schema' is set
  41. 2 if @api_client.config.client_side_validation && webhook_subscription_request_schema.nil?
  42. 1 fail ArgumentError, "Missing the required parameter 'webhook_subscription_request_schema' when calling TollFreeVerificationApi.create_webhook_subscription"
  43. end
  44. # resource path
  45. 1 local_var_path = '/accounts/{accountId}/tollFreeVerification/webhooks/subscriptions'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
  46. # query parameters
  47. 1 query_params = opts[:query_params] || {}
  48. # header parameters
  49. 1 header_params = opts[:header_params] || {}
  50. # HTTP header 'Accept' (if needed)
  51. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  52. # HTTP header 'Content-Type'
  53. 1 content_type = @api_client.select_header_content_type(['application/json'])
  54. 1 if !content_type.nil?
  55. 1 header_params['Content-Type'] = content_type
  56. end
  57. # form parameters
  58. 1 form_params = opts[:form_params] || {}
  59. # http body (model)
  60. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(webhook_subscription_request_schema)
  61. # return_type
  62. 1 return_type = opts[:debug_return_type] || 'WebhookSubscription'
  63. # auth_names
  64. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  65. 1 new_options = opts.merge(
  66. :operation => :"TollFreeVerificationApi.create_webhook_subscription",
  67. :header_params => header_params,
  68. :query_params => query_params,
  69. :form_params => form_params,
  70. :body => post_body,
  71. :auth_names => auth_names,
  72. :return_type => return_type
  73. )
  74. 1 data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  75. 1 if @api_client.config.debugging
  76. 1 @api_client.config.logger.debug "API called: TollFreeVerificationApi#create_webhook_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  77. end
  78. 1 return data, status_code, headers
  79. end
  80. # Delete a Toll-Free Verification Submission
  81. # Delete a toll-free verification submission for a toll-free number.
  82. # @param account_id [String] Your Bandwidth Account ID.
  83. # @param phone_number [String] Valid Toll-Free telephone number in E.164 format.
  84. # @param [Hash] opts the optional parameters
  85. # @return [nil]
  86. 1 def delete_verification_request(account_id, phone_number, opts = {})
  87. 2 delete_verification_request_with_http_info(account_id, phone_number, opts)
  88. nil
  89. end
  90. # Delete a Toll-Free Verification Submission
  91. # Delete a toll-free verification submission for a toll-free number.
  92. # @param account_id [String] Your Bandwidth Account ID.
  93. # @param phone_number [String] Valid Toll-Free telephone number in E.164 format.
  94. # @param [Hash] opts the optional parameters
  95. # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
  96. 1 def delete_verification_request_with_http_info(account_id, phone_number, opts = {})
  97. 3 if @api_client.config.debugging
  98. 3 @api_client.config.logger.debug 'Calling API: TollFreeVerificationApi.delete_verification_request ...'
  99. end
  100. # verify the required parameter 'account_id' is set
  101. 3 if @api_client.config.client_side_validation && account_id.nil?
  102. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling TollFreeVerificationApi.delete_verification_request"
  103. end
  104. # verify the required parameter 'phone_number' is set
  105. 2 if @api_client.config.client_side_validation && phone_number.nil?
  106. 1 fail ArgumentError, "Missing the required parameter 'phone_number' when calling TollFreeVerificationApi.delete_verification_request"
  107. end
  108. 1 if @api_client.config.client_side_validation && phone_number.to_s.length > 12
  109. fail ArgumentError, 'invalid value for "phone_number" when calling TollFreeVerificationApi.delete_verification_request, the character length must be smaller than or equal to 12.'
  110. end
  111. 1 if @api_client.config.client_side_validation && phone_number.to_s.length < 12
  112. fail ArgumentError, 'invalid value for "phone_number" when calling TollFreeVerificationApi.delete_verification_request, the character length must be greater than or equal to 12.'
  113. end
  114. 1 pattern = Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
  115. 1 if @api_client.config.client_side_validation && phone_number !~ pattern
  116. fail ArgumentError, "invalid value for 'phone_number' when calling TollFreeVerificationApi.delete_verification_request, must conform to the pattern #{pattern}."
  117. end
  118. # resource path
  119. 1 local_var_path = '/accounts/{accountId}/phoneNumbers/{phoneNumber}/tollFreeVerification'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'phoneNumber' + '}', CGI.escape(phone_number.to_s))
  120. # query parameters
  121. 1 query_params = opts[:query_params] || {}
  122. # header parameters
  123. 1 header_params = opts[:header_params] || {}
  124. # HTTP header 'Accept' (if needed)
  125. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  126. # form parameters
  127. 1 form_params = opts[:form_params] || {}
  128. # http body (model)
  129. 1 post_body = opts[:debug_body]
  130. # return_type
  131. 1 return_type = opts[:debug_return_type]
  132. # auth_names
  133. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  134. 1 new_options = opts.merge(
  135. :operation => :"TollFreeVerificationApi.delete_verification_request",
  136. :header_params => header_params,
  137. :query_params => query_params,
  138. :form_params => form_params,
  139. :body => post_body,
  140. :auth_names => auth_names,
  141. :return_type => return_type
  142. )
  143. 1 data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  144. 1 if @api_client.config.debugging
  145. 1 @api_client.config.logger.debug "API called: TollFreeVerificationApi#delete_verification_request\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  146. end
  147. 1 return data, status_code, headers
  148. end
  149. # Delete Webhook Subscription
  150. # Delete a webhook subscription by ID.
  151. # @param account_id [String] Your Bandwidth Account ID.
  152. # @param id [String] Webhook subscription ID
  153. # @param [Hash] opts the optional parameters
  154. # @return [nil]
  155. 1 def delete_webhook_subscription(account_id, id, opts = {})
  156. 2 delete_webhook_subscription_with_http_info(account_id, id, opts)
  157. nil
  158. end
  159. # Delete Webhook Subscription
  160. # Delete a webhook subscription by ID.
  161. # @param account_id [String] Your Bandwidth Account ID.
  162. # @param id [String] Webhook subscription ID
  163. # @param [Hash] opts the optional parameters
  164. # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
  165. 1 def delete_webhook_subscription_with_http_info(account_id, id, opts = {})
  166. 3 if @api_client.config.debugging
  167. 3 @api_client.config.logger.debug 'Calling API: TollFreeVerificationApi.delete_webhook_subscription ...'
  168. end
  169. # verify the required parameter 'account_id' is set
  170. 3 if @api_client.config.client_side_validation && account_id.nil?
  171. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling TollFreeVerificationApi.delete_webhook_subscription"
  172. end
  173. # verify the required parameter 'id' is set
  174. 2 if @api_client.config.client_side_validation && id.nil?
  175. 1 fail ArgumentError, "Missing the required parameter 'id' when calling TollFreeVerificationApi.delete_webhook_subscription"
  176. end
  177. # resource path
  178. 1 local_var_path = '/accounts/{accountId}/tollFreeVerification/webhooks/subscriptions/{id}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'id' + '}', CGI.escape(id.to_s))
  179. # query parameters
  180. 1 query_params = opts[:query_params] || {}
  181. # header parameters
  182. 1 header_params = opts[:header_params] || {}
  183. # HTTP header 'Accept' (if needed)
  184. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  185. # form parameters
  186. 1 form_params = opts[:form_params] || {}
  187. # http body (model)
  188. 1 post_body = opts[:debug_body]
  189. # return_type
  190. 1 return_type = opts[:debug_return_type]
  191. # auth_names
  192. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  193. 1 new_options = opts.merge(
  194. :operation => :"TollFreeVerificationApi.delete_webhook_subscription",
  195. :header_params => header_params,
  196. :query_params => query_params,
  197. :form_params => form_params,
  198. :body => post_body,
  199. :auth_names => auth_names,
  200. :return_type => return_type
  201. )
  202. 1 data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  203. 1 if @api_client.config.debugging
  204. 1 @api_client.config.logger.debug "API called: TollFreeVerificationApi#delete_webhook_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  205. end
  206. 1 return data, status_code, headers
  207. end
  208. # Get Toll-Free Verification Status
  209. # Gets the verification status for a phone number that is provisioned to your account. Submission information will be appended to the response if it is available.
  210. # @param account_id [String] Your Bandwidth Account ID.
  211. # @param phone_number [String] Valid Toll-Free telephone number in E.164 format.
  212. # @param [Hash] opts the optional parameters
  213. # @return [TfvStatus]
  214. 1 def get_toll_free_verification_status(account_id, phone_number, opts = {})
  215. 2 data, _status_code, _headers = get_toll_free_verification_status_with_http_info(account_id, phone_number, opts)
  216. data
  217. end
  218. # Get Toll-Free Verification Status
  219. # Gets the verification status for a phone number that is provisioned to your account. Submission information will be appended to the response if it is available.
  220. # @param account_id [String] Your Bandwidth Account ID.
  221. # @param phone_number [String] Valid Toll-Free telephone number in E.164 format.
  222. # @param [Hash] opts the optional parameters
  223. # @return [Array<(TfvStatus, Integer, Hash)>] TfvStatus data, response status code and response headers
  224. 1 def get_toll_free_verification_status_with_http_info(account_id, phone_number, opts = {})
  225. 3 if @api_client.config.debugging
  226. 3 @api_client.config.logger.debug 'Calling API: TollFreeVerificationApi.get_toll_free_verification_status ...'
  227. end
  228. # verify the required parameter 'account_id' is set
  229. 3 if @api_client.config.client_side_validation && account_id.nil?
  230. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling TollFreeVerificationApi.get_toll_free_verification_status"
  231. end
  232. # verify the required parameter 'phone_number' is set
  233. 2 if @api_client.config.client_side_validation && phone_number.nil?
  234. 1 fail ArgumentError, "Missing the required parameter 'phone_number' when calling TollFreeVerificationApi.get_toll_free_verification_status"
  235. end
  236. 1 if @api_client.config.client_side_validation && phone_number.to_s.length > 12
  237. fail ArgumentError, 'invalid value for "phone_number" when calling TollFreeVerificationApi.get_toll_free_verification_status, the character length must be smaller than or equal to 12.'
  238. end
  239. 1 if @api_client.config.client_side_validation && phone_number.to_s.length < 12
  240. fail ArgumentError, 'invalid value for "phone_number" when calling TollFreeVerificationApi.get_toll_free_verification_status, the character length must be greater than or equal to 12.'
  241. end
  242. 1 pattern = Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
  243. 1 if @api_client.config.client_side_validation && phone_number !~ pattern
  244. fail ArgumentError, "invalid value for 'phone_number' when calling TollFreeVerificationApi.get_toll_free_verification_status, must conform to the pattern #{pattern}."
  245. end
  246. # resource path
  247. 1 local_var_path = '/accounts/{accountId}/phoneNumbers/{phoneNumber}/tollFreeVerification'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'phoneNumber' + '}', CGI.escape(phone_number.to_s))
  248. # query parameters
  249. 1 query_params = opts[:query_params] || {}
  250. # header parameters
  251. 1 header_params = opts[:header_params] || {}
  252. # HTTP header 'Accept' (if needed)
  253. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  254. # form parameters
  255. 1 form_params = opts[:form_params] || {}
  256. # http body (model)
  257. 1 post_body = opts[:debug_body]
  258. # return_type
  259. 1 return_type = opts[:debug_return_type] || 'TfvStatus'
  260. # auth_names
  261. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  262. 1 new_options = opts.merge(
  263. :operation => :"TollFreeVerificationApi.get_toll_free_verification_status",
  264. :header_params => header_params,
  265. :query_params => query_params,
  266. :form_params => form_params,
  267. :body => post_body,
  268. :auth_names => auth_names,
  269. :return_type => return_type
  270. )
  271. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  272. 1 if @api_client.config.debugging
  273. 1 @api_client.config.logger.debug "API called: TollFreeVerificationApi#get_toll_free_verification_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  274. end
  275. 1 return data, status_code, headers
  276. end
  277. # List Toll-Free Use Cases
  278. # Lists valid toll-free use cases.
  279. # @param [Hash] opts the optional parameters
  280. # @return [Array<String>]
  281. 1 def list_toll_free_use_cases(opts = {})
  282. data, _status_code, _headers = list_toll_free_use_cases_with_http_info(opts)
  283. data
  284. end
  285. # List Toll-Free Use Cases
  286. # Lists valid toll-free use cases.
  287. # @param [Hash] opts the optional parameters
  288. # @return [Array<(Array<String>, Integer, Hash)>] Array<String> data, response status code and response headers
  289. 1 def list_toll_free_use_cases_with_http_info(opts = {})
  290. 1 if @api_client.config.debugging
  291. 1 @api_client.config.logger.debug 'Calling API: TollFreeVerificationApi.list_toll_free_use_cases ...'
  292. end
  293. # resource path
  294. 1 local_var_path = '/tollFreeVerification/useCases'
  295. # query parameters
  296. 1 query_params = opts[:query_params] || {}
  297. # header parameters
  298. 1 header_params = opts[:header_params] || {}
  299. # HTTP header 'Accept' (if needed)
  300. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  301. # form parameters
  302. 1 form_params = opts[:form_params] || {}
  303. # http body (model)
  304. 1 post_body = opts[:debug_body]
  305. # return_type
  306. 1 return_type = opts[:debug_return_type] || 'Array<String>'
  307. # auth_names
  308. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  309. 1 new_options = opts.merge(
  310. :operation => :"TollFreeVerificationApi.list_toll_free_use_cases",
  311. :header_params => header_params,
  312. :query_params => query_params,
  313. :form_params => form_params,
  314. :body => post_body,
  315. :auth_names => auth_names,
  316. :return_type => return_type
  317. )
  318. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  319. 1 if @api_client.config.debugging
  320. 1 @api_client.config.logger.debug "API called: TollFreeVerificationApi#list_toll_free_use_cases\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  321. end
  322. 1 return data, status_code, headers
  323. end
  324. # List Webhook Subscriptions
  325. # Lists all webhook subscriptions that are registered to receive status updates for the toll-free verification requests submitted under this account (password will not be returned through this API If `basicAuthentication` is defined, the `password` property of that object will be null).
  326. # @param account_id [String] Your Bandwidth Account ID.
  327. # @param [Hash] opts the optional parameters
  328. # @return [WebhookSubscriptionsListBody]
  329. 1 def list_webhook_subscriptions(account_id, opts = {})
  330. 1 data, _status_code, _headers = list_webhook_subscriptions_with_http_info(account_id, opts)
  331. data
  332. end
  333. # List Webhook Subscriptions
  334. # Lists all webhook subscriptions that are registered to receive status updates for the toll-free verification requests submitted under this account (password will not be returned through this API If &#x60;basicAuthentication&#x60; is defined, the &#x60;password&#x60; property of that object will be null).
  335. # @param account_id [String] Your Bandwidth Account ID.
  336. # @param [Hash] opts the optional parameters
  337. # @return [Array<(WebhookSubscriptionsListBody, Integer, Hash)>] WebhookSubscriptionsListBody data, response status code and response headers
  338. 1 def list_webhook_subscriptions_with_http_info(account_id, opts = {})
  339. 2 if @api_client.config.debugging
  340. 2 @api_client.config.logger.debug 'Calling API: TollFreeVerificationApi.list_webhook_subscriptions ...'
  341. end
  342. # verify the required parameter 'account_id' is set
  343. 2 if @api_client.config.client_side_validation && account_id.nil?
  344. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling TollFreeVerificationApi.list_webhook_subscriptions"
  345. end
  346. # resource path
  347. 1 local_var_path = '/accounts/{accountId}/tollFreeVerification/webhooks/subscriptions'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
  348. # query parameters
  349. 1 query_params = opts[:query_params] || {}
  350. # header parameters
  351. 1 header_params = opts[:header_params] || {}
  352. # HTTP header 'Accept' (if needed)
  353. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  354. # form parameters
  355. 1 form_params = opts[:form_params] || {}
  356. # http body (model)
  357. 1 post_body = opts[:debug_body]
  358. # return_type
  359. 1 return_type = opts[:debug_return_type] || 'WebhookSubscriptionsListBody'
  360. # auth_names
  361. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  362. 1 new_options = opts.merge(
  363. :operation => :"TollFreeVerificationApi.list_webhook_subscriptions",
  364. :header_params => header_params,
  365. :query_params => query_params,
  366. :form_params => form_params,
  367. :body => post_body,
  368. :auth_names => auth_names,
  369. :return_type => return_type
  370. )
  371. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  372. 1 if @api_client.config.debugging
  373. 1 @api_client.config.logger.debug "API called: TollFreeVerificationApi#list_webhook_subscriptions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  374. end
  375. 1 return data, status_code, headers
  376. end
  377. # Request Toll-Free Verification
  378. # Submit a request for verification of a toll-free phone number.
  379. # @param account_id [String] Your Bandwidth Account ID.
  380. # @param verification_request [VerificationRequest] Request for verification of a toll-free phone number.
  381. # @param [Hash] opts the optional parameters
  382. # @return [nil]
  383. 1 def request_toll_free_verification(account_id, verification_request, opts = {})
  384. 2 request_toll_free_verification_with_http_info(account_id, verification_request, opts)
  385. nil
  386. end
  387. # Request Toll-Free Verification
  388. # Submit a request for verification of a toll-free phone number.
  389. # @param account_id [String] Your Bandwidth Account ID.
  390. # @param verification_request [VerificationRequest] Request for verification of a toll-free phone number.
  391. # @param [Hash] opts the optional parameters
  392. # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
  393. 1 def request_toll_free_verification_with_http_info(account_id, verification_request, opts = {})
  394. 3 if @api_client.config.debugging
  395. 3 @api_client.config.logger.debug 'Calling API: TollFreeVerificationApi.request_toll_free_verification ...'
  396. end
  397. # verify the required parameter 'account_id' is set
  398. 3 if @api_client.config.client_side_validation && account_id.nil?
  399. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling TollFreeVerificationApi.request_toll_free_verification"
  400. end
  401. # verify the required parameter 'verification_request' is set
  402. 2 if @api_client.config.client_side_validation && verification_request.nil?
  403. 1 fail ArgumentError, "Missing the required parameter 'verification_request' when calling TollFreeVerificationApi.request_toll_free_verification"
  404. end
  405. # resource path
  406. 1 local_var_path = '/accounts/{accountId}/tollFreeVerification'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
  407. # query parameters
  408. 1 query_params = opts[:query_params] || {}
  409. # header parameters
  410. 1 header_params = opts[:header_params] || {}
  411. # HTTP header 'Accept' (if needed)
  412. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  413. # HTTP header 'Content-Type'
  414. 1 content_type = @api_client.select_header_content_type(['application/json'])
  415. 1 if !content_type.nil?
  416. 1 header_params['Content-Type'] = content_type
  417. end
  418. # form parameters
  419. 1 form_params = opts[:form_params] || {}
  420. # http body (model)
  421. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(verification_request)
  422. # return_type
  423. 1 return_type = opts[:debug_return_type]
  424. # auth_names
  425. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  426. 1 new_options = opts.merge(
  427. :operation => :"TollFreeVerificationApi.request_toll_free_verification",
  428. :header_params => header_params,
  429. :query_params => query_params,
  430. :form_params => form_params,
  431. :body => post_body,
  432. :auth_names => auth_names,
  433. :return_type => return_type
  434. )
  435. 1 data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  436. 1 if @api_client.config.debugging
  437. 1 @api_client.config.logger.debug "API called: TollFreeVerificationApi#request_toll_free_verification\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  438. end
  439. 1 return data, status_code, headers
  440. end
  441. # Update Toll-Free Verification Request
  442. # Updates a toll-free verification request. Submissions are only eligible for resubmission for 7 days within being processed and if resubmission is allowed (resubmitAllowed field is true).
  443. # @param account_id [String] Your Bandwidth Account ID.
  444. # @param phone_number [String] Valid Toll-Free telephone number in E.164 format.
  445. # @param tfv_submission_wrapper [TfvSubmissionWrapper] Update a request for verification of a toll-free phone number.
  446. # @param [Hash] opts the optional parameters
  447. # @return [nil]
  448. 1 def update_toll_free_verification_request(account_id, phone_number, tfv_submission_wrapper, opts = {})
  449. 3 update_toll_free_verification_request_with_http_info(account_id, phone_number, tfv_submission_wrapper, opts)
  450. nil
  451. end
  452. # Update Toll-Free Verification Request
  453. # Updates a toll-free verification request. Submissions are only eligible for resubmission for 7 days within being processed and if resubmission is allowed (resubmitAllowed field is true).
  454. # @param account_id [String] Your Bandwidth Account ID.
  455. # @param phone_number [String] Valid Toll-Free telephone number in E.164 format.
  456. # @param tfv_submission_wrapper [TfvSubmissionWrapper] Update a request for verification of a toll-free phone number.
  457. # @param [Hash] opts the optional parameters
  458. # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
  459. 1 def update_toll_free_verification_request_with_http_info(account_id, phone_number, tfv_submission_wrapper, opts = {})
  460. 4 if @api_client.config.debugging
  461. 4 @api_client.config.logger.debug 'Calling API: TollFreeVerificationApi.update_toll_free_verification_request ...'
  462. end
  463. # verify the required parameter 'account_id' is set
  464. 4 if @api_client.config.client_side_validation && account_id.nil?
  465. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling TollFreeVerificationApi.update_toll_free_verification_request"
  466. end
  467. # verify the required parameter 'phone_number' is set
  468. 3 if @api_client.config.client_side_validation && phone_number.nil?
  469. 1 fail ArgumentError, "Missing the required parameter 'phone_number' when calling TollFreeVerificationApi.update_toll_free_verification_request"
  470. end
  471. 2 if @api_client.config.client_side_validation && phone_number.to_s.length > 12
  472. fail ArgumentError, 'invalid value for "phone_number" when calling TollFreeVerificationApi.update_toll_free_verification_request, the character length must be smaller than or equal to 12.'
  473. end
  474. 2 if @api_client.config.client_side_validation && phone_number.to_s.length < 12
  475. fail ArgumentError, 'invalid value for "phone_number" when calling TollFreeVerificationApi.update_toll_free_verification_request, the character length must be greater than or equal to 12.'
  476. end
  477. 2 pattern = Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
  478. 2 if @api_client.config.client_side_validation && phone_number !~ pattern
  479. fail ArgumentError, "invalid value for 'phone_number' when calling TollFreeVerificationApi.update_toll_free_verification_request, must conform to the pattern #{pattern}."
  480. end
  481. # verify the required parameter 'tfv_submission_wrapper' is set
  482. 2 if @api_client.config.client_side_validation && tfv_submission_wrapper.nil?
  483. 1 fail ArgumentError, "Missing the required parameter 'tfv_submission_wrapper' when calling TollFreeVerificationApi.update_toll_free_verification_request"
  484. end
  485. # resource path
  486. 1 local_var_path = '/accounts/{accountId}/phoneNumbers/{phoneNumber}/tollFreeVerification'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'phoneNumber' + '}', CGI.escape(phone_number.to_s))
  487. # query parameters
  488. 1 query_params = opts[:query_params] || {}
  489. # header parameters
  490. 1 header_params = opts[:header_params] || {}
  491. # HTTP header 'Accept' (if needed)
  492. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  493. # HTTP header 'Content-Type'
  494. 1 content_type = @api_client.select_header_content_type(['application/json'])
  495. 1 if !content_type.nil?
  496. 1 header_params['Content-Type'] = content_type
  497. end
  498. # form parameters
  499. 1 form_params = opts[:form_params] || {}
  500. # http body (model)
  501. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(tfv_submission_wrapper)
  502. # return_type
  503. 1 return_type = opts[:debug_return_type]
  504. # auth_names
  505. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  506. 1 new_options = opts.merge(
  507. :operation => :"TollFreeVerificationApi.update_toll_free_verification_request",
  508. :header_params => header_params,
  509. :query_params => query_params,
  510. :form_params => form_params,
  511. :body => post_body,
  512. :auth_names => auth_names,
  513. :return_type => return_type
  514. )
  515. 1 data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  516. 1 if @api_client.config.debugging
  517. 1 @api_client.config.logger.debug "API called: TollFreeVerificationApi#update_toll_free_verification_request\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  518. end
  519. 1 return data, status_code, headers
  520. end
  521. # Update Webhook Subscription
  522. # Update an existing webhook subscription (`callbackUrl` and `basicAuthentication` can be updated).
  523. # @param account_id [String] Your Bandwidth Account ID.
  524. # @param id [String] Webhook subscription ID
  525. # @param webhook_subscription_request_schema [WebhookSubscriptionRequestSchema] Information about a webhook that Bandwidth should send upon the completion of event customer is trying to subscribe to.
  526. # @param [Hash] opts the optional parameters
  527. # @return [WebhookSubscription]
  528. 1 def update_webhook_subscription(account_id, id, webhook_subscription_request_schema, opts = {})
  529. 3 data, _status_code, _headers = update_webhook_subscription_with_http_info(account_id, id, webhook_subscription_request_schema, opts)
  530. data
  531. end
  532. # Update Webhook Subscription
  533. # Update an existing webhook subscription (&#x60;callbackUrl&#x60; and &#x60;basicAuthentication&#x60; can be updated).
  534. # @param account_id [String] Your Bandwidth Account ID.
  535. # @param id [String] Webhook subscription ID
  536. # @param webhook_subscription_request_schema [WebhookSubscriptionRequestSchema] Information about a webhook that Bandwidth should send upon the completion of event customer is trying to subscribe to.
  537. # @param [Hash] opts the optional parameters
  538. # @return [Array<(WebhookSubscription, Integer, Hash)>] WebhookSubscription data, response status code and response headers
  539. 1 def update_webhook_subscription_with_http_info(account_id, id, webhook_subscription_request_schema, opts = {})
  540. 4 if @api_client.config.debugging
  541. 4 @api_client.config.logger.debug 'Calling API: TollFreeVerificationApi.update_webhook_subscription ...'
  542. end
  543. # verify the required parameter 'account_id' is set
  544. 4 if @api_client.config.client_side_validation && account_id.nil?
  545. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling TollFreeVerificationApi.update_webhook_subscription"
  546. end
  547. # verify the required parameter 'id' is set
  548. 3 if @api_client.config.client_side_validation && id.nil?
  549. 1 fail ArgumentError, "Missing the required parameter 'id' when calling TollFreeVerificationApi.update_webhook_subscription"
  550. end
  551. # verify the required parameter 'webhook_subscription_request_schema' is set
  552. 2 if @api_client.config.client_side_validation && webhook_subscription_request_schema.nil?
  553. 1 fail ArgumentError, "Missing the required parameter 'webhook_subscription_request_schema' when calling TollFreeVerificationApi.update_webhook_subscription"
  554. end
  555. # resource path
  556. 1 local_var_path = '/accounts/{accountId}/tollFreeVerification/webhooks/subscriptions/{id}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'id' + '}', CGI.escape(id.to_s))
  557. # query parameters
  558. 1 query_params = opts[:query_params] || {}
  559. # header parameters
  560. 1 header_params = opts[:header_params] || {}
  561. # HTTP header 'Accept' (if needed)
  562. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  563. # HTTP header 'Content-Type'
  564. 1 content_type = @api_client.select_header_content_type(['application/json'])
  565. 1 if !content_type.nil?
  566. 1 header_params['Content-Type'] = content_type
  567. end
  568. # form parameters
  569. 1 form_params = opts[:form_params] || {}
  570. # http body (model)
  571. 1 post_body = opts[:debug_body] || @api_client.object_to_http_body(webhook_subscription_request_schema)
  572. # return_type
  573. 1 return_type = opts[:debug_return_type] || 'WebhookSubscription'
  574. # auth_names
  575. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  576. 1 new_options = opts.merge(
  577. :operation => :"TollFreeVerificationApi.update_webhook_subscription",
  578. :header_params => header_params,
  579. :query_params => query_params,
  580. :form_params => form_params,
  581. :body => post_body,
  582. :auth_names => auth_names,
  583. :return_type => return_type
  584. )
  585. 1 data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  586. 1 if @api_client.config.debugging
  587. 1 @api_client.config.logger.debug "API called: TollFreeVerificationApi#update_webhook_subscription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  588. end
  589. 1 return data, status_code, headers
  590. end
  591. end
  592. end

lib/bandwidth-sdk/api/transcriptions_api.rb

97.44% lines covered

78 relevant lines. 76 lines covered and 2 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'cgi'
  10. 1 module Bandwidth
  11. 1 class TranscriptionsApi
  12. 1 attr_accessor :api_client
  13. 1 def initialize(api_client = ApiClient.default)
  14. 1 @api_client = api_client
  15. end
  16. # Delete Real-time Transcription
  17. # Delete the specified transcription that was created on this call via [startTranscription](/docs/voice/bxml/startTranscription). Note: After the deletion is requested and a `200` is returned, the transcription will not be accessible anymore. However, it is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours.
  18. # @param account_id [String] Your Bandwidth Account ID.
  19. # @param call_id [String] Programmable Voice API Call ID.
  20. # @param transcription_id [String] Programmable Voice API Transcription ID.
  21. # @param [Hash] opts the optional parameters
  22. # @return [nil]
  23. 1 def delete_real_time_transcription(account_id, call_id, transcription_id, opts = {})
  24. 3 delete_real_time_transcription_with_http_info(account_id, call_id, transcription_id, opts)
  25. nil
  26. end
  27. # Delete Real-time Transcription
  28. # Delete the specified transcription that was created on this call via [startTranscription](/docs/voice/bxml/startTranscription). Note: After the deletion is requested and a &#x60;200&#x60; is returned, the transcription will not be accessible anymore. However, it is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours.
  29. # @param account_id [String] Your Bandwidth Account ID.
  30. # @param call_id [String] Programmable Voice API Call ID.
  31. # @param transcription_id [String] Programmable Voice API Transcription ID.
  32. # @param [Hash] opts the optional parameters
  33. # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
  34. 1 def delete_real_time_transcription_with_http_info(account_id, call_id, transcription_id, opts = {})
  35. 4 if @api_client.config.debugging
  36. 4 @api_client.config.logger.debug 'Calling API: TranscriptionsApi.delete_real_time_transcription ...'
  37. end
  38. # verify the required parameter 'account_id' is set
  39. 4 if @api_client.config.client_side_validation && account_id.nil?
  40. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling TranscriptionsApi.delete_real_time_transcription"
  41. end
  42. # verify the required parameter 'call_id' is set
  43. 3 if @api_client.config.client_side_validation && call_id.nil?
  44. 1 fail ArgumentError, "Missing the required parameter 'call_id' when calling TranscriptionsApi.delete_real_time_transcription"
  45. end
  46. # verify the required parameter 'transcription_id' is set
  47. 2 if @api_client.config.client_side_validation && transcription_id.nil?
  48. 1 fail ArgumentError, "Missing the required parameter 'transcription_id' when calling TranscriptionsApi.delete_real_time_transcription"
  49. end
  50. # resource path
  51. 1 local_var_path = '/accounts/{accountId}/calls/{callId}/transcriptions/{transcriptionId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'transcriptionId' + '}', CGI.escape(transcription_id.to_s))
  52. # query parameters
  53. 1 query_params = opts[:query_params] || {}
  54. # header parameters
  55. 1 header_params = opts[:header_params] || {}
  56. # HTTP header 'Accept' (if needed)
  57. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  58. # form parameters
  59. 1 form_params = opts[:form_params] || {}
  60. # http body (model)
  61. 1 post_body = opts[:debug_body]
  62. # return_type
  63. 1 return_type = opts[:debug_return_type]
  64. # auth_names
  65. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  66. 1 new_options = opts.merge(
  67. :operation => :"TranscriptionsApi.delete_real_time_transcription",
  68. :header_params => header_params,
  69. :query_params => query_params,
  70. :form_params => form_params,
  71. :body => post_body,
  72. :auth_names => auth_names,
  73. :return_type => return_type
  74. )
  75. 1 data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  76. 1 if @api_client.config.debugging
  77. 1 @api_client.config.logger.debug "API called: TranscriptionsApi#delete_real_time_transcription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  78. end
  79. 1 return data, status_code, headers
  80. end
  81. # Get Real-time Transcription
  82. # Retrieve the specified transcription that was created on this call via [startTranscription](/docs/voice/bxml/startTranscription).
  83. # @param account_id [String] Your Bandwidth Account ID.
  84. # @param call_id [String] Programmable Voice API Call ID.
  85. # @param transcription_id [String] Programmable Voice API Transcription ID.
  86. # @param [Hash] opts the optional parameters
  87. # @return [CallTranscriptionResponse]
  88. 1 def get_real_time_transcription(account_id, call_id, transcription_id, opts = {})
  89. 3 data, _status_code, _headers = get_real_time_transcription_with_http_info(account_id, call_id, transcription_id, opts)
  90. data
  91. end
  92. # Get Real-time Transcription
  93. # Retrieve the specified transcription that was created on this call via [startTranscription](/docs/voice/bxml/startTranscription).
  94. # @param account_id [String] Your Bandwidth Account ID.
  95. # @param call_id [String] Programmable Voice API Call ID.
  96. # @param transcription_id [String] Programmable Voice API Transcription ID.
  97. # @param [Hash] opts the optional parameters
  98. # @return [Array<(CallTranscriptionResponse, Integer, Hash)>] CallTranscriptionResponse data, response status code and response headers
  99. 1 def get_real_time_transcription_with_http_info(account_id, call_id, transcription_id, opts = {})
  100. 4 if @api_client.config.debugging
  101. 4 @api_client.config.logger.debug 'Calling API: TranscriptionsApi.get_real_time_transcription ...'
  102. end
  103. # verify the required parameter 'account_id' is set
  104. 4 if @api_client.config.client_side_validation && account_id.nil?
  105. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling TranscriptionsApi.get_real_time_transcription"
  106. end
  107. # verify the required parameter 'call_id' is set
  108. 3 if @api_client.config.client_side_validation && call_id.nil?
  109. 1 fail ArgumentError, "Missing the required parameter 'call_id' when calling TranscriptionsApi.get_real_time_transcription"
  110. end
  111. # verify the required parameter 'transcription_id' is set
  112. 2 if @api_client.config.client_side_validation && transcription_id.nil?
  113. 1 fail ArgumentError, "Missing the required parameter 'transcription_id' when calling TranscriptionsApi.get_real_time_transcription"
  114. end
  115. # resource path
  116. 1 local_var_path = '/accounts/{accountId}/calls/{callId}/transcriptions/{transcriptionId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'transcriptionId' + '}', CGI.escape(transcription_id.to_s))
  117. # query parameters
  118. 1 query_params = opts[:query_params] || {}
  119. # header parameters
  120. 1 header_params = opts[:header_params] || {}
  121. # HTTP header 'Accept' (if needed)
  122. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  123. # form parameters
  124. 1 form_params = opts[:form_params] || {}
  125. # http body (model)
  126. 1 post_body = opts[:debug_body]
  127. # return_type
  128. 1 return_type = opts[:debug_return_type] || 'CallTranscriptionResponse'
  129. # auth_names
  130. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  131. 1 new_options = opts.merge(
  132. :operation => :"TranscriptionsApi.get_real_time_transcription",
  133. :header_params => header_params,
  134. :query_params => query_params,
  135. :form_params => form_params,
  136. :body => post_body,
  137. :auth_names => auth_names,
  138. :return_type => return_type
  139. )
  140. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  141. 1 if @api_client.config.debugging
  142. 1 @api_client.config.logger.debug "API called: TranscriptionsApi#get_real_time_transcription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  143. end
  144. 1 return data, status_code, headers
  145. end
  146. # List Real-time Transcriptions
  147. # List the transcriptions created on this call via [startTranscription](/docs/voice/bxml/startTranscription).
  148. # @param account_id [String] Your Bandwidth Account ID.
  149. # @param call_id [String] Programmable Voice API Call ID.
  150. # @param [Hash] opts the optional parameters
  151. # @return [Array<CallTranscriptionMetadata>]
  152. 1 def list_real_time_transcriptions(account_id, call_id, opts = {})
  153. 2 data, _status_code, _headers = list_real_time_transcriptions_with_http_info(account_id, call_id, opts)
  154. data
  155. end
  156. # List Real-time Transcriptions
  157. # List the transcriptions created on this call via [startTranscription](/docs/voice/bxml/startTranscription).
  158. # @param account_id [String] Your Bandwidth Account ID.
  159. # @param call_id [String] Programmable Voice API Call ID.
  160. # @param [Hash] opts the optional parameters
  161. # @return [Array<(Array<CallTranscriptionMetadata>, Integer, Hash)>] Array<CallTranscriptionMetadata> data, response status code and response headers
  162. 1 def list_real_time_transcriptions_with_http_info(account_id, call_id, opts = {})
  163. 3 if @api_client.config.debugging
  164. 3 @api_client.config.logger.debug 'Calling API: TranscriptionsApi.list_real_time_transcriptions ...'
  165. end
  166. # verify the required parameter 'account_id' is set
  167. 3 if @api_client.config.client_side_validation && account_id.nil?
  168. 1 fail ArgumentError, "Missing the required parameter 'account_id' when calling TranscriptionsApi.list_real_time_transcriptions"
  169. end
  170. # verify the required parameter 'call_id' is set
  171. 2 if @api_client.config.client_side_validation && call_id.nil?
  172. 1 fail ArgumentError, "Missing the required parameter 'call_id' when calling TranscriptionsApi.list_real_time_transcriptions"
  173. end
  174. # resource path
  175. 1 local_var_path = '/accounts/{accountId}/calls/{callId}/transcriptions'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s))
  176. # query parameters
  177. 1 query_params = opts[:query_params] || {}
  178. # header parameters
  179. 1 header_params = opts[:header_params] || {}
  180. # HTTP header 'Accept' (if needed)
  181. 1 header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  182. # form parameters
  183. 1 form_params = opts[:form_params] || {}
  184. # http body (model)
  185. 1 post_body = opts[:debug_body]
  186. # return_type
  187. 1 return_type = opts[:debug_return_type] || 'Array<CallTranscriptionMetadata>'
  188. # auth_names
  189. 1 auth_names = opts[:debug_auth_names] || ['Basic', 'OAuth2']
  190. 1 new_options = opts.merge(
  191. :operation => :"TranscriptionsApi.list_real_time_transcriptions",
  192. :header_params => header_params,
  193. :query_params => query_params,
  194. :form_params => form_params,
  195. :body => post_body,
  196. :auth_names => auth_names,
  197. :return_type => return_type
  198. )
  199. 1 data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  200. 1 if @api_client.config.debugging
  201. 1 @api_client.config.logger.debug "API called: TranscriptionsApi#list_real_time_transcriptions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  202. end
  203. 1 return data, status_code, headers
  204. end
  205. end
  206. end

lib/bandwidth-sdk/api_client.rb

84.66% lines covered

189 relevant lines. 160 lines covered and 29 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'json'
  11. 1 require 'logger'
  12. 1 require 'tempfile'
  13. 1 require 'time'
  14. 1 require 'faraday'
  15. 1 require 'faraday/multipart' if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
  16. 1 require 'marcel'
  17. 1 module Bandwidth
  18. 1 class ApiClient
  19. # The Configuration object holding settings to be used in the API client.
  20. 1 attr_accessor :config
  21. # Defines the headers to be used in HTTP requests of all API calls by default.
  22. #
  23. # @return [Hash]
  24. 1 attr_accessor :default_headers
  25. # Initializes the ApiClient
  26. # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
  27. 1 def initialize(config = Configuration.default)
  28. 18 @config = config
  29. 18 @user_agent = "OpenAPI-Generator/#{VERSION}/ruby"
  30. @default_headers = {
  31. 18 'Content-Type' => 'application/json',
  32. 'User-Agent' => @user_agent
  33. }
  34. end
  35. 1 def self.default
  36. 13 @@default ||= ApiClient.new
  37. end
  38. # Call an API with given options.
  39. #
  40. # @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
  41. # the data deserialized from response body (could be nil), response status code and response headers.
  42. 1 def call_api(http_method, path, opts = {})
  43. 54 stream = nil
  44. begin
  45. 54 response = connection(opts).public_send(http_method.to_sym.downcase) do |req|
  46. 54 request = build_request(http_method, path, req, opts)
  47. 54 stream = download_file(request) if opts[:return_type] == 'File' || opts[:return_type] == 'Binary'
  48. end
  49. 54 if config.debugging
  50. 54 config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
  51. end
  52. 54 unless response.success?
  53. if response.status == 0 && response.respond_to?(:return_message)
  54. # Errors from libcurl will be made visible here
  55. fail ApiError.new(code: 0,
  56. message: response.return_message)
  57. else
  58. fail ApiError.new(code: response.status,
  59. response_headers: response.headers,
  60. response_body: response.body),
  61. response.reason_phrase
  62. end
  63. end
  64. rescue Faraday::TimeoutError
  65. fail ApiError.new('Connection timed out')
  66. rescue Faraday::ConnectionFailed
  67. fail ApiError.new('Connection failed')
  68. end
  69. 54 if opts[:return_type] == 'File' || opts[:return_type] == 'Binary'
  70. 3 data = deserialize_file(response, stream)
  71. 51 elsif opts[:return_type]
  72. 32 data = deserialize(response, opts[:return_type])
  73. else
  74. 19 data = nil
  75. end
  76. 54 return data, response.status, response.headers
  77. end
  78. # Builds the HTTP request
  79. #
  80. # @param [String] http_method HTTP method/verb (e.g. POST)
  81. # @param [String] path URL path (e.g. /account/new)
  82. # @option opts [Hash] :header_params Header parameters
  83. # @option opts [Hash] :query_params Query parameters
  84. # @option opts [Hash] :form_params Query parameters
  85. # @option opts [Object] :body HTTP body (JSON/XML)
  86. # @return [Faraday::Request] A Faraday Request
  87. 1 def build_request(http_method, path, request, opts = {})
  88. 54 url = build_request_url(path, opts)
  89. 54 http_method = http_method.to_sym.downcase
  90. 54 header_params = @default_headers.merge(opts[:header_params] || {})
  91. 54 query_params = opts[:query_params] || {}
  92. 54 form_params = opts[:form_params] || {}
  93. 54 update_params_for_auth! header_params, query_params, opts[:auth_names]
  94. 54 if [:post, :patch, :put, :delete].include?(http_method)
  95. 30 req_body = build_request_body(header_params, form_params, opts[:body])
  96. 30 if config.debugging
  97. 30 config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
  98. end
  99. end
  100. 54 request.headers = header_params
  101. 54 request.body = req_body
  102. # Overload default options only if provided
  103. 54 request.options.params_encoder = config.params_encoder if config.params_encoder
  104. 54 request.options.timeout = config.timeout if config.timeout
  105. 54 request.url url
  106. 54 request.params = query_params
  107. 54 request
  108. end
  109. # Builds the HTTP request body
  110. #
  111. # @param [Hash] header_params Header parameters
  112. # @param [Hash] form_params Query parameters
  113. # @param [Object] body HTTP body (JSON/XML)
  114. # @return [String] HTTP body data in the form of string
  115. 1 def build_request_body(header_params, form_params, body)
  116. # http form
  117. 32 if header_params['Content-Type'] == 'application/x-www-form-urlencoded'
  118. 1 data = URI.encode_www_form(form_params)
  119. 31 elsif header_params['Content-Type'] == 'multipart/form-data'
  120. data = {}
  121. form_params.each do |key, value|
  122. case value
  123. when ::File, ::Tempfile
  124. data[key] = Faraday::FilePart.new(value.path, Marcel::MimeType.for(Pathname.new(value.path)))
  125. when ::Array, nil
  126. # let Faraday handle Array and nil parameters
  127. data[key] = value
  128. else
  129. data[key] = value.to_s
  130. end
  131. end
  132. 31 elsif body
  133. 22 data = body.is_a?(String) ? body : body.to_json
  134. else
  135. 9 data = nil
  136. end
  137. 32 data
  138. end
  139. 1 def download_file(request)
  140. 3 stream = []
  141. # handle streaming Responses
  142. 3 request.options.on_data = Proc.new do |chunk, overall_received_bytes|
  143. 3 stream << chunk
  144. end
  145. 3 stream
  146. end
  147. 1 def deserialize_file(response, stream)
  148. 3 body = response.body
  149. 3 encoding = body.encoding
  150. # reconstruct content
  151. 3 content = stream.join
  152. 3 content = content.unpack('m').join if response.headers['Content-Transfer-Encoding'] == 'binary'
  153. 3 content = content.force_encoding(encoding)
  154. # return byte stream
  155. 3 return content if @config.return_binary_data == true
  156. # return file instead of binary data
  157. content_disposition = response.headers['Content-Disposition']
  158. if content_disposition && content_disposition =~ /filename=/i
  159. filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
  160. prefix = sanitize_filename(filename)
  161. else
  162. prefix = 'download-'
  163. end
  164. prefix = prefix + '-' unless prefix.end_with?('-')
  165. tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
  166. tempfile.write(content)
  167. tempfile.close
  168. config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
  169. "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
  170. "will be deleted automatically with GC. It's also recommended to delete the temp file "\
  171. "explicitly with `tempfile.delete`"
  172. tempfile
  173. end
  174. 1 def connection(opts)
  175. 54 opts[:header_params]['Content-Type'] == 'multipart/form-data' ? connection_multipart : connection_regular
  176. end
  177. 1 def connection_multipart
  178. @connection_multipart ||= build_connection do |conn|
  179. conn.request :multipart
  180. conn.request :url_encoded
  181. end
  182. end
  183. 1 def connection_regular
  184. 54 @connection_regular ||= build_connection
  185. end
  186. 1 def build_connection
  187. 1 Faraday.new(url: config.base_url, ssl: ssl_options, proxy: config.proxy) do |conn|
  188. 1 basic_auth(conn)
  189. 1 config.configure_middleware(conn)
  190. 1 yield(conn) if block_given?
  191. 1 conn.adapter(Faraday.default_adapter)
  192. 1 config.configure_connection(conn)
  193. end
  194. end
  195. 1 def ssl_options
  196. {
  197. 1 ca_file: config.ssl_ca_file,
  198. verify: config.ssl_verify,
  199. verify_mode: config.ssl_verify_mode,
  200. client_cert: config.ssl_client_cert,
  201. client_key: config.ssl_client_key
  202. }
  203. end
  204. 1 def basic_auth(conn)
  205. 2 if config.username && config.password
  206. 2 if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
  207. 2 conn.request(:authorization, :basic, config.username, config.password)
  208. else
  209. conn.request(:basic_auth, config.username, config.password)
  210. end
  211. end
  212. end
  213. # Check if the given MIME is a JSON MIME.
  214. # JSON MIME examples:
  215. # application/json
  216. # application/json; charset=UTF8
  217. # APPLICATION/JSON
  218. # */*
  219. # @param [String] mime MIME
  220. # @return [Boolean] True if the MIME is application/json
  221. 1 def json_mime?(mime)
  222. 129 (mime == '*/*') || !(mime =~ /^Application\/.*json(?!p)(;.*)?/i).nil?
  223. end
  224. # Deserialize the response to the given return type.
  225. #
  226. # @param [Response] response HTTP response
  227. # @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
  228. 1 def deserialize(response, return_type)
  229. 34 body = response.body
  230. 34 return nil if body.nil? || body.empty?
  231. # return response body directly for String return type
  232. 34 return body.to_s if return_type == 'String'
  233. # ensuring a default content type
  234. 34 content_type = response.headers['Content-Type'] || 'application/json'
  235. 34 fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
  236. begin
  237. 34 data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
  238. rescue JSON::ParserError => e
  239. 2 if %w(String Date Time).include?(return_type)
  240. 1 data = body
  241. else
  242. 1 raise e
  243. end
  244. end
  245. 33 convert_to_type data, return_type
  246. end
  247. # Convert data to the given return type.
  248. # @param [Object] data Data to be converted
  249. # @param [String] return_type Return type
  250. # @return [Mixed] Data in a particular type
  251. 1 def convert_to_type(data, return_type)
  252. 66 return nil if data.nil?
  253. 66 case return_type
  254. when 'String'
  255. 12 data.to_s
  256. when 'Integer'
  257. 4 data.to_i
  258. when 'Float'
  259. 1 data.to_f
  260. when 'Boolean'
  261. 1 data == true
  262. when 'Time'
  263. # parse date time (expecting ISO 8601 format)
  264. 1 Time.parse data
  265. when 'Date'
  266. # parse date time (expecting ISO 8601 format)
  267. 2 Date.parse data
  268. when 'Object'
  269. # generic object (usually a Hash), return directly
  270. 1 data
  271. when /\AArray<(.+)>\z/
  272. # e.g. Array<Pet>
  273. 11 sub_type = $1
  274. 33 data.map { |item| convert_to_type(item, sub_type) }
  275. when /\AHash\<String, (.+)\>\z/
  276. # e.g. Hash<String, Integer>
  277. 1 sub_type = $1
  278. 1 {}.tap do |hash|
  279. 2 data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
  280. end
  281. else
  282. # models (e.g. Pet) or oneOf/anyOf
  283. 32 klass = Bandwidth.const_get(return_type)
  284. 32 if klass.respond_to?(:openapi_one_of) || klass.respond_to?(:openapi_any_of)
  285. klass.build(data)
  286. else
  287. 32 klass.build_from_hash(data)
  288. end
  289. end
  290. end
  291. # Sanitize filename by removing path.
  292. # e.g. ../../sun.gif becomes sun.gif
  293. #
  294. # @param [String] filename the filename to be sanitized
  295. # @return [String] the sanitized filename
  296. 1 def sanitize_filename(filename)
  297. 9 filename.split(/[\/\\]/).last
  298. end
  299. 1 def build_request_url(path, opts = {})
  300. # Add leading and trailing slashes to path
  301. 55 path = "/#{path}".gsub(/\/+/, '/')
  302. 55 @config.base_url(opts[:operation]) + path
  303. end
  304. # Update header and query params based on authentication settings.
  305. #
  306. # @param [Hash] header_params Header parameters
  307. # @param [Hash] query_params Query parameters
  308. # @param [String] auth_names Authentication scheme name
  309. 1 def update_params_for_auth!(header_params, query_params, auth_names)
  310. 54 Array(auth_names).each do |auth_name|
  311. 108 auth_setting = @config.auth_settings[auth_name]
  312. 108 next unless auth_setting
  313. 108 case auth_setting[:in]
  314. 108 when 'header' then header_params[auth_setting[:key]] = auth_setting[:value] unless auth_setting[:value].nil?
  315. when 'query' then query_params[auth_setting[:key]] = auth_setting[:value] unless auth_setting[:value].nil?
  316. else fail ArgumentError, 'Authentication token must be in `query` or `header`'
  317. end
  318. end
  319. end
  320. # Sets user agent in HTTP header
  321. #
  322. # @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
  323. 1 def user_agent=(user_agent)
  324. 1 @user_agent = user_agent
  325. 1 @default_headers['User-Agent'] = @user_agent
  326. end
  327. # Return Accept header based on an array of accepts provided.
  328. # @param [Array] accepts array for Accept
  329. # @return [String] the Accept header (e.g. application/json)
  330. 1 def select_header_accept(accepts)
  331. 58 return nil if accepts.nil? || accepts.empty?
  332. # use JSON when present, otherwise use all of the provided
  333. 114 json_accept = accepts.find { |s| json_mime?(s) }
  334. 56 json_accept || accepts.join(',')
  335. end
  336. # Return Content-Type header based on an array of content types provided.
  337. # @param [Array] content_types array for Content-Type
  338. # @return [String] the Content-Type header (e.g. application/json)
  339. 1 def select_header_content_type(content_types)
  340. # return nil by default
  341. 29 return if content_types.nil? || content_types.empty?
  342. # use JSON when present, otherwise use the first one
  343. 56 json_content_type = content_types.find { |s| json_mime?(s) }
  344. 27 json_content_type || content_types.first
  345. end
  346. # Convert object (array, hash, object, etc) to JSON string.
  347. # @param [Object] model object to be converted into JSON string
  348. # @return [String] JSON string representation of the object
  349. 1 def object_to_http_body(model)
  350. 24 return model if model.nil? || model.is_a?(String)
  351. 20 local_body = nil
  352. 20 if model.is_a?(Array)
  353. 4 local_body = model.map { |m| object_to_hash(m) }
  354. else
  355. 19 local_body = object_to_hash(model)
  356. end
  357. 20 local_body.to_json
  358. end
  359. # Convert object(non-array) to hash.
  360. # @param [Object] obj object to be converted into JSON string
  361. # @return [String] JSON string representation of the object
  362. 1 def object_to_hash(obj)
  363. 25 if obj.respond_to?(:to_hash)
  364. 20 obj.to_hash
  365. else
  366. 5 obj
  367. end
  368. end
  369. # Build parameter value according to the given collection format.
  370. # @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
  371. 1 def build_collection_param(param, collection_format)
  372. 6 case collection_format
  373. when :csv
  374. 1 param.join(',')
  375. when :ssv
  376. 1 param.join(' ')
  377. when :tsv
  378. 1 param.join("\t")
  379. when :pipes
  380. 1 param.join('|')
  381. when :multi
  382. # return the array directly as typhoeus will handle it as expected
  383. 1 param
  384. else
  385. 1 fail "unknown collection format: #{collection_format.inspect}"
  386. end
  387. end
  388. end
  389. end

lib/bandwidth-sdk/api_error.rb

95.45% lines covered

22 relevant lines. 21 lines covered and 1 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 module Bandwidth
  10. 1 class ApiError < StandardError
  11. 1 attr_reader :code, :response_headers, :response_body
  12. # Usage examples:
  13. # ApiError.new
  14. # ApiError.new("message")
  15. # ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
  16. # ApiError.new(:code => 404, :message => "Not Found")
  17. 1 def initialize(arg = nil)
  18. 3 if arg.is_a? Hash
  19. 1 if arg.key?(:message) || arg.key?('message')
  20. 1 super(arg[:message] || arg['message'])
  21. else
  22. super arg
  23. end
  24. 1 arg.each do |k, v|
  25. 1 instance_variable_set "@#{k}", v
  26. end
  27. else
  28. 2 super arg
  29. 2 @message = arg
  30. end
  31. end
  32. # Override to_s to display a friendly error message
  33. 1 def to_s
  34. 1 message
  35. end
  36. 1 def message
  37. 3 if @message.nil?
  38. 1 msg = 'Error message: the server returns an error'
  39. else
  40. 2 msg = @message
  41. end
  42. 3 msg += "\nHTTP status code: #{code}" if code
  43. 3 msg += "\nResponse headers: #{response_headers}" if response_headers
  44. 3 msg += "\nResponse body: #{response_body}" if response_body
  45. 3 msg
  46. end
  47. end
  48. end

lib/bandwidth-sdk/api_model_base.rb

94.29% lines covered

35 relevant lines. 33 lines covered and 2 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 module Bandwidth
  10. 1 class ApiModelBase
  11. # Deserializes the data based on type
  12. # @param string type Data type
  13. # @param string value Value to be deserialized
  14. # @return [Object] Deserialized data
  15. 1 def self._deserialize(type, value)
  16. 1722 case type.to_sym
  17. when :Time
  18. 167 Time.parse(value)
  19. when :Date
  20. 10 Date.parse(value)
  21. when :String
  22. 1079 value.to_s
  23. when :Integer
  24. 71 value.to_i
  25. when :Float
  26. 24 value.to_f
  27. when :Boolean
  28. 26 if value.to_s =~ /\A(true|t|yes|y|1)\z/i
  29. 13 true
  30. else
  31. 13 false
  32. end
  33. when :Object
  34. # generic object (usually a Hash), return directly
  35. 5 value
  36. when /\AArray<(?<inner_type>.+)>\z/
  37. inner_type = Regexp.last_match[:inner_type]
  38. value.map { |v| _deserialize(inner_type, v) }
  39. when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
  40. 3 k_type = Regexp.last_match[:k_type]
  41. 3 v_type = Regexp.last_match[:v_type]
  42. 3 {}.tap do |hash|
  43. 3 value.each do |k, v|
  44. 9 hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
  45. end
  46. end
  47. else # model
  48. # models (e.g. Pet) or oneOf
  49. 337 klass = Bandwidth.const_get(type)
  50. 337 klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  51. end
  52. end
  53. # Returns the string representation of the object
  54. # @return [String] String presentation of the object
  55. 1 def to_s
  56. 151 to_hash.to_s
  57. end
  58. # to_body is an alias to to_hash (backward compatibility)
  59. # @return [Hash] Returns the object in the form of hash
  60. 1 def to_body
  61. 151 to_hash
  62. end
  63. # Outputs non-array value in the form of hash
  64. # For object, use to_hash. Otherwise, just return the value
  65. # @param [Object] value Any valid value
  66. # @return [Hash] Returns the value in the form of hash
  67. 1 def _to_hash(value)
  68. 2726 if value.is_a?(Array)
  69. 292 value.compact.map { |v| _to_hash(v) }
  70. 2585 elsif value.is_a?(Hash)
  71. 63 {}.tap do |hash|
  72. 193 value.each { |k, v| hash[k] = _to_hash(v) }
  73. end
  74. 2522 elsif value.respond_to? :to_hash
  75. 150 value.to_hash
  76. else
  77. 2372 value
  78. end
  79. end
  80. end
  81. end

lib/bandwidth-sdk/configuration.rb

96.79% lines covered

156 relevant lines. 151 lines covered and 5 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 module Bandwidth
  10. 1 class Configuration
  11. # Defines url scheme
  12. 1 attr_accessor :scheme
  13. # Defines url host
  14. 1 attr_accessor :host
  15. # Defines url base path
  16. 1 attr_accessor :base_path
  17. # Define server configuration index
  18. 1 attr_accessor :server_index
  19. # Define server operation configuration index
  20. 1 attr_accessor :server_operation_index
  21. # Default server variables
  22. 1 attr_accessor :server_variables
  23. # Default server operation variables
  24. 1 attr_accessor :server_operation_variables
  25. # Defines API keys used with API Key authentications.
  26. #
  27. # @return [Hash] key: parameter name, value: parameter value (API key)
  28. #
  29. # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
  30. # config.api_key['api_key'] = 'xxx'
  31. 1 attr_accessor :api_key
  32. # Defines API key prefixes used with API Key authentications.
  33. #
  34. # @return [Hash] key: parameter name, value: API key prefix
  35. #
  36. # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
  37. # config.api_key_prefix['api_key'] = 'Token'
  38. 1 attr_accessor :api_key_prefix
  39. # Defines the username used with HTTP basic authentication.
  40. #
  41. # @return [String]
  42. 1 attr_accessor :username
  43. # Defines the password used with HTTP basic authentication.
  44. #
  45. # @return [String]
  46. 1 attr_accessor :password
  47. # Defines the client ID used with OAuth2.
  48. #
  49. # @return [String]
  50. 1 attr_accessor :client_id
  51. # Defines the client secret used with OAuth2.
  52. #
  53. # @return [String]
  54. 1 attr_accessor :client_secret
  55. # Defines the access token (Bearer) used with OAuth2.
  56. 1 attr_accessor :access_token
  57. # Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2.
  58. # Overrides the access_token if set
  59. # @return [Proc]
  60. 1 attr_accessor :access_token_getter
  61. # Set this to return data as binary instead of downloading a temp file. When enabled (set to true)
  62. # HTTP responses with return type `File` will be returned as a stream of binary data.
  63. # Default to false.
  64. 1 attr_accessor :return_binary_data
  65. # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
  66. # details will be logged with `logger.debug` (see the `logger` attribute).
  67. # Default to false.
  68. #
  69. # @return [true, false]
  70. 1 attr_accessor :debugging
  71. # Set this to ignore operation servers for the API client. This is useful when you need to
  72. # send requests to a different server than the one specified in the OpenAPI document.
  73. # Will default to the base url defined in the spec but can be overridden by setting
  74. # `scheme`, `host`, `base_path` directly.
  75. # Default to false.
  76. # @return [true, false]
  77. 1 attr_accessor :ignore_operation_servers
  78. # Defines the logger used for debugging.
  79. # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
  80. #
  81. # @return [#debug]
  82. 1 attr_accessor :logger
  83. # Defines the temporary folder to store downloaded files
  84. # (for API endpoints that have file response).
  85. # Default to use `Tempfile`.
  86. #
  87. # @return [String]
  88. 1 attr_accessor :temp_folder_path
  89. # The time limit for HTTP request in seconds.
  90. # Default to 0 (never times out).
  91. 1 attr_accessor :timeout
  92. # Set this to false to skip client side validation in the operation.
  93. # Default to true.
  94. # @return [true, false]
  95. 1 attr_accessor :client_side_validation
  96. ### TLS/SSL setting
  97. # Set this to false to skip verifying SSL certificate when calling API from https server.
  98. # Default to true.
  99. #
  100. # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
  101. #
  102. # @return [true, false]
  103. 1 attr_accessor :ssl_verify
  104. ### TLS/SSL setting
  105. # Any `OpenSSL::SSL::` constant (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL.html)
  106. #
  107. # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
  108. #
  109. 1 attr_accessor :ssl_verify_mode
  110. ### TLS/SSL setting
  111. # Set this to customize the certificate file to verify the peer.
  112. #
  113. # @return [String] the path to the certificate file
  114. 1 attr_accessor :ssl_ca_file
  115. ### TLS/SSL setting
  116. # Client certificate file (for client certificate)
  117. 1 attr_accessor :ssl_client_cert
  118. ### TLS/SSL setting
  119. # Client private key file (for client certificate)
  120. 1 attr_accessor :ssl_client_key
  121. ### Proxy setting
  122. # HTTP Proxy settings
  123. 1 attr_accessor :proxy
  124. # Set this to customize parameters encoder of array parameter.
  125. # Default to nil. Faraday uses NestedParamsEncoder when nil.
  126. #
  127. # @see The params_encoder option of Faraday. Related source code:
  128. # https://github.com/lostisland/faraday/tree/main/lib/faraday/encoders
  129. 1 attr_accessor :params_encoder
  130. 1 attr_accessor :inject_format
  131. 1 attr_accessor :force_ending_format
  132. 1 def initialize
  133. 37 @scheme = 'http'
  134. 37 @host = 'localhost'
  135. 37 @base_path = ''
  136. 37 @server_index = nil
  137. 37 @server_operation_index = {}
  138. 37 @server_variables = {}
  139. 37 @server_operation_variables = {}
  140. 37 @api_key = {}
  141. 37 @api_key_prefix = {}
  142. 37 @client_side_validation = true
  143. 37 @ssl_verify = true
  144. 37 @ssl_verify_mode = nil
  145. 37 @ssl_ca_file = nil
  146. 37 @ssl_client_cert = nil
  147. 37 @ssl_client_key = nil
  148. 42 @middlewares = Hash.new { |h, k| h[k] = [] }
  149. 37 @configure_connection_blocks = []
  150. 37 @timeout = 60
  151. # return data as binary instead of file
  152. 37 @return_binary_data = false
  153. 37 @params_encoder = nil
  154. 37 @debugging = false
  155. 37 @ignore_operation_servers = false
  156. 37 @inject_format = false
  157. 37 @force_ending_format = false
  158. 37 @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
  159. 37 @access_token_expiration = nil
  160. 37 @access_token_getter = Proc.new {
  161. 116 access_token_valid = @access_token && (@access_token_expiration.nil? || @access_token_expiration > Time.now + 60)
  162. 116 next @access_token if access_token_valid
  163. 113 next unless @client_id && @client_secret
  164. 3 puts "Refreshing access token..." if @debugging
  165. # obtain new access token using client credentials
  166. 3 token_url = 'https://api.bandwidth.com/api/v1/oauth2/token'
  167. 3 auth_header = 'Basic ' + ["#{@client_id}:#{@client_secret}"].pack('m').delete("\r\n")
  168. 3 conn = Faraday.new(url: token_url) do |faraday|
  169. faraday.request :url_encoded
  170. faraday.adapter Faraday.default_adapter
  171. end
  172. 3 response = conn.post do |req|
  173. req.headers['Authorization'] = auth_header
  174. req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
  175. req.body = 'grant_type=client_credentials'
  176. end
  177. 3 if response.status != 200
  178. 1 raise "Failed to obtain access token: #{response.status} #{response.body}"
  179. end
  180. 2 body = JSON.parse(response.body)
  181. 2 @access_token = body['access_token']
  182. 2 @access_token_expiration = Time.now + body['expires_in']
  183. 2 @access_token
  184. }
  185. 37 yield(self) if block_given?
  186. end
  187. # The default Configuration object.
  188. 1 def self.default
  189. 30 @@default ||= Configuration.new
  190. end
  191. 1 def configure
  192. 1 yield(self) if block_given?
  193. end
  194. 1 def scheme=(scheme)
  195. # remove :// from scheme
  196. 2 @scheme = scheme.sub(/:\/\//, '')
  197. end
  198. 1 def host=(host)
  199. # remove http(s):// and anything after a slash
  200. 14 @host = host.sub(/https?:\/\//, '').split('/').first
  201. end
  202. 1 def base_path=(base_path)
  203. # Add leading and trailing slashes to base_path
  204. 2 @base_path = "/#{base_path}".gsub(/\/+/, '/')
  205. 2 @base_path = '' if @base_path == '/'
  206. end
  207. # Returns base URL for specified operation based on server settings
  208. 1 def base_url(operation = nil)
  209. 61 return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if ignore_operation_servers
  210. 5 if operation_server_settings.key?(operation) then
  211. 2 index = server_operation_index.fetch(operation, server_index)
  212. 2 server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
  213. else
  214. 3 server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil)
  215. end
  216. end
  217. # Gets API key (with prefix if set).
  218. # @param [String] param_name the parameter name of API key auth
  219. 1 def api_key_with_prefix(param_name, param_alias = nil)
  220. 2 key = @api_key[param_name]
  221. 2 key = @api_key.fetch(param_alias, key) unless param_alias.nil?
  222. 2 if @api_key_prefix[param_name]
  223. 1 "#{@api_key_prefix[param_name]} #{key}"
  224. else
  225. 1 key
  226. end
  227. end
  228. # Gets access_token using access_token_getter or uses the static access_token
  229. 1 def access_token_with_refresh
  230. 118 return access_token if access_token_getter.nil?
  231. 114 access_token_getter.call
  232. end
  233. # Gets Basic Auth token string
  234. 1 def basic_auth_token
  235. 111 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
  236. end
  237. # Gets Bearer auth token string
  238. 1 def oauth_bearer_token
  239. 113 "Bearer #{access_token_with_refresh}" unless access_token_with_refresh.nil?
  240. end
  241. # Returns Auth Settings hash for api client.
  242. 1 def auth_settings
  243. {
  244. 110 'Basic' =>
  245. {
  246. type: 'basic',
  247. in: 'header',
  248. key: 'Authorization',
  249. value: basic_auth_token
  250. },
  251. 'OAuth2' =>
  252. {
  253. type: 'oauth2',
  254. in: 'header',
  255. key: 'Authorization',
  256. value: oauth_bearer_token
  257. },
  258. }
  259. end
  260. # Returns an array of Server setting
  261. 1 def server_settings
  262. [
  263. {
  264. 1 url: "",
  265. description: "No description provided",
  266. }
  267. ]
  268. end
  269. 1 def operation_server_settings
  270. {
  271. 8 "CallsApi.create_call": [
  272. {
  273. url: "https://voice.bandwidth.com/api/v2",
  274. description: "Production",
  275. }
  276. ],
  277. "CallsApi.get_call_state": [
  278. {
  279. url: "https://voice.bandwidth.com/api/v2",
  280. description: "Production",
  281. }
  282. ],
  283. "CallsApi.list_calls": [
  284. {
  285. url: "https://voice.bandwidth.com/api/v2",
  286. description: "Production",
  287. }
  288. ],
  289. "CallsApi.update_call": [
  290. {
  291. url: "https://voice.bandwidth.com/api/v2",
  292. description: "Production",
  293. }
  294. ],
  295. "CallsApi.update_call_bxml": [
  296. {
  297. url: "https://voice.bandwidth.com/api/v2",
  298. description: "Production",
  299. }
  300. ],
  301. "ConferencesApi.download_conference_recording": [
  302. {
  303. url: "https://voice.bandwidth.com/api/v2",
  304. description: "Production",
  305. }
  306. ],
  307. "ConferencesApi.get_conference": [
  308. {
  309. url: "https://voice.bandwidth.com/api/v2",
  310. description: "Production",
  311. }
  312. ],
  313. "ConferencesApi.get_conference_member": [
  314. {
  315. url: "https://voice.bandwidth.com/api/v2",
  316. description: "Production",
  317. }
  318. ],
  319. "ConferencesApi.get_conference_recording": [
  320. {
  321. url: "https://voice.bandwidth.com/api/v2",
  322. description: "Production",
  323. }
  324. ],
  325. "ConferencesApi.list_conference_recordings": [
  326. {
  327. url: "https://voice.bandwidth.com/api/v2",
  328. description: "Production",
  329. }
  330. ],
  331. "ConferencesApi.list_conferences": [
  332. {
  333. url: "https://voice.bandwidth.com/api/v2",
  334. description: "Production",
  335. }
  336. ],
  337. "ConferencesApi.update_conference": [
  338. {
  339. url: "https://voice.bandwidth.com/api/v2",
  340. description: "Production",
  341. }
  342. ],
  343. "ConferencesApi.update_conference_bxml": [
  344. {
  345. url: "https://voice.bandwidth.com/api/v2",
  346. description: "Production",
  347. }
  348. ],
  349. "ConferencesApi.update_conference_member": [
  350. {
  351. url: "https://voice.bandwidth.com/api/v2",
  352. description: "Production",
  353. }
  354. ],
  355. "EndpointsApi.create_endpoint": [
  356. {
  357. url: "https://api.bandwidth.com/v2",
  358. description: "Production",
  359. }
  360. ],
  361. "EndpointsApi.delete_endpoint": [
  362. {
  363. url: "https://api.bandwidth.com/v2",
  364. description: "Production",
  365. }
  366. ],
  367. "EndpointsApi.get_endpoint": [
  368. {
  369. url: "https://api.bandwidth.com/v2",
  370. description: "Production",
  371. }
  372. ],
  373. "EndpointsApi.list_endpoints": [
  374. {
  375. url: "https://api.bandwidth.com/v2",
  376. description: "Production",
  377. }
  378. ],
  379. "EndpointsApi.update_endpoint_bxml": [
  380. {
  381. url: "https://api.bandwidth.com/v2",
  382. description: "Production",
  383. }
  384. ],
  385. "MFAApi.generate_messaging_code": [
  386. {
  387. url: "https://mfa.bandwidth.com/api/v1",
  388. description: "Production",
  389. }
  390. ],
  391. "MFAApi.generate_voice_code": [
  392. {
  393. url: "https://mfa.bandwidth.com/api/v1",
  394. description: "Production",
  395. }
  396. ],
  397. "MFAApi.verify_code": [
  398. {
  399. url: "https://mfa.bandwidth.com/api/v1",
  400. description: "Production",
  401. }
  402. ],
  403. "MediaApi.delete_media": [
  404. {
  405. url: "https://messaging.bandwidth.com/api/v2",
  406. description: "Production",
  407. }
  408. ],
  409. "MediaApi.get_media": [
  410. {
  411. url: "https://messaging.bandwidth.com/api/v2",
  412. description: "Production",
  413. }
  414. ],
  415. "MediaApi.list_media": [
  416. {
  417. url: "https://messaging.bandwidth.com/api/v2",
  418. description: "Production",
  419. }
  420. ],
  421. "MediaApi.upload_media": [
  422. {
  423. url: "https://messaging.bandwidth.com/api/v2",
  424. description: "Production",
  425. }
  426. ],
  427. "MessagesApi.create_message": [
  428. {
  429. url: "https://messaging.bandwidth.com/api/v2",
  430. description: "Production",
  431. }
  432. ],
  433. "MessagesApi.list_messages": [
  434. {
  435. url: "https://messaging.bandwidth.com/api/v2",
  436. description: "Production",
  437. }
  438. ],
  439. "MultiChannelApi.create_multi_channel_message": [
  440. {
  441. url: "https://messaging.bandwidth.com/api/v2",
  442. description: "Production",
  443. }
  444. ],
  445. "PhoneNumberLookupApi.create_async_bulk_lookup": [
  446. {
  447. url: "https://api.bandwidth.com/v2",
  448. description: "Production",
  449. }
  450. ],
  451. "PhoneNumberLookupApi.create_sync_lookup": [
  452. {
  453. url: "https://api.bandwidth.com/v2",
  454. description: "Production",
  455. }
  456. ],
  457. "PhoneNumberLookupApi.get_async_bulk_lookup": [
  458. {
  459. url: "https://api.bandwidth.com/v2",
  460. description: "Production",
  461. }
  462. ],
  463. "RecordingsApi.delete_recording": [
  464. {
  465. url: "https://voice.bandwidth.com/api/v2",
  466. description: "Production",
  467. }
  468. ],
  469. "RecordingsApi.delete_recording_media": [
  470. {
  471. url: "https://voice.bandwidth.com/api/v2",
  472. description: "Production",
  473. }
  474. ],
  475. "RecordingsApi.delete_recording_transcription": [
  476. {
  477. url: "https://voice.bandwidth.com/api/v2",
  478. description: "Production",
  479. }
  480. ],
  481. "RecordingsApi.download_call_recording": [
  482. {
  483. url: "https://voice.bandwidth.com/api/v2",
  484. description: "Production",
  485. }
  486. ],
  487. "RecordingsApi.get_call_recording": [
  488. {
  489. url: "https://voice.bandwidth.com/api/v2",
  490. description: "Production",
  491. }
  492. ],
  493. "RecordingsApi.get_recording_transcription": [
  494. {
  495. url: "https://voice.bandwidth.com/api/v2",
  496. description: "Production",
  497. }
  498. ],
  499. "RecordingsApi.list_account_call_recordings": [
  500. {
  501. url: "https://voice.bandwidth.com/api/v2",
  502. description: "Production",
  503. }
  504. ],
  505. "RecordingsApi.list_call_recordings": [
  506. {
  507. url: "https://voice.bandwidth.com/api/v2",
  508. description: "Production",
  509. }
  510. ],
  511. "RecordingsApi.transcribe_call_recording": [
  512. {
  513. url: "https://voice.bandwidth.com/api/v2",
  514. description: "Production",
  515. }
  516. ],
  517. "RecordingsApi.update_call_recording_state": [
  518. {
  519. url: "https://voice.bandwidth.com/api/v2",
  520. description: "Production",
  521. }
  522. ],
  523. "StatisticsApi.get_statistics": [
  524. {
  525. url: "https://voice.bandwidth.com/api/v2",
  526. description: "Production",
  527. }
  528. ],
  529. "TollFreeVerificationApi.create_webhook_subscription": [
  530. {
  531. url: "https://api.bandwidth.com/api/v2",
  532. description: "Production",
  533. }
  534. ],
  535. "TollFreeVerificationApi.delete_verification_request": [
  536. {
  537. url: "https://api.bandwidth.com/api/v2",
  538. description: "Production",
  539. }
  540. ],
  541. "TollFreeVerificationApi.delete_webhook_subscription": [
  542. {
  543. url: "https://api.bandwidth.com/api/v2",
  544. description: "Production",
  545. }
  546. ],
  547. "TollFreeVerificationApi.get_toll_free_verification_status": [
  548. {
  549. url: "https://api.bandwidth.com/api/v2",
  550. description: "Production",
  551. }
  552. ],
  553. "TollFreeVerificationApi.list_toll_free_use_cases": [
  554. {
  555. url: "https://api.bandwidth.com/api/v2",
  556. description: "Production",
  557. }
  558. ],
  559. "TollFreeVerificationApi.list_webhook_subscriptions": [
  560. {
  561. url: "https://api.bandwidth.com/api/v2",
  562. description: "Production",
  563. }
  564. ],
  565. "TollFreeVerificationApi.request_toll_free_verification": [
  566. {
  567. url: "https://api.bandwidth.com/api/v2",
  568. description: "Production",
  569. }
  570. ],
  571. "TollFreeVerificationApi.update_toll_free_verification_request": [
  572. {
  573. url: "https://api.bandwidth.com/api/v2",
  574. description: "Production",
  575. }
  576. ],
  577. "TollFreeVerificationApi.update_webhook_subscription": [
  578. {
  579. url: "https://api.bandwidth.com/api/v2",
  580. description: "Production",
  581. }
  582. ],
  583. "TranscriptionsApi.delete_real_time_transcription": [
  584. {
  585. url: "https://voice.bandwidth.com/api/v2",
  586. description: "Production",
  587. }
  588. ],
  589. "TranscriptionsApi.get_real_time_transcription": [
  590. {
  591. url: "https://voice.bandwidth.com/api/v2",
  592. description: "Production",
  593. }
  594. ],
  595. "TranscriptionsApi.list_real_time_transcriptions": [
  596. {
  597. url: "https://voice.bandwidth.com/api/v2",
  598. description: "Production",
  599. }
  600. ],
  601. }
  602. end
  603. # Returns URL based on server settings
  604. #
  605. # @param index array index of the server settings
  606. # @param variables hash of variable and the corresponding value
  607. 1 def server_url(index, variables = {}, servers = nil)
  608. 5 servers = server_settings if servers == nil
  609. # check array index out of bound
  610. 5 if (index.nil? || index < 0 || index >= servers.size)
  611. 2 fail ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}"
  612. end
  613. 3 server = servers[index]
  614. 3 url = server[:url]
  615. 3 return url unless server.key? :variables
  616. # go through variable and assign a value
  617. 2 server[:variables].each do |name, variable|
  618. 3 if variables.key?(name)
  619. 2 if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
  620. 1 url.gsub! "{" + name.to_s + "}", variables[name]
  621. else
  622. 1 fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
  623. end
  624. else
  625. # use default value
  626. 1 url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
  627. end
  628. end
  629. 1 url
  630. end
  631. # Configure Faraday connection directly.
  632. #
  633. # ```
  634. # c.configure_faraday_connection do |conn|
  635. # conn.use Faraday::HttpCache, shared_cache: false, logger: logger
  636. # conn.response :logger, nil, headers: true, bodies: true, log_level: :debug do |logger|
  637. # logger.filter(/(Authorization: )(.*)/, '\1[REDACTED]')
  638. # end
  639. # end
  640. #
  641. # c.configure_faraday_connection do |conn|
  642. # conn.adapter :typhoeus
  643. # end
  644. # ```
  645. #
  646. # @param block [Proc] `#call`able object that takes one arg, the connection
  647. 1 def configure_faraday_connection(&block)
  648. 1 @configure_connection_blocks << block
  649. end
  650. 1 def configure_connection(conn)
  651. 2 @configure_connection_blocks.each do |block|
  652. 1 block.call(conn)
  653. end
  654. end
  655. # Adds middleware to the stack
  656. 1 def use(*middleware)
  657. 1 set_faraday_middleware(:use, *middleware)
  658. end
  659. # Adds request middleware to the stack
  660. 1 def request(*middleware)
  661. 1 set_faraday_middleware(:request, *middleware)
  662. end
  663. # Adds response middleware to the stack
  664. 1 def response(*middleware)
  665. 2 set_faraday_middleware(:response, *middleware)
  666. end
  667. # Adds Faraday middleware setting information to the stack
  668. #
  669. # @example Use the `set_faraday_middleware` method to set middleware information
  670. # config.set_faraday_middleware(:request, :retry, max: 3, methods: [:get, :post], retry_statuses: [503])
  671. # config.set_faraday_middleware(:response, :logger, nil, { bodies: true, log_level: :debug })
  672. # config.set_faraday_middleware(:use, Faraday::HttpCache, store: Rails.cache, shared_cache: false)
  673. # config.set_faraday_middleware(:insert, 0, FaradayMiddleware::FollowRedirects, { standards_compliant: true, limit: 1 })
  674. # config.set_faraday_middleware(:swap, 0, Faraday::Response::Logger)
  675. # config.set_faraday_middleware(:delete, Faraday::Multipart::Middleware)
  676. #
  677. # @see https://github.com/lostisland/faraday/blob/v2.3.0/lib/faraday/rack_builder.rb#L92-L143
  678. 1 def set_faraday_middleware(operation, key, *args, &block)
  679. 6 unless [:request, :response, :use, :insert, :insert_before, :insert_after, :swap, :delete].include?(operation)
  680. 1 fail ArgumentError, "Invalid faraday middleware operation #{operation}. Must be" \
  681. " :request, :response, :use, :insert, :insert_before, :insert_after, :swap or :delete."
  682. end
  683. 5 @middlewares[operation] << [key, args, block]
  684. end
  685. 1 ruby2_keywords(:set_faraday_middleware) if respond_to?(:ruby2_keywords, true)
  686. # Set up middleware on the connection
  687. 1 def configure_middleware(connection)
  688. 3 return if @middlewares.empty?
  689. 2 [:request, :response, :use, :insert, :insert_before, :insert_after, :swap].each do |operation|
  690. 14 next unless @middlewares.key?(operation)
  691. 1 @middlewares[operation].each do |key, args, block|
  692. 1 connection.builder.send(operation, key, *args, &block)
  693. end
  694. end
  695. 2 if @middlewares.key?(:delete)
  696. 1 @middlewares[:delete].each do |key, _args, _block|
  697. 1 connection.builder.delete(key)
  698. end
  699. end
  700. end
  701. end
  702. end

lib/bandwidth-sdk/models/account_statistics.rb

82.81% lines covered

64 relevant lines. 53 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class AccountStatistics < ApiModelBase
  13. # The number of calls currently enqueued.
  14. 1 attr_accessor :current_call_queue_size
  15. # The maximum size of the queue before outgoing calls start being rejected.
  16. 1 attr_accessor :max_call_queue_size
  17. # Attribute mapping from ruby-style variable name to JSON key.
  18. 1 def self.attribute_map
  19. 28 {
  20. :'current_call_queue_size' => :'currentCallQueueSize',
  21. :'max_call_queue_size' => :'maxCallQueueSize'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 9 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 1 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 2 {
  35. :'current_call_queue_size' => :'Integer',
  36. :'max_call_queue_size' => :'Integer'
  37. }
  38. end
  39. # List of attributes with nullable: true
  40. 1 def self.openapi_nullable
  41. 1 Set.new([
  42. ])
  43. end
  44. # Initializes the object
  45. # @param [Hash] attributes Model attributes in the form of hash
  46. 1 def initialize(attributes = {})
  47. 9 if (!attributes.is_a?(Hash))
  48. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::AccountStatistics` initialize method'
  49. end
  50. # check to see if the attribute exists and convert string to symbol for hash key
  51. 8 acceptable_attribute_map = self.class.acceptable_attribute_map
  52. 8 attributes = attributes.each_with_object({}) { |(k, v), h|
  53. 11 if (!acceptable_attribute_map.key?(k.to_sym))
  54. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::AccountStatistics`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  55. end
  56. 10 h[k.to_sym] = v
  57. }
  58. 7 if attributes.key?(:'current_call_queue_size')
  59. 5 self.current_call_queue_size = attributes[:'current_call_queue_size']
  60. end
  61. 7 if attributes.key?(:'max_call_queue_size')
  62. 5 self.max_call_queue_size = attributes[:'max_call_queue_size']
  63. end
  64. end
  65. # Show invalid properties with the reasons. Usually used together with valid?
  66. # @return Array for valid properties with the reasons
  67. 1 def list_invalid_properties
  68. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  69. invalid_properties = Array.new
  70. invalid_properties
  71. end
  72. # Check to see if the all the properties in the model are valid
  73. # @return true if the model is valid
  74. 1 def valid?
  75. warn '[DEPRECATED] the `valid?` method is obsolete'
  76. true
  77. end
  78. # Checks equality by comparing each attribute.
  79. # @param [Object] Object to be compared
  80. 1 def ==(o)
  81. 2 return true if self.equal?(o)
  82. 2 self.class == o.class &&
  83. current_call_queue_size == o.current_call_queue_size &&
  84. max_call_queue_size == o.max_call_queue_size
  85. end
  86. # @see the `==` method
  87. # @param [Object] Object to be compared
  88. 1 def eql?(o)
  89. 2 self == o
  90. end
  91. # Calculates hash code according to all attributes.
  92. # @return [Integer] Hash code
  93. 1 def hash
  94. [current_call_queue_size, max_call_queue_size].hash
  95. end
  96. # Builds the object from hash
  97. # @param [Hash] attributes Model attributes in the form of hash
  98. # @return [Object] Returns the model itself
  99. 1 def self.build_from_hash(attributes)
  100. 2 return nil unless attributes.is_a?(Hash)
  101. 2 attributes = attributes.transform_keys(&:to_sym)
  102. 2 transformed_hash = {}
  103. 2 openapi_types.each_pair do |key, type|
  104. 4 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  105. transformed_hash["#{key}"] = nil
  106. 4 elsif type =~ /\AArray<(.*)>/i
  107. # check to ensure the input is an array given that the attribute
  108. # is documented as an array but the input is not
  109. if attributes[attribute_map[key]].is_a?(Array)
  110. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  111. end
  112. 4 elsif !attributes[attribute_map[key]].nil?
  113. 4 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  114. end
  115. end
  116. 2 new(transformed_hash)
  117. end
  118. # Returns the object in the form of hash
  119. # @return [Hash] Returns the object in the form of hash
  120. 1 def to_hash
  121. 2 hash = {}
  122. 2 self.class.attribute_map.each_pair do |attr, param|
  123. 4 value = self.send(attr)
  124. 4 if value.nil?
  125. is_nullable = self.class.openapi_nullable.include?(attr)
  126. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  127. end
  128. 4 hash[param] = _to_hash(value)
  129. end
  130. 2 hash
  131. end
  132. end
  133. end

lib/bandwidth-sdk/models/additional_denial_reason.rb

74.73% lines covered

91 relevant lines. 68 lines covered and 23 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class AdditionalDenialReason < ApiModelBase
  13. # Reason code for denial.
  14. 1 attr_accessor :status_code
  15. # Explanation for why a verification request was declined.
  16. 1 attr_accessor :reason
  17. # Whether a Toll-Free Verification request qualifies for resubmission via PUT.
  18. 1 attr_accessor :resubmit_allowed
  19. # Attribute mapping from ruby-style variable name to JSON key.
  20. 1 def self.attribute_map
  21. 44 {
  22. :'status_code' => :'statusCode',
  23. :'reason' => :'reason',
  24. :'resubmit_allowed' => :'resubmitAllowed'
  25. }
  26. end
  27. # Returns attribute mapping this model knows about
  28. 1 def self.acceptable_attribute_map
  29. 15 attribute_map
  30. end
  31. # Returns all the JSON keys this model knows about
  32. 1 def self.acceptable_attributes
  33. 1 acceptable_attribute_map.values
  34. end
  35. # Attribute type mapping.
  36. 1 def self.openapi_types
  37. 2 {
  38. :'status_code' => :'Integer',
  39. :'reason' => :'String',
  40. :'resubmit_allowed' => :'Boolean'
  41. }
  42. end
  43. # List of attributes with nullable: true
  44. 1 def self.openapi_nullable
  45. 1 Set.new([
  46. ])
  47. end
  48. # Initializes the object
  49. # @param [Hash] attributes Model attributes in the form of hash
  50. 1 def initialize(attributes = {})
  51. 15 if (!attributes.is_a?(Hash))
  52. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::AdditionalDenialReason` initialize method'
  53. end
  54. # check to see if the attribute exists and convert string to symbol for hash key
  55. 14 acceptable_attribute_map = self.class.acceptable_attribute_map
  56. 14 attributes = attributes.each_with_object({}) { |(k, v), h|
  57. 40 if (!acceptable_attribute_map.key?(k.to_sym))
  58. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::AdditionalDenialReason`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  59. end
  60. 39 h[k.to_sym] = v
  61. }
  62. 13 if attributes.key?(:'status_code')
  63. 13 self.status_code = attributes[:'status_code']
  64. else
  65. self.status_code = nil
  66. end
  67. 12 if attributes.key?(:'reason')
  68. 12 self.reason = attributes[:'reason']
  69. else
  70. self.reason = nil
  71. end
  72. 11 if attributes.key?(:'resubmit_allowed')
  73. 11 self.resubmit_allowed = attributes[:'resubmit_allowed']
  74. else
  75. self.resubmit_allowed = nil
  76. end
  77. end
  78. # Show invalid properties with the reasons. Usually used together with valid?
  79. # @return Array for valid properties with the reasons
  80. 1 def list_invalid_properties
  81. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  82. invalid_properties = Array.new
  83. if @status_code.nil?
  84. invalid_properties.push('invalid value for "status_code", status_code cannot be nil.')
  85. end
  86. if @reason.nil?
  87. invalid_properties.push('invalid value for "reason", reason cannot be nil.')
  88. end
  89. if @resubmit_allowed.nil?
  90. invalid_properties.push('invalid value for "resubmit_allowed", resubmit_allowed cannot be nil.')
  91. end
  92. invalid_properties
  93. end
  94. # Check to see if the all the properties in the model are valid
  95. # @return true if the model is valid
  96. 1 def valid?
  97. warn '[DEPRECATED] the `valid?` method is obsolete'
  98. return false if @status_code.nil?
  99. return false if @reason.nil?
  100. return false if @resubmit_allowed.nil?
  101. true
  102. end
  103. # Custom attribute writer method with validation
  104. # @param [Object] status_code Value to be assigned
  105. 1 def status_code=(status_code)
  106. 13 if status_code.nil?
  107. 1 fail ArgumentError, 'status_code cannot be nil'
  108. end
  109. 12 @status_code = status_code
  110. end
  111. # Custom attribute writer method with validation
  112. # @param [Object] reason Value to be assigned
  113. 1 def reason=(reason)
  114. 12 if reason.nil?
  115. 1 fail ArgumentError, 'reason cannot be nil'
  116. end
  117. 11 @reason = reason
  118. end
  119. # Custom attribute writer method with validation
  120. # @param [Object] resubmit_allowed Value to be assigned
  121. 1 def resubmit_allowed=(resubmit_allowed)
  122. 11 if resubmit_allowed.nil?
  123. 1 fail ArgumentError, 'resubmit_allowed cannot be nil'
  124. end
  125. 10 @resubmit_allowed = resubmit_allowed
  126. end
  127. # Checks equality by comparing each attribute.
  128. # @param [Object] Object to be compared
  129. 1 def ==(o)
  130. 2 return true if self.equal?(o)
  131. 2 self.class == o.class &&
  132. status_code == o.status_code &&
  133. reason == o.reason &&
  134. resubmit_allowed == o.resubmit_allowed
  135. end
  136. # @see the `==` method
  137. # @param [Object] Object to be compared
  138. 1 def eql?(o)
  139. 2 self == o
  140. end
  141. # Calculates hash code according to all attributes.
  142. # @return [Integer] Hash code
  143. 1 def hash
  144. [status_code, reason, resubmit_allowed].hash
  145. end
  146. # Builds the object from hash
  147. # @param [Hash] attributes Model attributes in the form of hash
  148. # @return [Object] Returns the model itself
  149. 1 def self.build_from_hash(attributes)
  150. 2 return nil unless attributes.is_a?(Hash)
  151. 2 attributes = attributes.transform_keys(&:to_sym)
  152. 2 transformed_hash = {}
  153. 2 openapi_types.each_pair do |key, type|
  154. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  155. transformed_hash["#{key}"] = nil
  156. 6 elsif type =~ /\AArray<(.*)>/i
  157. # check to ensure the input is an array given that the attribute
  158. # is documented as an array but the input is not
  159. if attributes[attribute_map[key]].is_a?(Array)
  160. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  161. end
  162. 6 elsif !attributes[attribute_map[key]].nil?
  163. 6 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  164. end
  165. end
  166. 2 new(transformed_hash)
  167. end
  168. # Returns the object in the form of hash
  169. # @return [Hash] Returns the object in the form of hash
  170. 1 def to_hash
  171. 4 hash = {}
  172. 4 self.class.attribute_map.each_pair do |attr, param|
  173. 12 value = self.send(attr)
  174. 12 if value.nil?
  175. is_nullable = self.class.openapi_nullable.include?(attr)
  176. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  177. end
  178. 12 hash[param] = _to_hash(value)
  179. end
  180. 4 hash
  181. end
  182. end
  183. end

lib/bandwidth-sdk/models/address.rb

60.71% lines covered

196 relevant lines. 119 lines covered and 77 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class Address < ApiModelBase
  13. # The name of the business using the toll-free number.
  14. 1 attr_accessor :name
  15. # The address of the business using the toll-free number.
  16. 1 attr_accessor :addr1
  17. # The address of the business using the toll-free number.
  18. 1 attr_accessor :addr2
  19. # The city of the business using the toll-free number.
  20. 1 attr_accessor :city
  21. # The state of the business using the toll-free number.
  22. 1 attr_accessor :state
  23. # The zip of the business using the toll-free number.
  24. 1 attr_accessor :zip
  25. # The website of the business using the toll-free number.
  26. 1 attr_accessor :url
  27. # Attribute mapping from ruby-style variable name to JSON key.
  28. 1 def self.attribute_map
  29. 224 {
  30. :'name' => :'name',
  31. :'addr1' => :'addr1',
  32. :'addr2' => :'addr2',
  33. :'city' => :'city',
  34. :'state' => :'state',
  35. :'zip' => :'zip',
  36. :'url' => :'url'
  37. }
  38. end
  39. # Returns attribute mapping this model knows about
  40. 1 def self.acceptable_attribute_map
  41. 33 attribute_map
  42. end
  43. # Returns all the JSON keys this model knows about
  44. 1 def self.acceptable_attributes
  45. 1 acceptable_attribute_map.values
  46. end
  47. # Attribute type mapping.
  48. 1 def self.openapi_types
  49. 7 {
  50. :'name' => :'String',
  51. :'addr1' => :'String',
  52. :'addr2' => :'String',
  53. :'city' => :'String',
  54. :'state' => :'String',
  55. :'zip' => :'String',
  56. :'url' => :'String'
  57. }
  58. end
  59. # List of attributes with nullable: true
  60. 1 def self.openapi_nullable
  61. 1 Set.new([
  62. :'addr2',
  63. ])
  64. end
  65. # Initializes the object
  66. # @param [Hash] attributes Model attributes in the form of hash
  67. 1 def initialize(attributes = {})
  68. 33 if (!attributes.is_a?(Hash))
  69. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::Address` initialize method'
  70. end
  71. # check to see if the attribute exists and convert string to symbol for hash key
  72. 32 acceptable_attribute_map = self.class.acceptable_attribute_map
  73. 32 attributes = attributes.each_with_object({}) { |(k, v), h|
  74. 152 if (!acceptable_attribute_map.key?(k.to_sym))
  75. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::Address`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  76. end
  77. 151 h[k.to_sym] = v
  78. }
  79. 31 if attributes.key?(:'name')
  80. 31 self.name = attributes[:'name']
  81. else
  82. self.name = nil
  83. end
  84. 28 if attributes.key?(:'addr1')
  85. 28 self.addr1 = attributes[:'addr1']
  86. else
  87. self.addr1 = nil
  88. end
  89. 25 if attributes.key?(:'addr2')
  90. 8 self.addr2 = attributes[:'addr2']
  91. end
  92. 24 if attributes.key?(:'city')
  93. 24 self.city = attributes[:'city']
  94. else
  95. self.city = nil
  96. end
  97. 21 if attributes.key?(:'state')
  98. 21 self.state = attributes[:'state']
  99. else
  100. self.state = nil
  101. end
  102. 18 if attributes.key?(:'zip')
  103. 18 self.zip = attributes[:'zip']
  104. else
  105. self.zip = nil
  106. end
  107. 17 if attributes.key?(:'url')
  108. 17 self.url = attributes[:'url']
  109. else
  110. self.url = nil
  111. end
  112. end
  113. # Show invalid properties with the reasons. Usually used together with valid?
  114. # @return Array for valid properties with the reasons
  115. 1 def list_invalid_properties
  116. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  117. invalid_properties = Array.new
  118. if @name.nil?
  119. invalid_properties.push('invalid value for "name", name cannot be nil.')
  120. end
  121. if @name.to_s.length > 500
  122. invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 500.')
  123. end
  124. if @name.to_s.length < 1
  125. invalid_properties.push('invalid value for "name", the character length must be greater than or equal to 1.')
  126. end
  127. if @addr1.nil?
  128. invalid_properties.push('invalid value for "addr1", addr1 cannot be nil.')
  129. end
  130. if @addr1.to_s.length > 500
  131. invalid_properties.push('invalid value for "addr1", the character length must be smaller than or equal to 500.')
  132. end
  133. if @addr1.to_s.length < 1
  134. invalid_properties.push('invalid value for "addr1", the character length must be greater than or equal to 1.')
  135. end
  136. if !@addr2.nil? && @addr2.to_s.length > 500
  137. invalid_properties.push('invalid value for "addr2", the character length must be smaller than or equal to 500.')
  138. end
  139. if !@addr2.nil? && @addr2.to_s.length < 0
  140. invalid_properties.push('invalid value for "addr2", the character length must be greater than or equal to 0.')
  141. end
  142. if @city.nil?
  143. invalid_properties.push('invalid value for "city", city cannot be nil.')
  144. end
  145. if @city.to_s.length > 500
  146. invalid_properties.push('invalid value for "city", the character length must be smaller than or equal to 500.')
  147. end
  148. if @city.to_s.length < 1
  149. invalid_properties.push('invalid value for "city", the character length must be greater than or equal to 1.')
  150. end
  151. if @state.nil?
  152. invalid_properties.push('invalid value for "state", state cannot be nil.')
  153. end
  154. if @state.to_s.length > 500
  155. invalid_properties.push('invalid value for "state", the character length must be smaller than or equal to 500.')
  156. end
  157. if @state.to_s.length < 1
  158. invalid_properties.push('invalid value for "state", the character length must be greater than or equal to 1.')
  159. end
  160. if @zip.nil?
  161. invalid_properties.push('invalid value for "zip", zip cannot be nil.')
  162. end
  163. pattern = Regexp.new(/[- A-Za-z0-9]{0,500}/)
  164. if @zip !~ pattern
  165. invalid_properties.push("invalid value for \"zip\", must conform to the pattern #{pattern}.")
  166. end
  167. if @url.nil?
  168. invalid_properties.push('invalid value for "url", url cannot be nil.')
  169. end
  170. if @url.to_s.length > 500
  171. invalid_properties.push('invalid value for "url", the character length must be smaller than or equal to 500.')
  172. end
  173. if @url.to_s.length < 1
  174. invalid_properties.push('invalid value for "url", the character length must be greater than or equal to 1.')
  175. end
  176. invalid_properties
  177. end
  178. # Check to see if the all the properties in the model are valid
  179. # @return true if the model is valid
  180. 1 def valid?
  181. warn '[DEPRECATED] the `valid?` method is obsolete'
  182. return false if @name.nil?
  183. return false if @name.to_s.length > 500
  184. return false if @name.to_s.length < 1
  185. return false if @addr1.nil?
  186. return false if @addr1.to_s.length > 500
  187. return false if @addr1.to_s.length < 1
  188. return false if !@addr2.nil? && @addr2.to_s.length > 500
  189. return false if !@addr2.nil? && @addr2.to_s.length < 0
  190. return false if @city.nil?
  191. return false if @city.to_s.length > 500
  192. return false if @city.to_s.length < 1
  193. return false if @state.nil?
  194. return false if @state.to_s.length > 500
  195. return false if @state.to_s.length < 1
  196. return false if @zip.nil?
  197. return false if @zip !~ Regexp.new(/[- A-Za-z0-9]{0,500}/)
  198. return false if @url.nil?
  199. return false if @url.to_s.length > 500
  200. return false if @url.to_s.length < 1
  201. true
  202. end
  203. # Custom attribute writer method with validation
  204. # @param [Object] name Value to be assigned
  205. 1 def name=(name)
  206. 31 if name.nil?
  207. 1 fail ArgumentError, 'name cannot be nil'
  208. end
  209. 30 if name.to_s.length > 500
  210. 1 fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 500.'
  211. end
  212. 29 if name.to_s.length < 1
  213. 1 fail ArgumentError, 'invalid value for "name", the character length must be greater than or equal to 1.'
  214. end
  215. 28 @name = name
  216. end
  217. # Custom attribute writer method with validation
  218. # @param [Object] addr1 Value to be assigned
  219. 1 def addr1=(addr1)
  220. 28 if addr1.nil?
  221. 1 fail ArgumentError, 'addr1 cannot be nil'
  222. end
  223. 27 if addr1.to_s.length > 500
  224. 1 fail ArgumentError, 'invalid value for "addr1", the character length must be smaller than or equal to 500.'
  225. end
  226. 26 if addr1.to_s.length < 1
  227. 1 fail ArgumentError, 'invalid value for "addr1", the character length must be greater than or equal to 1.'
  228. end
  229. 25 @addr1 = addr1
  230. end
  231. # Custom attribute writer method with validation
  232. # @param [Object] addr2 Value to be assigned
  233. 1 def addr2=(addr2)
  234. 8 if !addr2.nil? && addr2.to_s.length > 500
  235. 1 fail ArgumentError, 'invalid value for "addr2", the character length must be smaller than or equal to 500.'
  236. end
  237. 7 if !addr2.nil? && addr2.to_s.length < 0
  238. fail ArgumentError, 'invalid value for "addr2", the character length must be greater than or equal to 0.'
  239. end
  240. 7 @addr2 = addr2
  241. end
  242. # Custom attribute writer method with validation
  243. # @param [Object] city Value to be assigned
  244. 1 def city=(city)
  245. 24 if city.nil?
  246. 1 fail ArgumentError, 'city cannot be nil'
  247. end
  248. 23 if city.to_s.length > 500
  249. 1 fail ArgumentError, 'invalid value for "city", the character length must be smaller than or equal to 500.'
  250. end
  251. 22 if city.to_s.length < 1
  252. 1 fail ArgumentError, 'invalid value for "city", the character length must be greater than or equal to 1.'
  253. end
  254. 21 @city = city
  255. end
  256. # Custom attribute writer method with validation
  257. # @param [Object] state Value to be assigned
  258. 1 def state=(state)
  259. 21 if state.nil?
  260. 1 fail ArgumentError, 'state cannot be nil'
  261. end
  262. 20 if state.to_s.length > 500
  263. 1 fail ArgumentError, 'invalid value for "state", the character length must be smaller than or equal to 500.'
  264. end
  265. 19 if state.to_s.length < 1
  266. 1 fail ArgumentError, 'invalid value for "state", the character length must be greater than or equal to 1.'
  267. end
  268. 18 @state = state
  269. end
  270. # Custom attribute writer method with validation
  271. # @param [Object] zip Value to be assigned
  272. 1 def zip=(zip)
  273. 18 if zip.nil?
  274. 1 fail ArgumentError, 'zip cannot be nil'
  275. end
  276. 17 pattern = Regexp.new(/[- A-Za-z0-9]{0,500}/)
  277. 17 if zip !~ pattern
  278. fail ArgumentError, "invalid value for \"zip\", must conform to the pattern #{pattern}."
  279. end
  280. 17 @zip = zip
  281. end
  282. # Custom attribute writer method with validation
  283. # @param [Object] url Value to be assigned
  284. 1 def url=(url)
  285. 17 if url.nil?
  286. 1 fail ArgumentError, 'url cannot be nil'
  287. end
  288. 16 if url.to_s.length > 500
  289. 1 fail ArgumentError, 'invalid value for "url", the character length must be smaller than or equal to 500.'
  290. end
  291. 15 if url.to_s.length < 1
  292. 1 fail ArgumentError, 'invalid value for "url", the character length must be greater than or equal to 1.'
  293. end
  294. 14 @url = url
  295. end
  296. # Checks equality by comparing each attribute.
  297. # @param [Object] Object to be compared
  298. 1 def ==(o)
  299. 2 return true if self.equal?(o)
  300. 2 self.class == o.class &&
  301. name == o.name &&
  302. addr1 == o.addr1 &&
  303. addr2 == o.addr2 &&
  304. city == o.city &&
  305. state == o.state &&
  306. zip == o.zip &&
  307. url == o.url
  308. end
  309. # @see the `==` method
  310. # @param [Object] Object to be compared
  311. 1 def eql?(o)
  312. 2 self == o
  313. end
  314. # Calculates hash code according to all attributes.
  315. # @return [Integer] Hash code
  316. 1 def hash
  317. [name, addr1, addr2, city, state, zip, url].hash
  318. end
  319. # Builds the object from hash
  320. # @param [Hash] attributes Model attributes in the form of hash
  321. # @return [Object] Returns the model itself
  322. 1 def self.build_from_hash(attributes)
  323. 7 return nil unless attributes.is_a?(Hash)
  324. 7 attributes = attributes.transform_keys(&:to_sym)
  325. 7 transformed_hash = {}
  326. 7 openapi_types.each_pair do |key, type|
  327. 49 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  328. transformed_hash["#{key}"] = nil
  329. 49 elsif type =~ /\AArray<(.*)>/i
  330. # check to ensure the input is an array given that the attribute
  331. # is documented as an array but the input is not
  332. if attributes[attribute_map[key]].is_a?(Array)
  333. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  334. end
  335. 49 elsif !attributes[attribute_map[key]].nil?
  336. 44 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  337. end
  338. end
  339. 7 new(transformed_hash)
  340. end
  341. # Returns the object in the form of hash
  342. # @return [Hash] Returns the object in the form of hash
  343. 1 def to_hash
  344. 4 hash = {}
  345. 4 self.class.attribute_map.each_pair do |attr, param|
  346. 28 value = self.send(attr)
  347. 28 if value.nil?
  348. is_nullable = self.class.openapi_nullable.include?(attr)
  349. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  350. end
  351. 28 hash[param] = _to_hash(value)
  352. end
  353. 4 hash
  354. end
  355. end
  356. end

lib/bandwidth-sdk/models/answer_callback.rb

84.68% lines covered

111 relevant lines. 94 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The Answer event is sent to the answerUrl specified in the createCall request when an outbound call is answered.
  13. 1 class AnswerCallback < ApiModelBase
  14. # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect.
  15. 1 attr_accessor :event_type
  16. # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.
  17. 1 attr_accessor :event_time
  18. # The user account associated with the call.
  19. 1 attr_accessor :account_id
  20. # The id of the application associated with the call.
  21. 1 attr_accessor :application_id
  22. # The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555).
  23. 1 attr_accessor :from
  24. # The phone number that received the call, in E.164 format (e.g. +15555555555).
  25. 1 attr_accessor :to
  26. 1 attr_accessor :direction
  27. # The call id associated with the event.
  28. 1 attr_accessor :call_id
  29. # The URL of the call associated with the event.
  30. 1 attr_accessor :call_url
  31. # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format.
  32. 1 attr_accessor :enqueued_time
  33. # Time the call was started, in ISO 8601 format.
  34. 1 attr_accessor :start_time
  35. # Time the call was answered, in ISO 8601 format.
  36. 1 attr_accessor :answer_time
  37. # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.
  38. 1 attr_accessor :tag
  39. 1 attr_accessor :machine_detection_result
  40. 1 class EnumAttributeValidator
  41. 1 attr_reader :datatype
  42. 1 attr_reader :allowable_values
  43. 1 def initialize(datatype, allowable_values)
  44. @allowable_values = allowable_values.map do |value|
  45. case datatype.to_s
  46. when /Integer/i
  47. value.to_i
  48. when /Float/i
  49. value.to_f
  50. else
  51. value
  52. end
  53. end
  54. end
  55. 1 def valid?(value)
  56. !value || allowable_values.include?(value)
  57. end
  58. end
  59. # Attribute mapping from ruby-style variable name to JSON key.
  60. 1 def self.attribute_map
  61. 67 {
  62. :'event_type' => :'eventType',
  63. :'event_time' => :'eventTime',
  64. :'account_id' => :'accountId',
  65. :'application_id' => :'applicationId',
  66. :'from' => :'from',
  67. :'to' => :'to',
  68. :'direction' => :'direction',
  69. :'call_id' => :'callId',
  70. :'call_url' => :'callUrl',
  71. :'enqueued_time' => :'enqueuedTime',
  72. :'start_time' => :'startTime',
  73. :'answer_time' => :'answerTime',
  74. :'tag' => :'tag',
  75. :'machine_detection_result' => :'machineDetectionResult'
  76. }
  77. end
  78. # Returns attribute mapping this model knows about
  79. 1 def self.acceptable_attribute_map
  80. 8 attribute_map
  81. end
  82. # Returns all the JSON keys this model knows about
  83. 1 def self.acceptable_attributes
  84. 1 acceptable_attribute_map.values
  85. end
  86. # Attribute type mapping.
  87. 1 def self.openapi_types
  88. 1 {
  89. :'event_type' => :'String',
  90. :'event_time' => :'Time',
  91. :'account_id' => :'String',
  92. :'application_id' => :'String',
  93. :'from' => :'String',
  94. :'to' => :'String',
  95. :'direction' => :'CallDirectionEnum',
  96. :'call_id' => :'String',
  97. :'call_url' => :'String',
  98. :'enqueued_time' => :'Time',
  99. :'start_time' => :'Time',
  100. :'answer_time' => :'Time',
  101. :'tag' => :'String',
  102. :'machine_detection_result' => :'MachineDetectionResult'
  103. }
  104. end
  105. # List of attributes with nullable: true
  106. 1 def self.openapi_nullable
  107. 1 Set.new([
  108. :'enqueued_time',
  109. :'answer_time',
  110. :'tag',
  111. :'machine_detection_result'
  112. ])
  113. end
  114. # Initializes the object
  115. # @param [Hash] attributes Model attributes in the form of hash
  116. 1 def initialize(attributes = {})
  117. 8 if (!attributes.is_a?(Hash))
  118. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::AnswerCallback` initialize method'
  119. end
  120. # check to see if the attribute exists and convert string to symbol for hash key
  121. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  122. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  123. 57 if (!acceptable_attribute_map.key?(k.to_sym))
  124. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::AnswerCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  125. end
  126. 56 h[k.to_sym] = v
  127. }
  128. 6 if attributes.key?(:'event_type')
  129. 4 self.event_type = attributes[:'event_type']
  130. end
  131. 6 if attributes.key?(:'event_time')
  132. 4 self.event_time = attributes[:'event_time']
  133. end
  134. 6 if attributes.key?(:'account_id')
  135. 4 self.account_id = attributes[:'account_id']
  136. end
  137. 6 if attributes.key?(:'application_id')
  138. 4 self.application_id = attributes[:'application_id']
  139. end
  140. 6 if attributes.key?(:'from')
  141. 4 self.from = attributes[:'from']
  142. end
  143. 6 if attributes.key?(:'to')
  144. 4 self.to = attributes[:'to']
  145. end
  146. 6 if attributes.key?(:'direction')
  147. 4 self.direction = attributes[:'direction']
  148. end
  149. 6 if attributes.key?(:'call_id')
  150. 4 self.call_id = attributes[:'call_id']
  151. end
  152. 6 if attributes.key?(:'call_url')
  153. 4 self.call_url = attributes[:'call_url']
  154. end
  155. 6 if attributes.key?(:'enqueued_time')
  156. 4 self.enqueued_time = attributes[:'enqueued_time']
  157. end
  158. 6 if attributes.key?(:'start_time')
  159. 4 self.start_time = attributes[:'start_time']
  160. end
  161. 6 if attributes.key?(:'answer_time')
  162. 4 self.answer_time = attributes[:'answer_time']
  163. end
  164. 6 if attributes.key?(:'tag')
  165. 4 self.tag = attributes[:'tag']
  166. end
  167. 6 if attributes.key?(:'machine_detection_result')
  168. 4 self.machine_detection_result = attributes[:'machine_detection_result']
  169. end
  170. end
  171. # Show invalid properties with the reasons. Usually used together with valid?
  172. # @return Array for valid properties with the reasons
  173. 1 def list_invalid_properties
  174. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  175. invalid_properties = Array.new
  176. invalid_properties
  177. end
  178. # Check to see if the all the properties in the model are valid
  179. # @return true if the model is valid
  180. 1 def valid?
  181. warn '[DEPRECATED] the `valid?` method is obsolete'
  182. true
  183. end
  184. # Checks equality by comparing each attribute.
  185. # @param [Object] Object to be compared
  186. 1 def ==(o)
  187. 2 return true if self.equal?(o)
  188. 2 self.class == o.class &&
  189. event_type == o.event_type &&
  190. event_time == o.event_time &&
  191. account_id == o.account_id &&
  192. application_id == o.application_id &&
  193. from == o.from &&
  194. to == o.to &&
  195. direction == o.direction &&
  196. call_id == o.call_id &&
  197. call_url == o.call_url &&
  198. enqueued_time == o.enqueued_time &&
  199. start_time == o.start_time &&
  200. answer_time == o.answer_time &&
  201. tag == o.tag &&
  202. machine_detection_result == o.machine_detection_result
  203. end
  204. # @see the `==` method
  205. # @param [Object] Object to be compared
  206. 1 def eql?(o)
  207. 2 self == o
  208. end
  209. # Calculates hash code according to all attributes.
  210. # @return [Integer] Hash code
  211. 1 def hash
  212. [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, enqueued_time, start_time, answer_time, tag, machine_detection_result].hash
  213. end
  214. # Builds the object from hash
  215. # @param [Hash] attributes Model attributes in the form of hash
  216. # @return [Object] Returns the model itself
  217. 1 def self.build_from_hash(attributes)
  218. 1 return nil unless attributes.is_a?(Hash)
  219. 1 attributes = attributes.transform_keys(&:to_sym)
  220. 1 transformed_hash = {}
  221. 1 openapi_types.each_pair do |key, type|
  222. 14 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  223. transformed_hash["#{key}"] = nil
  224. 14 elsif type =~ /\AArray<(.*)>/i
  225. # check to ensure the input is an array given that the attribute
  226. # is documented as an array but the input is not
  227. if attributes[attribute_map[key]].is_a?(Array)
  228. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  229. end
  230. 14 elsif !attributes[attribute_map[key]].nil?
  231. 14 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  232. end
  233. end
  234. 1 new(transformed_hash)
  235. end
  236. # Returns the object in the form of hash
  237. # @return [Hash] Returns the object in the form of hash
  238. 1 def to_hash
  239. 2 hash = {}
  240. 2 self.class.attribute_map.each_pair do |attr, param|
  241. 28 value = self.send(attr)
  242. 28 if value.nil?
  243. is_nullable = self.class.openapi_nullable.include?(attr)
  244. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  245. end
  246. 28 hash[param] = _to_hash(value)
  247. end
  248. 2 hash
  249. end
  250. end
  251. end

lib/bandwidth-sdk/models/async_lookup_request.rb

78.57% lines covered

70 relevant lines. 55 lines covered and 15 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class AsyncLookupRequest < ApiModelBase
  13. # Telephone numbers in E.164 format.
  14. 1 attr_accessor :phone_numbers
  15. # Attribute mapping from ruby-style variable name to JSON key.
  16. 1 def self.attribute_map
  17. 19 {
  18. :'phone_numbers' => :'phoneNumbers'
  19. }
  20. end
  21. # Returns attribute mapping this model knows about
  22. 1 def self.acceptable_attribute_map
  23. 11 attribute_map
  24. end
  25. # Returns all the JSON keys this model knows about
  26. 1 def self.acceptable_attributes
  27. 1 acceptable_attribute_map.values
  28. end
  29. # Attribute type mapping.
  30. 1 def self.openapi_types
  31. 1 {
  32. :'phone_numbers' => :'Array<String>'
  33. }
  34. end
  35. # List of attributes with nullable: true
  36. 1 def self.openapi_nullable
  37. 1 Set.new([
  38. ])
  39. end
  40. # Initializes the object
  41. # @param [Hash] attributes Model attributes in the form of hash
  42. 1 def initialize(attributes = {})
  43. 11 if (!attributes.is_a?(Hash))
  44. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::AsyncLookupRequest` initialize method'
  45. end
  46. # check to see if the attribute exists and convert string to symbol for hash key
  47. 10 acceptable_attribute_map = self.class.acceptable_attribute_map
  48. 10 attributes = attributes.each_with_object({}) { |(k, v), h|
  49. 10 if (!acceptable_attribute_map.key?(k.to_sym))
  50. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::AsyncLookupRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  51. end
  52. 9 h[k.to_sym] = v
  53. }
  54. 9 if attributes.key?(:'phone_numbers')
  55. 9 if (value = attributes[:'phone_numbers']).is_a?(Array)
  56. 9 self.phone_numbers = value
  57. end
  58. else
  59. self.phone_numbers = nil
  60. end
  61. end
  62. # Show invalid properties with the reasons. Usually used together with valid?
  63. # @return Array for valid properties with the reasons
  64. 1 def list_invalid_properties
  65. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  66. invalid_properties = Array.new
  67. if @phone_numbers.nil?
  68. invalid_properties.push('invalid value for "phone_numbers", phone_numbers cannot be nil.')
  69. end
  70. invalid_properties
  71. end
  72. # Check to see if the all the properties in the model are valid
  73. # @return true if the model is valid
  74. 1 def valid?
  75. warn '[DEPRECATED] the `valid?` method is obsolete'
  76. return false if @phone_numbers.nil?
  77. true
  78. end
  79. # Custom attribute writer method with validation
  80. # @param [Object] phone_numbers Value to be assigned
  81. 1 def phone_numbers=(phone_numbers)
  82. 10 if phone_numbers.nil?
  83. 1 fail ArgumentError, 'phone_numbers cannot be nil'
  84. end
  85. 9 @phone_numbers = phone_numbers
  86. end
  87. # Checks equality by comparing each attribute.
  88. # @param [Object] Object to be compared
  89. 1 def ==(o)
  90. 2 return true if self.equal?(o)
  91. 2 self.class == o.class &&
  92. phone_numbers == o.phone_numbers
  93. end
  94. # @see the `==` method
  95. # @param [Object] Object to be compared
  96. 1 def eql?(o)
  97. 2 self == o
  98. end
  99. # Calculates hash code according to all attributes.
  100. # @return [Integer] Hash code
  101. 1 def hash
  102. [phone_numbers].hash
  103. end
  104. # Builds the object from hash
  105. # @param [Hash] attributes Model attributes in the form of hash
  106. # @return [Object] Returns the model itself
  107. 1 def self.build_from_hash(attributes)
  108. 1 return nil unless attributes.is_a?(Hash)
  109. 1 attributes = attributes.transform_keys(&:to_sym)
  110. 1 transformed_hash = {}
  111. 1 openapi_types.each_pair do |key, type|
  112. 1 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  113. transformed_hash["#{key}"] = nil
  114. 1 elsif type =~ /\AArray<(.*)>/i
  115. # check to ensure the input is an array given that the attribute
  116. # is documented as an array but the input is not
  117. 1 if attributes[attribute_map[key]].is_a?(Array)
  118. 3 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  119. end
  120. elsif !attributes[attribute_map[key]].nil?
  121. transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  122. end
  123. end
  124. 1 new(transformed_hash)
  125. end
  126. # Returns the object in the form of hash
  127. # @return [Hash] Returns the object in the form of hash
  128. 1 def to_hash
  129. 3 hash = {}
  130. 3 self.class.attribute_map.each_pair do |attr, param|
  131. 3 value = self.send(attr)
  132. 3 if value.nil?
  133. is_nullable = self.class.openapi_nullable.include?(attr)
  134. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  135. end
  136. 3 hash[param] = _to_hash(value)
  137. end
  138. 3 hash
  139. end
  140. end
  141. end

lib/bandwidth-sdk/models/blocked_webhook.rb

75.0% lines covered

108 relevant lines. 81 lines covered and 27 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class BlockedWebhook < ApiModelBase
  13. # User's account ID.
  14. 1 attr_accessor :account_id
  15. # Toll-free telephone number in E.164 format.
  16. 1 attr_accessor :phone_number
  17. 1 attr_accessor :status
  18. # Unique identifier (UUID) generated by Bandwidth to assist in tracking the verification status of a toll-free number.
  19. 1 attr_accessor :internal_ticket_number
  20. # Whether a Toll-Free Verification is blocked. This attribute will only be defined when the number is blocked.
  21. 1 attr_accessor :blocked
  22. # The reason why the Toll-Free Verification is blocked. This attribute will only be defined when the number is blocked.
  23. 1 attr_accessor :blocked_reason
  24. 1 class EnumAttributeValidator
  25. 1 attr_reader :datatype
  26. 1 attr_reader :allowable_values
  27. 1 def initialize(datatype, allowable_values)
  28. @allowable_values = allowable_values.map do |value|
  29. case datatype.to_s
  30. when /Integer/i
  31. value.to_i
  32. when /Float/i
  33. value.to_f
  34. else
  35. value
  36. end
  37. end
  38. end
  39. 1 def valid?(value)
  40. !value || allowable_values.include?(value)
  41. end
  42. end
  43. # Attribute mapping from ruby-style variable name to JSON key.
  44. 1 def self.attribute_map
  45. 39 {
  46. :'account_id' => :'accountId',
  47. :'phone_number' => :'phoneNumber',
  48. :'status' => :'status',
  49. :'internal_ticket_number' => :'internalTicketNumber',
  50. :'blocked' => :'blocked',
  51. :'blocked_reason' => :'blockedReason'
  52. }
  53. end
  54. # Returns attribute mapping this model knows about
  55. 1 def self.acceptable_attribute_map
  56. 12 attribute_map
  57. end
  58. # Returns all the JSON keys this model knows about
  59. 1 def self.acceptable_attributes
  60. 1 acceptable_attribute_map.values
  61. end
  62. # Attribute type mapping.
  63. 1 def self.openapi_types
  64. 1 {
  65. :'account_id' => :'String',
  66. :'phone_number' => :'String',
  67. :'status' => :'TfvCallbackStatusEnum',
  68. :'internal_ticket_number' => :'String',
  69. :'blocked' => :'Boolean',
  70. :'blocked_reason' => :'String'
  71. }
  72. end
  73. # List of attributes with nullable: true
  74. 1 def self.openapi_nullable
  75. 1 Set.new([
  76. ])
  77. end
  78. # Initializes the object
  79. # @param [Hash] attributes Model attributes in the form of hash
  80. 1 def initialize(attributes = {})
  81. 12 if (!attributes.is_a?(Hash))
  82. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::BlockedWebhook` initialize method'
  83. end
  84. # check to see if the attribute exists and convert string to symbol for hash key
  85. 11 acceptable_attribute_map = self.class.acceptable_attribute_map
  86. 11 attributes = attributes.each_with_object({}) { |(k, v), h|
  87. 29 if (!acceptable_attribute_map.key?(k.to_sym))
  88. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::BlockedWebhook`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  89. end
  90. 28 h[k.to_sym] = v
  91. }
  92. 10 if attributes.key?(:'account_id')
  93. 4 self.account_id = attributes[:'account_id']
  94. end
  95. 10 if attributes.key?(:'phone_number')
  96. 8 self.phone_number = attributes[:'phone_number']
  97. end
  98. 6 if attributes.key?(:'status')
  99. 4 self.status = attributes[:'status']
  100. end
  101. 6 if attributes.key?(:'internal_ticket_number')
  102. 4 self.internal_ticket_number = attributes[:'internal_ticket_number']
  103. end
  104. 6 if attributes.key?(:'blocked')
  105. 4 self.blocked = attributes[:'blocked']
  106. end
  107. 6 if attributes.key?(:'blocked_reason')
  108. 4 self.blocked_reason = attributes[:'blocked_reason']
  109. end
  110. end
  111. # Show invalid properties with the reasons. Usually used together with valid?
  112. # @return Array for valid properties with the reasons
  113. 1 def list_invalid_properties
  114. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  115. invalid_properties = Array.new
  116. if !@phone_number.nil? && @phone_number.to_s.length > 12
  117. invalid_properties.push('invalid value for "phone_number", the character length must be smaller than or equal to 12.')
  118. end
  119. if !@phone_number.nil? && @phone_number.to_s.length < 12
  120. invalid_properties.push('invalid value for "phone_number", the character length must be greater than or equal to 12.')
  121. end
  122. pattern = Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
  123. if !@phone_number.nil? && @phone_number !~ pattern
  124. invalid_properties.push("invalid value for \"phone_number\", must conform to the pattern #{pattern}.")
  125. end
  126. invalid_properties
  127. end
  128. # Check to see if the all the properties in the model are valid
  129. # @return true if the model is valid
  130. 1 def valid?
  131. warn '[DEPRECATED] the `valid?` method is obsolete'
  132. return false if !@phone_number.nil? && @phone_number.to_s.length > 12
  133. return false if !@phone_number.nil? && @phone_number.to_s.length < 12
  134. return false if !@phone_number.nil? && @phone_number !~ Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
  135. true
  136. end
  137. # Custom attribute writer method with validation
  138. # @param [Object] phone_number Value to be assigned
  139. 1 def phone_number=(phone_number)
  140. 8 if phone_number.nil?
  141. 1 fail ArgumentError, 'phone_number cannot be nil'
  142. end
  143. 7 if phone_number.to_s.length > 12
  144. 1 fail ArgumentError, 'invalid value for "phone_number", the character length must be smaller than or equal to 12.'
  145. end
  146. 6 if phone_number.to_s.length < 12
  147. 1 fail ArgumentError, 'invalid value for "phone_number", the character length must be greater than or equal to 12.'
  148. end
  149. 5 pattern = Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
  150. 5 if phone_number !~ pattern
  151. 1 fail ArgumentError, "invalid value for \"phone_number\", must conform to the pattern #{pattern}."
  152. end
  153. 4 @phone_number = phone_number
  154. end
  155. # Checks equality by comparing each attribute.
  156. # @param [Object] Object to be compared
  157. 1 def ==(o)
  158. 2 return true if self.equal?(o)
  159. 2 self.class == o.class &&
  160. account_id == o.account_id &&
  161. phone_number == o.phone_number &&
  162. status == o.status &&
  163. internal_ticket_number == o.internal_ticket_number &&
  164. blocked == o.blocked &&
  165. blocked_reason == o.blocked_reason
  166. end
  167. # @see the `==` method
  168. # @param [Object] Object to be compared
  169. 1 def eql?(o)
  170. 2 self == o
  171. end
  172. # Calculates hash code according to all attributes.
  173. # @return [Integer] Hash code
  174. 1 def hash
  175. [account_id, phone_number, status, internal_ticket_number, blocked, blocked_reason].hash
  176. end
  177. # Builds the object from hash
  178. # @param [Hash] attributes Model attributes in the form of hash
  179. # @return [Object] Returns the model itself
  180. 1 def self.build_from_hash(attributes)
  181. 1 return nil unless attributes.is_a?(Hash)
  182. 1 attributes = attributes.transform_keys(&:to_sym)
  183. 1 transformed_hash = {}
  184. 1 openapi_types.each_pair do |key, type|
  185. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  186. transformed_hash["#{key}"] = nil
  187. 6 elsif type =~ /\AArray<(.*)>/i
  188. # check to ensure the input is an array given that the attribute
  189. # is documented as an array but the input is not
  190. if attributes[attribute_map[key]].is_a?(Array)
  191. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  192. end
  193. 6 elsif !attributes[attribute_map[key]].nil?
  194. 6 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  195. end
  196. end
  197. 1 new(transformed_hash)
  198. end
  199. # Returns the object in the form of hash
  200. # @return [Hash] Returns the object in the form of hash
  201. 1 def to_hash
  202. 2 hash = {}
  203. 2 self.class.attribute_map.each_pair do |attr, param|
  204. 12 value = self.send(attr)
  205. 12 if value.nil?
  206. is_nullable = self.class.openapi_nullable.include?(attr)
  207. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  208. end
  209. 12 hash[param] = _to_hash(value)
  210. end
  211. 2 hash
  212. end
  213. end
  214. end

lib/bandwidth-sdk/models/bridge_complete_callback.rb

85.47% lines covered

117 relevant lines. 100 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # If the target call leaves the <Bridge>, then this callback is sent to the bridgeCompleteUrl, and the BXML returned in it is executed on the call. If this webhook is sent, the Bridge Target Complete webhook is NOT sent. This callback is also sent if any problem occurs that prevents the calls to be bridged.
  13. 1 class BridgeCompleteCallback < ApiModelBase
  14. # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect.
  15. 1 attr_accessor :event_type
  16. # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.
  17. 1 attr_accessor :event_time
  18. # The user account associated with the call.
  19. 1 attr_accessor :account_id
  20. # The id of the application associated with the call.
  21. 1 attr_accessor :application_id
  22. # The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555).
  23. 1 attr_accessor :from
  24. # The phone number that received the call, in E.164 format (e.g. +15555555555).
  25. 1 attr_accessor :to
  26. 1 attr_accessor :direction
  27. # The call id associated with the event.
  28. 1 attr_accessor :call_id
  29. # The URL of the call associated with the event.
  30. 1 attr_accessor :call_url
  31. # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format.
  32. 1 attr_accessor :enqueued_time
  33. # Time the call was started, in ISO 8601 format.
  34. 1 attr_accessor :start_time
  35. # Time the call was answered, in ISO 8601 format.
  36. 1 attr_accessor :answer_time
  37. # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.
  38. 1 attr_accessor :tag
  39. # Reason the call failed - hangup, busy, timeout, cancel, rejected, callback-error, invalid-bxml, application-error, account-limit, node-capacity-exceeded, error, or unknown.
  40. 1 attr_accessor :cause
  41. # Text explaining the reason that caused the call to fail in case of errors.
  42. 1 attr_accessor :error_message
  43. # Bandwidth's internal id that references the error event.
  44. 1 attr_accessor :error_id
  45. 1 class EnumAttributeValidator
  46. 1 attr_reader :datatype
  47. 1 attr_reader :allowable_values
  48. 1 def initialize(datatype, allowable_values)
  49. @allowable_values = allowable_values.map do |value|
  50. case datatype.to_s
  51. when /Integer/i
  52. value.to_i
  53. when /Float/i
  54. value.to_f
  55. else
  56. value
  57. end
  58. end
  59. end
  60. 1 def valid?(value)
  61. !value || allowable_values.include?(value)
  62. end
  63. end
  64. # Attribute mapping from ruby-style variable name to JSON key.
  65. 1 def self.attribute_map
  66. 75 {
  67. :'event_type' => :'eventType',
  68. :'event_time' => :'eventTime',
  69. :'account_id' => :'accountId',
  70. :'application_id' => :'applicationId',
  71. :'from' => :'from',
  72. :'to' => :'to',
  73. :'direction' => :'direction',
  74. :'call_id' => :'callId',
  75. :'call_url' => :'callUrl',
  76. :'enqueued_time' => :'enqueuedTime',
  77. :'start_time' => :'startTime',
  78. :'answer_time' => :'answerTime',
  79. :'tag' => :'tag',
  80. :'cause' => :'cause',
  81. :'error_message' => :'errorMessage',
  82. :'error_id' => :'errorId'
  83. }
  84. end
  85. # Returns attribute mapping this model knows about
  86. 1 def self.acceptable_attribute_map
  87. 8 attribute_map
  88. end
  89. # Returns all the JSON keys this model knows about
  90. 1 def self.acceptable_attributes
  91. 1 acceptable_attribute_map.values
  92. end
  93. # Attribute type mapping.
  94. 1 def self.openapi_types
  95. 1 {
  96. :'event_type' => :'String',
  97. :'event_time' => :'Time',
  98. :'account_id' => :'String',
  99. :'application_id' => :'String',
  100. :'from' => :'String',
  101. :'to' => :'String',
  102. :'direction' => :'CallDirectionEnum',
  103. :'call_id' => :'String',
  104. :'call_url' => :'String',
  105. :'enqueued_time' => :'Time',
  106. :'start_time' => :'Time',
  107. :'answer_time' => :'Time',
  108. :'tag' => :'String',
  109. :'cause' => :'String',
  110. :'error_message' => :'String',
  111. :'error_id' => :'String'
  112. }
  113. end
  114. # List of attributes with nullable: true
  115. 1 def self.openapi_nullable
  116. 1 Set.new([
  117. :'enqueued_time',
  118. :'answer_time',
  119. :'tag',
  120. :'error_message',
  121. :'error_id'
  122. ])
  123. end
  124. # Initializes the object
  125. # @param [Hash] attributes Model attributes in the form of hash
  126. 1 def initialize(attributes = {})
  127. 8 if (!attributes.is_a?(Hash))
  128. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::BridgeCompleteCallback` initialize method'
  129. end
  130. # check to see if the attribute exists and convert string to symbol for hash key
  131. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  132. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  133. 65 if (!acceptable_attribute_map.key?(k.to_sym))
  134. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::BridgeCompleteCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  135. end
  136. 64 h[k.to_sym] = v
  137. }
  138. 6 if attributes.key?(:'event_type')
  139. 4 self.event_type = attributes[:'event_type']
  140. end
  141. 6 if attributes.key?(:'event_time')
  142. 4 self.event_time = attributes[:'event_time']
  143. end
  144. 6 if attributes.key?(:'account_id')
  145. 4 self.account_id = attributes[:'account_id']
  146. end
  147. 6 if attributes.key?(:'application_id')
  148. 4 self.application_id = attributes[:'application_id']
  149. end
  150. 6 if attributes.key?(:'from')
  151. 4 self.from = attributes[:'from']
  152. end
  153. 6 if attributes.key?(:'to')
  154. 4 self.to = attributes[:'to']
  155. end
  156. 6 if attributes.key?(:'direction')
  157. 4 self.direction = attributes[:'direction']
  158. end
  159. 6 if attributes.key?(:'call_id')
  160. 4 self.call_id = attributes[:'call_id']
  161. end
  162. 6 if attributes.key?(:'call_url')
  163. 4 self.call_url = attributes[:'call_url']
  164. end
  165. 6 if attributes.key?(:'enqueued_time')
  166. 4 self.enqueued_time = attributes[:'enqueued_time']
  167. end
  168. 6 if attributes.key?(:'start_time')
  169. 4 self.start_time = attributes[:'start_time']
  170. end
  171. 6 if attributes.key?(:'answer_time')
  172. 4 self.answer_time = attributes[:'answer_time']
  173. end
  174. 6 if attributes.key?(:'tag')
  175. 4 self.tag = attributes[:'tag']
  176. end
  177. 6 if attributes.key?(:'cause')
  178. 4 self.cause = attributes[:'cause']
  179. end
  180. 6 if attributes.key?(:'error_message')
  181. 4 self.error_message = attributes[:'error_message']
  182. end
  183. 6 if attributes.key?(:'error_id')
  184. 4 self.error_id = attributes[:'error_id']
  185. end
  186. end
  187. # Show invalid properties with the reasons. Usually used together with valid?
  188. # @return Array for valid properties with the reasons
  189. 1 def list_invalid_properties
  190. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  191. invalid_properties = Array.new
  192. invalid_properties
  193. end
  194. # Check to see if the all the properties in the model are valid
  195. # @return true if the model is valid
  196. 1 def valid?
  197. warn '[DEPRECATED] the `valid?` method is obsolete'
  198. true
  199. end
  200. # Checks equality by comparing each attribute.
  201. # @param [Object] Object to be compared
  202. 1 def ==(o)
  203. 2 return true if self.equal?(o)
  204. 2 self.class == o.class &&
  205. event_type == o.event_type &&
  206. event_time == o.event_time &&
  207. account_id == o.account_id &&
  208. application_id == o.application_id &&
  209. from == o.from &&
  210. to == o.to &&
  211. direction == o.direction &&
  212. call_id == o.call_id &&
  213. call_url == o.call_url &&
  214. enqueued_time == o.enqueued_time &&
  215. start_time == o.start_time &&
  216. answer_time == o.answer_time &&
  217. tag == o.tag &&
  218. cause == o.cause &&
  219. error_message == o.error_message &&
  220. error_id == o.error_id
  221. end
  222. # @see the `==` method
  223. # @param [Object] Object to be compared
  224. 1 def eql?(o)
  225. 2 self == o
  226. end
  227. # Calculates hash code according to all attributes.
  228. # @return [Integer] Hash code
  229. 1 def hash
  230. [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, enqueued_time, start_time, answer_time, tag, cause, error_message, error_id].hash
  231. end
  232. # Builds the object from hash
  233. # @param [Hash] attributes Model attributes in the form of hash
  234. # @return [Object] Returns the model itself
  235. 1 def self.build_from_hash(attributes)
  236. 1 return nil unless attributes.is_a?(Hash)
  237. 1 attributes = attributes.transform_keys(&:to_sym)
  238. 1 transformed_hash = {}
  239. 1 openapi_types.each_pair do |key, type|
  240. 16 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  241. transformed_hash["#{key}"] = nil
  242. 16 elsif type =~ /\AArray<(.*)>/i
  243. # check to ensure the input is an array given that the attribute
  244. # is documented as an array but the input is not
  245. if attributes[attribute_map[key]].is_a?(Array)
  246. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  247. end
  248. 16 elsif !attributes[attribute_map[key]].nil?
  249. 16 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  250. end
  251. end
  252. 1 new(transformed_hash)
  253. end
  254. # Returns the object in the form of hash
  255. # @return [Hash] Returns the object in the form of hash
  256. 1 def to_hash
  257. 2 hash = {}
  258. 2 self.class.attribute_map.each_pair do |attr, param|
  259. 32 value = self.send(attr)
  260. 32 if value.nil?
  261. is_nullable = self.class.openapi_nullable.include?(attr)
  262. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  263. end
  264. 32 hash[param] = _to_hash(value)
  265. end
  266. 2 hash
  267. end
  268. end
  269. end

lib/bandwidth-sdk/models/bridge_target_complete_callback.rb

84.26% lines covered

108 relevant lines. 91 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # If the originating call leaves the <Bridge>, then this callback is sent to the bridgeTargetCompleteUrl, and the BXML returned in it is executed on the target call. If this webhook is sent, the Bridge Complete webhook is NOT sent.
  13. 1 class BridgeTargetCompleteCallback < ApiModelBase
  14. # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect.
  15. 1 attr_accessor :event_type
  16. # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.
  17. 1 attr_accessor :event_time
  18. # The user account associated with the call.
  19. 1 attr_accessor :account_id
  20. # The id of the application associated with the call.
  21. 1 attr_accessor :application_id
  22. # The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555).
  23. 1 attr_accessor :from
  24. # The phone number that received the call, in E.164 format (e.g. +15555555555).
  25. 1 attr_accessor :to
  26. 1 attr_accessor :direction
  27. # The call id associated with the event.
  28. 1 attr_accessor :call_id
  29. # The URL of the call associated with the event.
  30. 1 attr_accessor :call_url
  31. # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format.
  32. 1 attr_accessor :enqueued_time
  33. # Time the call was started, in ISO 8601 format.
  34. 1 attr_accessor :start_time
  35. # Time the call was answered, in ISO 8601 format.
  36. 1 attr_accessor :answer_time
  37. # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.
  38. 1 attr_accessor :tag
  39. 1 class EnumAttributeValidator
  40. 1 attr_reader :datatype
  41. 1 attr_reader :allowable_values
  42. 1 def initialize(datatype, allowable_values)
  43. @allowable_values = allowable_values.map do |value|
  44. case datatype.to_s
  45. when /Integer/i
  46. value.to_i
  47. when /Float/i
  48. value.to_f
  49. else
  50. value
  51. end
  52. end
  53. end
  54. 1 def valid?(value)
  55. !value || allowable_values.include?(value)
  56. end
  57. end
  58. # Attribute mapping from ruby-style variable name to JSON key.
  59. 1 def self.attribute_map
  60. 63 {
  61. :'event_type' => :'eventType',
  62. :'event_time' => :'eventTime',
  63. :'account_id' => :'accountId',
  64. :'application_id' => :'applicationId',
  65. :'from' => :'from',
  66. :'to' => :'to',
  67. :'direction' => :'direction',
  68. :'call_id' => :'callId',
  69. :'call_url' => :'callUrl',
  70. :'enqueued_time' => :'enqueuedTime',
  71. :'start_time' => :'startTime',
  72. :'answer_time' => :'answerTime',
  73. :'tag' => :'tag'
  74. }
  75. end
  76. # Returns attribute mapping this model knows about
  77. 1 def self.acceptable_attribute_map
  78. 8 attribute_map
  79. end
  80. # Returns all the JSON keys this model knows about
  81. 1 def self.acceptable_attributes
  82. 1 acceptable_attribute_map.values
  83. end
  84. # Attribute type mapping.
  85. 1 def self.openapi_types
  86. 1 {
  87. :'event_type' => :'String',
  88. :'event_time' => :'Time',
  89. :'account_id' => :'String',
  90. :'application_id' => :'String',
  91. :'from' => :'String',
  92. :'to' => :'String',
  93. :'direction' => :'CallDirectionEnum',
  94. :'call_id' => :'String',
  95. :'call_url' => :'String',
  96. :'enqueued_time' => :'Time',
  97. :'start_time' => :'Time',
  98. :'answer_time' => :'Time',
  99. :'tag' => :'String'
  100. }
  101. end
  102. # List of attributes with nullable: true
  103. 1 def self.openapi_nullable
  104. 1 Set.new([
  105. :'enqueued_time',
  106. :'answer_time',
  107. :'tag'
  108. ])
  109. end
  110. # Initializes the object
  111. # @param [Hash] attributes Model attributes in the form of hash
  112. 1 def initialize(attributes = {})
  113. 8 if (!attributes.is_a?(Hash))
  114. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::BridgeTargetCompleteCallback` initialize method'
  115. end
  116. # check to see if the attribute exists and convert string to symbol for hash key
  117. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  118. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  119. 53 if (!acceptable_attribute_map.key?(k.to_sym))
  120. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::BridgeTargetCompleteCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  121. end
  122. 52 h[k.to_sym] = v
  123. }
  124. 6 if attributes.key?(:'event_type')
  125. 4 self.event_type = attributes[:'event_type']
  126. end
  127. 6 if attributes.key?(:'event_time')
  128. 4 self.event_time = attributes[:'event_time']
  129. end
  130. 6 if attributes.key?(:'account_id')
  131. 4 self.account_id = attributes[:'account_id']
  132. end
  133. 6 if attributes.key?(:'application_id')
  134. 4 self.application_id = attributes[:'application_id']
  135. end
  136. 6 if attributes.key?(:'from')
  137. 4 self.from = attributes[:'from']
  138. end
  139. 6 if attributes.key?(:'to')
  140. 4 self.to = attributes[:'to']
  141. end
  142. 6 if attributes.key?(:'direction')
  143. 4 self.direction = attributes[:'direction']
  144. end
  145. 6 if attributes.key?(:'call_id')
  146. 4 self.call_id = attributes[:'call_id']
  147. end
  148. 6 if attributes.key?(:'call_url')
  149. 4 self.call_url = attributes[:'call_url']
  150. end
  151. 6 if attributes.key?(:'enqueued_time')
  152. 4 self.enqueued_time = attributes[:'enqueued_time']
  153. end
  154. 6 if attributes.key?(:'start_time')
  155. 4 self.start_time = attributes[:'start_time']
  156. end
  157. 6 if attributes.key?(:'answer_time')
  158. 4 self.answer_time = attributes[:'answer_time']
  159. end
  160. 6 if attributes.key?(:'tag')
  161. 4 self.tag = attributes[:'tag']
  162. end
  163. end
  164. # Show invalid properties with the reasons. Usually used together with valid?
  165. # @return Array for valid properties with the reasons
  166. 1 def list_invalid_properties
  167. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  168. invalid_properties = Array.new
  169. invalid_properties
  170. end
  171. # Check to see if the all the properties in the model are valid
  172. # @return true if the model is valid
  173. 1 def valid?
  174. warn '[DEPRECATED] the `valid?` method is obsolete'
  175. true
  176. end
  177. # Checks equality by comparing each attribute.
  178. # @param [Object] Object to be compared
  179. 1 def ==(o)
  180. 2 return true if self.equal?(o)
  181. 2 self.class == o.class &&
  182. event_type == o.event_type &&
  183. event_time == o.event_time &&
  184. account_id == o.account_id &&
  185. application_id == o.application_id &&
  186. from == o.from &&
  187. to == o.to &&
  188. direction == o.direction &&
  189. call_id == o.call_id &&
  190. call_url == o.call_url &&
  191. enqueued_time == o.enqueued_time &&
  192. start_time == o.start_time &&
  193. answer_time == o.answer_time &&
  194. tag == o.tag
  195. end
  196. # @see the `==` method
  197. # @param [Object] Object to be compared
  198. 1 def eql?(o)
  199. 2 self == o
  200. end
  201. # Calculates hash code according to all attributes.
  202. # @return [Integer] Hash code
  203. 1 def hash
  204. [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, enqueued_time, start_time, answer_time, tag].hash
  205. end
  206. # Builds the object from hash
  207. # @param [Hash] attributes Model attributes in the form of hash
  208. # @return [Object] Returns the model itself
  209. 1 def self.build_from_hash(attributes)
  210. 1 return nil unless attributes.is_a?(Hash)
  211. 1 attributes = attributes.transform_keys(&:to_sym)
  212. 1 transformed_hash = {}
  213. 1 openapi_types.each_pair do |key, type|
  214. 13 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  215. transformed_hash["#{key}"] = nil
  216. 13 elsif type =~ /\AArray<(.*)>/i
  217. # check to ensure the input is an array given that the attribute
  218. # is documented as an array but the input is not
  219. if attributes[attribute_map[key]].is_a?(Array)
  220. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  221. end
  222. 13 elsif !attributes[attribute_map[key]].nil?
  223. 13 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  224. end
  225. end
  226. 1 new(transformed_hash)
  227. end
  228. # Returns the object in the form of hash
  229. # @return [Hash] Returns the object in the form of hash
  230. 1 def to_hash
  231. 2 hash = {}
  232. 2 self.class.attribute_map.each_pair do |attr, param|
  233. 26 value = self.send(attr)
  234. 26 if value.nil?
  235. is_nullable = self.class.openapi_nullable.include?(attr)
  236. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  237. end
  238. 26 hash[param] = _to_hash(value)
  239. end
  240. 2 hash
  241. end
  242. end
  243. end

lib/bandwidth-sdk/models/brtc_error.rb

80.9% lines covered

89 relevant lines. 72 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class BrtcError < ApiModelBase
  13. # A unique identifier for the error.
  14. 1 attr_accessor :id
  15. # The type of error.
  16. 1 attr_accessor :type
  17. # A description of the error.
  18. 1 attr_accessor :description
  19. # A code that uniquely identifies the error.
  20. 1 attr_accessor :code
  21. 1 attr_accessor :source
  22. # Attribute mapping from ruby-style variable name to JSON key.
  23. 1 def self.attribute_map
  24. 124 {
  25. :'id' => :'id',
  26. :'type' => :'type',
  27. :'description' => :'description',
  28. :'code' => :'code',
  29. :'source' => :'source'
  30. }
  31. end
  32. # Returns attribute mapping this model knows about
  33. 1 def self.acceptable_attribute_map
  34. 37 attribute_map
  35. end
  36. # Returns all the JSON keys this model knows about
  37. 1 def self.acceptable_attributes
  38. 1 acceptable_attribute_map.values
  39. end
  40. # Attribute type mapping.
  41. 1 def self.openapi_types
  42. 5 {
  43. :'id' => :'String',
  44. :'type' => :'String',
  45. :'description' => :'String',
  46. :'code' => :'String',
  47. :'source' => :'BrtcErrorSource'
  48. }
  49. end
  50. # List of attributes with nullable: true
  51. 1 def self.openapi_nullable
  52. 25 Set.new([
  53. ])
  54. end
  55. # Initializes the object
  56. # @param [Hash] attributes Model attributes in the form of hash
  57. 1 def initialize(attributes = {})
  58. 37 if (!attributes.is_a?(Hash))
  59. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::BrtcError` initialize method'
  60. end
  61. # check to see if the attribute exists and convert string to symbol for hash key
  62. 36 acceptable_attribute_map = self.class.acceptable_attribute_map
  63. 36 attributes = attributes.each_with_object({}) { |(k, v), h|
  64. 83 if (!acceptable_attribute_map.key?(k.to_sym))
  65. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::BrtcError`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  66. end
  67. 82 h[k.to_sym] = v
  68. }
  69. 35 if attributes.key?(:'id')
  70. 4 self.id = attributes[:'id']
  71. end
  72. 35 if attributes.key?(:'type')
  73. 35 self.type = attributes[:'type']
  74. else
  75. self.type = nil
  76. end
  77. 34 if attributes.key?(:'description')
  78. 34 self.description = attributes[:'description']
  79. else
  80. self.description = nil
  81. end
  82. 33 if attributes.key?(:'code')
  83. 4 self.code = attributes[:'code']
  84. end
  85. 33 if attributes.key?(:'source')
  86. 4 self.source = attributes[:'source']
  87. end
  88. end
  89. # Show invalid properties with the reasons. Usually used together with valid?
  90. # @return Array for valid properties with the reasons
  91. 1 def list_invalid_properties
  92. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  93. invalid_properties = Array.new
  94. if @type.nil?
  95. invalid_properties.push('invalid value for "type", type cannot be nil.')
  96. end
  97. if @description.nil?
  98. invalid_properties.push('invalid value for "description", description cannot be nil.')
  99. end
  100. invalid_properties
  101. end
  102. # Check to see if the all the properties in the model are valid
  103. # @return true if the model is valid
  104. 1 def valid?
  105. warn '[DEPRECATED] the `valid?` method is obsolete'
  106. return false if @type.nil?
  107. return false if @description.nil?
  108. true
  109. end
  110. # Custom attribute writer method with validation
  111. # @param [Object] type Value to be assigned
  112. 1 def type=(type)
  113. 35 if type.nil?
  114. 1 fail ArgumentError, 'type cannot be nil'
  115. end
  116. 34 @type = type
  117. end
  118. # Custom attribute writer method with validation
  119. # @param [Object] description Value to be assigned
  120. 1 def description=(description)
  121. 34 if description.nil?
  122. 1 fail ArgumentError, 'description cannot be nil'
  123. end
  124. 33 @description = description
  125. end
  126. # Checks equality by comparing each attribute.
  127. # @param [Object] Object to be compared
  128. 1 def ==(o)
  129. 2 return true if self.equal?(o)
  130. 2 self.class == o.class &&
  131. id == o.id &&
  132. type == o.type &&
  133. description == o.description &&
  134. code == o.code &&
  135. source == o.source
  136. end
  137. # @see the `==` method
  138. # @param [Object] Object to be compared
  139. 1 def eql?(o)
  140. 2 self == o
  141. end
  142. # Calculates hash code according to all attributes.
  143. # @return [Integer] Hash code
  144. 1 def hash
  145. [id, type, description, code, source].hash
  146. end
  147. # Builds the object from hash
  148. # @param [Hash] attributes Model attributes in the form of hash
  149. # @return [Object] Returns the model itself
  150. 1 def self.build_from_hash(attributes)
  151. 5 return nil unless attributes.is_a?(Hash)
  152. 5 attributes = attributes.transform_keys(&:to_sym)
  153. 5 transformed_hash = {}
  154. 5 openapi_types.each_pair do |key, type|
  155. 25 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  156. transformed_hash["#{key}"] = nil
  157. 25 elsif type =~ /\AArray<(.*)>/i
  158. # check to ensure the input is an array given that the attribute
  159. # is documented as an array but the input is not
  160. if attributes[attribute_map[key]].is_a?(Array)
  161. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  162. end
  163. 25 elsif !attributes[attribute_map[key]].nil?
  164. 13 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  165. end
  166. end
  167. 5 new(transformed_hash)
  168. end
  169. # Returns the object in the form of hash
  170. # @return [Hash] Returns the object in the form of hash
  171. 1 def to_hash
  172. 10 hash = {}
  173. 10 self.class.attribute_map.each_pair do |attr, param|
  174. 50 value = self.send(attr)
  175. 50 if value.nil?
  176. 24 is_nullable = self.class.openapi_nullable.include?(attr)
  177. 24 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  178. end
  179. 26 hash[param] = _to_hash(value)
  180. end
  181. 10 hash
  182. end
  183. end
  184. end

lib/bandwidth-sdk/models/brtc_error_response.rb

80.23% lines covered

86 relevant lines. 69 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class BrtcErrorResponse < ApiModelBase
  13. 1 attr_accessor :links
  14. 1 attr_accessor :data
  15. 1 attr_accessor :errors
  16. # Attribute mapping from ruby-style variable name to JSON key.
  17. 1 def self.attribute_map
  18. 25 {
  19. :'links' => :'links',
  20. :'data' => :'data',
  21. :'errors' => :'errors'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 10 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 1 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 1 {
  35. :'links' => :'Array<BrtcLink>',
  36. :'data' => :'Object',
  37. :'errors' => :'Array<BrtcError>'
  38. }
  39. end
  40. # List of attributes with nullable: true
  41. 1 def self.openapi_nullable
  42. 1 Set.new([
  43. :'data',
  44. ])
  45. end
  46. # Initializes the object
  47. # @param [Hash] attributes Model attributes in the form of hash
  48. 1 def initialize(attributes = {})
  49. 10 if (!attributes.is_a?(Hash))
  50. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::BrtcErrorResponse` initialize method'
  51. end
  52. # check to see if the attribute exists and convert string to symbol for hash key
  53. 9 acceptable_attribute_map = self.class.acceptable_attribute_map
  54. 9 attributes = attributes.each_with_object({}) { |(k, v), h|
  55. 23 if (!acceptable_attribute_map.key?(k.to_sym))
  56. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::BrtcErrorResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  57. end
  58. 22 h[k.to_sym] = v
  59. }
  60. 8 if attributes.key?(:'links')
  61. 8 if (value = attributes[:'links']).is_a?(Array)
  62. 8 self.links = value
  63. end
  64. else
  65. self.links = nil
  66. end
  67. 8 if attributes.key?(:'data')
  68. 6 self.data = attributes[:'data']
  69. else
  70. 2 self.data = nil
  71. end
  72. 8 if attributes.key?(:'errors')
  73. 8 if (value = attributes[:'errors']).is_a?(Array)
  74. 8 self.errors = value
  75. end
  76. else
  77. self.errors = nil
  78. end
  79. end
  80. # Show invalid properties with the reasons. Usually used together with valid?
  81. # @return Array for valid properties with the reasons
  82. 1 def list_invalid_properties
  83. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  84. invalid_properties = Array.new
  85. if @links.nil?
  86. invalid_properties.push('invalid value for "links", links cannot be nil.')
  87. end
  88. if @errors.nil?
  89. invalid_properties.push('invalid value for "errors", errors cannot be nil.')
  90. end
  91. invalid_properties
  92. end
  93. # Check to see if the all the properties in the model are valid
  94. # @return true if the model is valid
  95. 1 def valid?
  96. warn '[DEPRECATED] the `valid?` method is obsolete'
  97. return false if @links.nil?
  98. return false if @errors.nil?
  99. true
  100. end
  101. # Custom attribute writer method with validation
  102. # @param [Object] links Value to be assigned
  103. 1 def links=(links)
  104. 9 if links.nil?
  105. 1 fail ArgumentError, 'links cannot be nil'
  106. end
  107. 8 @links = links
  108. end
  109. # Custom attribute writer method with validation
  110. # @param [Object] errors Value to be assigned
  111. 1 def errors=(errors)
  112. 9 if errors.nil?
  113. 1 fail ArgumentError, 'errors cannot be nil'
  114. end
  115. 8 @errors = errors
  116. end
  117. # Checks equality by comparing each attribute.
  118. # @param [Object] Object to be compared
  119. 1 def ==(o)
  120. 2 return true if self.equal?(o)
  121. 2 self.class == o.class &&
  122. links == o.links &&
  123. data == o.data &&
  124. errors == o.errors
  125. end
  126. # @see the `==` method
  127. # @param [Object] Object to be compared
  128. 1 def eql?(o)
  129. 2 self == o
  130. end
  131. # Calculates hash code according to all attributes.
  132. # @return [Integer] Hash code
  133. 1 def hash
  134. [links, data, errors].hash
  135. end
  136. # Builds the object from hash
  137. # @param [Hash] attributes Model attributes in the form of hash
  138. # @return [Object] Returns the model itself
  139. 1 def self.build_from_hash(attributes)
  140. 1 return nil unless attributes.is_a?(Hash)
  141. 1 attributes = attributes.transform_keys(&:to_sym)
  142. 1 transformed_hash = {}
  143. 1 openapi_types.each_pair do |key, type|
  144. 3 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  145. transformed_hash["#{key}"] = nil
  146. 3 elsif type =~ /\AArray<(.*)>/i
  147. # check to ensure the input is an array given that the attribute
  148. # is documented as an array but the input is not
  149. 2 if attributes[attribute_map[key]].is_a?(Array)
  150. 4 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  151. end
  152. 1 elsif !attributes[attribute_map[key]].nil?
  153. 1 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  154. end
  155. end
  156. 1 new(transformed_hash)
  157. end
  158. # Returns the object in the form of hash
  159. # @return [Hash] Returns the object in the form of hash
  160. 1 def to_hash
  161. 2 hash = {}
  162. 2 self.class.attribute_map.each_pair do |attr, param|
  163. 6 value = self.send(attr)
  164. 6 if value.nil?
  165. is_nullable = self.class.openapi_nullable.include?(attr)
  166. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  167. end
  168. 6 hash[param] = _to_hash(value)
  169. end
  170. 2 hash
  171. end
  172. end
  173. end

lib/bandwidth-sdk/models/brtc_error_source.rb

87.14% lines covered

70 relevant lines. 61 lines covered and 9 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class BrtcErrorSource < ApiModelBase
  13. # The URI parameter that caused the error.
  14. 1 attr_accessor :parameter
  15. # The request body field that caused the error.
  16. 1 attr_accessor :field
  17. # The header that caused the error.
  18. 1 attr_accessor :header
  19. # The resource ID or path to the resource (or non-existent resource) causing the error.
  20. 1 attr_accessor :reference
  21. # Attribute mapping from ruby-style variable name to JSON key.
  22. 1 def self.attribute_map
  23. 43 {
  24. :'parameter' => :'parameter',
  25. :'field' => :'field',
  26. :'header' => :'header',
  27. :'reference' => :'reference'
  28. }
  29. end
  30. # Returns attribute mapping this model knows about
  31. 1 def self.acceptable_attribute_map
  32. 12 attribute_map
  33. end
  34. # Returns all the JSON keys this model knows about
  35. 1 def self.acceptable_attributes
  36. 1 acceptable_attribute_map.values
  37. end
  38. # Attribute type mapping.
  39. 1 def self.openapi_types
  40. 2 {
  41. :'parameter' => :'String',
  42. :'field' => :'String',
  43. :'header' => :'String',
  44. :'reference' => :'String'
  45. }
  46. end
  47. # List of attributes with nullable: true
  48. 1 def self.openapi_nullable
  49. 7 Set.new([
  50. ])
  51. end
  52. # Initializes the object
  53. # @param [Hash] attributes Model attributes in the form of hash
  54. 1 def initialize(attributes = {})
  55. 12 if (!attributes.is_a?(Hash))
  56. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::BrtcErrorSource` initialize method'
  57. end
  58. # check to see if the attribute exists and convert string to symbol for hash key
  59. 11 acceptable_attribute_map = self.class.acceptable_attribute_map
  60. 11 attributes = attributes.each_with_object({}) { |(k, v), h|
  61. 21 if (!acceptable_attribute_map.key?(k.to_sym))
  62. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::BrtcErrorSource`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  63. end
  64. 20 h[k.to_sym] = v
  65. }
  66. 10 if attributes.key?(:'parameter')
  67. 4 self.parameter = attributes[:'parameter']
  68. end
  69. 10 if attributes.key?(:'field')
  70. 8 self.field = attributes[:'field']
  71. end
  72. 10 if attributes.key?(:'header')
  73. 4 self.header = attributes[:'header']
  74. end
  75. 10 if attributes.key?(:'reference')
  76. 4 self.reference = attributes[:'reference']
  77. end
  78. end
  79. # Show invalid properties with the reasons. Usually used together with valid?
  80. # @return Array for valid properties with the reasons
  81. 1 def list_invalid_properties
  82. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  83. invalid_properties = Array.new
  84. invalid_properties
  85. end
  86. # Check to see if the all the properties in the model are valid
  87. # @return true if the model is valid
  88. 1 def valid?
  89. warn '[DEPRECATED] the `valid?` method is obsolete'
  90. true
  91. end
  92. # Checks equality by comparing each attribute.
  93. # @param [Object] Object to be compared
  94. 1 def ==(o)
  95. 2 return true if self.equal?(o)
  96. 2 self.class == o.class &&
  97. parameter == o.parameter &&
  98. field == o.field &&
  99. header == o.header &&
  100. reference == o.reference
  101. end
  102. # @see the `==` method
  103. # @param [Object] Object to be compared
  104. 1 def eql?(o)
  105. 2 self == o
  106. end
  107. # Calculates hash code according to all attributes.
  108. # @return [Integer] Hash code
  109. 1 def hash
  110. [parameter, field, header, reference].hash
  111. end
  112. # Builds the object from hash
  113. # @param [Hash] attributes Model attributes in the form of hash
  114. # @return [Object] Returns the model itself
  115. 1 def self.build_from_hash(attributes)
  116. 2 return nil unless attributes.is_a?(Hash)
  117. 2 attributes = attributes.transform_keys(&:to_sym)
  118. 2 transformed_hash = {}
  119. 2 openapi_types.each_pair do |key, type|
  120. 8 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  121. transformed_hash["#{key}"] = nil
  122. 8 elsif type =~ /\AArray<(.*)>/i
  123. # check to ensure the input is an array given that the attribute
  124. # is documented as an array but the input is not
  125. if attributes[attribute_map[key]].is_a?(Array)
  126. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  127. end
  128. 8 elsif !attributes[attribute_map[key]].nil?
  129. 5 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  130. end
  131. end
  132. 2 new(transformed_hash)
  133. end
  134. # Returns the object in the form of hash
  135. # @return [Hash] Returns the object in the form of hash
  136. 1 def to_hash
  137. 4 hash = {}
  138. 4 self.class.attribute_map.each_pair do |attr, param|
  139. 16 value = self.send(attr)
  140. 16 if value.nil?
  141. 6 is_nullable = self.class.openapi_nullable.include?(attr)
  142. 6 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  143. end
  144. 10 hash[param] = _to_hash(value)
  145. end
  146. 4 hash
  147. end
  148. end
  149. end

lib/bandwidth-sdk/models/brtc_link.rb

83.58% lines covered

67 relevant lines. 56 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class BrtcLink < ApiModelBase
  13. # The full URL of the link.
  14. 1 attr_accessor :href
  15. # The relationship of the link to the current resource.
  16. 1 attr_accessor :rel
  17. # The HTTP method to use when making the request.
  18. 1 attr_accessor :method
  19. # Attribute mapping from ruby-style variable name to JSON key.
  20. 1 def self.attribute_map
  21. 158 {
  22. :'href' => :'href',
  23. :'rel' => :'rel',
  24. :'method' => :'method'
  25. }
  26. end
  27. # Returns attribute mapping this model knows about
  28. 1 def self.acceptable_attribute_map
  29. 39 attribute_map
  30. end
  31. # Returns all the JSON keys this model knows about
  32. 1 def self.acceptable_attributes
  33. 1 acceptable_attribute_map.values
  34. end
  35. # Attribute type mapping.
  36. 1 def self.openapi_types
  37. 9 {
  38. :'href' => :'String',
  39. :'rel' => :'String',
  40. :'method' => :'String'
  41. }
  42. end
  43. # List of attributes with nullable: true
  44. 1 def self.openapi_nullable
  45. 1 Set.new([
  46. ])
  47. end
  48. # Initializes the object
  49. # @param [Hash] attributes Model attributes in the form of hash
  50. 1 def initialize(attributes = {})
  51. 39 if (!attributes.is_a?(Hash))
  52. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::BrtcLink` initialize method'
  53. end
  54. # check to see if the attribute exists and convert string to symbol for hash key
  55. 38 acceptable_attribute_map = self.class.acceptable_attribute_map
  56. 38 attributes = attributes.each_with_object({}) { |(k, v), h|
  57. 106 if (!acceptable_attribute_map.key?(k.to_sym))
  58. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::BrtcLink`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  59. end
  60. 105 h[k.to_sym] = v
  61. }
  62. 37 if attributes.key?(:'href')
  63. 35 self.href = attributes[:'href']
  64. end
  65. 37 if attributes.key?(:'rel')
  66. 35 self.rel = attributes[:'rel']
  67. end
  68. 37 if attributes.key?(:'method')
  69. 35 self.method = attributes[:'method']
  70. end
  71. end
  72. # Show invalid properties with the reasons. Usually used together with valid?
  73. # @return Array for valid properties with the reasons
  74. 1 def list_invalid_properties
  75. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  76. invalid_properties = Array.new
  77. invalid_properties
  78. end
  79. # Check to see if the all the properties in the model are valid
  80. # @return true if the model is valid
  81. 1 def valid?
  82. warn '[DEPRECATED] the `valid?` method is obsolete'
  83. true
  84. end
  85. # Checks equality by comparing each attribute.
  86. # @param [Object] Object to be compared
  87. 1 def ==(o)
  88. 2 return true if self.equal?(o)
  89. 2 self.class == o.class &&
  90. href == o.href &&
  91. rel == o.rel &&
  92. method == o.method
  93. end
  94. # @see the `==` method
  95. # @param [Object] Object to be compared
  96. 1 def eql?(o)
  97. 2 self == o
  98. end
  99. # Calculates hash code according to all attributes.
  100. # @return [Integer] Hash code
  101. 1 def hash
  102. [href, rel, method].hash
  103. end
  104. # Builds the object from hash
  105. # @param [Hash] attributes Model attributes in the form of hash
  106. # @return [Object] Returns the model itself
  107. 1 def self.build_from_hash(attributes)
  108. 9 return nil unless attributes.is_a?(Hash)
  109. 9 attributes = attributes.transform_keys(&:to_sym)
  110. 9 transformed_hash = {}
  111. 9 openapi_types.each_pair do |key, type|
  112. 27 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  113. transformed_hash["#{key}"] = nil
  114. 27 elsif type =~ /\AArray<(.*)>/i
  115. # check to ensure the input is an array given that the attribute
  116. # is documented as an array but the input is not
  117. if attributes[attribute_map[key]].is_a?(Array)
  118. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  119. end
  120. 27 elsif !attributes[attribute_map[key]].nil?
  121. 27 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  122. end
  123. end
  124. 9 new(transformed_hash)
  125. end
  126. # Returns the object in the form of hash
  127. # @return [Hash] Returns the object in the form of hash
  128. 1 def to_hash
  129. 10 hash = {}
  130. 10 self.class.attribute_map.each_pair do |attr, param|
  131. 30 value = self.send(attr)
  132. 30 if value.nil?
  133. is_nullable = self.class.openapi_nullable.include?(attr)
  134. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  135. end
  136. 30 hash[param] = _to_hash(value)
  137. end
  138. 10 hash
  139. end
  140. end
  141. end

lib/bandwidth-sdk/models/business_entity_type_enum.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class BusinessEntityTypeEnum
  13. 1 SOLE_PROPRIETOR = 'SOLE_PROPRIETOR'.freeze
  14. 1 PRIVATE_PROFIT = 'PRIVATE_PROFIT'.freeze
  15. 1 PUBLIC_PROFIT = 'PUBLIC_PROFIT'.freeze
  16. 1 NON_PROFIT = 'NON_PROFIT'.freeze
  17. 1 GOVERNMENT = 'GOVERNMENT'.freeze
  18. 1 def self.all_vars
  19. 11 @all_vars ||= [SOLE_PROPRIETOR, PRIVATE_PROFIT, PUBLIC_PROFIT, NON_PROFIT, GOVERNMENT].freeze
  20. end
  21. # Builds the enum from string
  22. # @param [String] The enum value in the form of the string
  23. # @return [String] The enum value
  24. 1 def self.build_from_hash(value)
  25. 10 new.build_from_hash(value)
  26. end
  27. # Builds the enum from string
  28. # @param [String] The enum value in the form of the string
  29. # @return [String] The enum value
  30. 1 def build_from_hash(value)
  31. 10 return value if BusinessEntityTypeEnum.all_vars.include?(value)
  32. 1 raise "Invalid ENUM value #{value} for class #BusinessEntityTypeEnum"
  33. end
  34. end
  35. end

lib/bandwidth-sdk/models/business_registration_type_enum.rb

100.0% lines covered

29 relevant lines. 29 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class BusinessRegistrationTypeEnum
  13. 1 EIN = 'EIN'.freeze
  14. 1 CBN = 'CBN'.freeze
  15. 1 NEQ = 'NEQ'.freeze
  16. 1 PROVINCIAL_NUMBER = 'PROVINCIAL_NUMBER'.freeze
  17. 1 CRN = 'CRN'.freeze
  18. 1 VAT = 'VAT'.freeze
  19. 1 ACN = 'ACN'.freeze
  20. 1 ABN = 'ABN'.freeze
  21. 1 BRN = 'BRN'.freeze
  22. 1 SIREN = 'SIREN'.freeze
  23. 1 SIRET = 'SIRET'.freeze
  24. 1 NZBN = 'NZBN'.freeze
  25. 1 UST_IDNR = 'UST_IDNR'.freeze
  26. 1 CIF = 'CIF'.freeze
  27. 1 NIF = 'NIF'.freeze
  28. 1 CNPJ = 'CNPJ'.freeze
  29. 1 UID = 'UID'.freeze
  30. 1 OTHER = 'OTHER'.freeze
  31. 1 def self.all_vars
  32. 24 @all_vars ||= [EIN, CBN, NEQ, PROVINCIAL_NUMBER, CRN, VAT, ACN, ABN, BRN, SIREN, SIRET, NZBN, UST_IDNR, CIF, NIF, CNPJ, UID, OTHER].freeze
  33. end
  34. # Builds the enum from string
  35. # @param [String] The enum value in the form of the string
  36. # @return [String] The enum value
  37. 1 def self.build_from_hash(value)
  38. 23 new.build_from_hash(value)
  39. end
  40. # Builds the enum from string
  41. # @param [String] The enum value in the form of the string
  42. # @return [String] The enum value
  43. 1 def build_from_hash(value)
  44. 23 return value if BusinessRegistrationTypeEnum.all_vars.include?(value)
  45. 1 raise "Invalid ENUM value #{value} for class #BusinessRegistrationTypeEnum"
  46. end
  47. end
  48. end

lib/bandwidth-sdk/models/bxml/bxml.rb

100.0% lines covered

5 relevant lines. 5 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class Bxml < Bandwidth::Bxml::Root
  4. # Initializer
  5. # @param nested_verbs [Verb] or [Array<Verb>] XML element children. Defaults to an empty array.
  6. 1 def initialize(nested_verbs = [])
  7. 6 super(tag = 'Bxml', nested_verbs)
  8. end
  9. end
  10. end
  11. end

lib/bandwidth-sdk/models/bxml/nestable_verb.rb

90.91% lines covered

22 relevant lines. 20 lines covered and 2 lines missed.
    
  1. 1 require 'ox'
  2. 1 module Bandwidth
  3. 1 module Bxml
  4. 1 class NestableVerb < Bandwidth::Bxml::Verb
  5. # Initializer
  6. # @param tag [String] Name of the XML element.
  7. # @param content [String] XML element content. Defaults to nil.
  8. # @param nested_verbs [Verb] or [Array<Verb>] XML element children. Defaults to an empty array.
  9. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  10. 1 def initialize(tag, content = nil, nested_verbs = [], attributes = {})
  11. 25 @tag = tag
  12. 25 @content = content
  13. 25 @nested_verbs = Array(nested_verbs)
  14. 25 @attributes = attributes
  15. end
  16. # Generate an XML element for the verb
  17. # @return [Node] The XML element.
  18. 1 def generate_xml
  19. 20 root = Ox::Element.new(@tag)
  20. 20 if @content
  21. root << @content
  22. end
  23. 20 if @nested_verbs.length > 0
  24. 12 @nested_verbs.each do |verb|
  25. 28 root << verb.generate_xml
  26. end
  27. end
  28. 20 if !@attributes.empty? && !@attribute_map.nil?
  29. 20 @attributes.each do |key, value|
  30. 230 if @attribute_map.include? key.to_sym
  31. 230 root[@attribute_map[key.to_sym]] = value
  32. else
  33. raise NoMethodError.new("attribute '#{key}' is not a valid attribute for this verb")
  34. end
  35. end
  36. end
  37. 20 root
  38. end
  39. end
  40. end
  41. end

lib/bandwidth-sdk/models/bxml/response.rb

100.0% lines covered

5 relevant lines. 5 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class Response < Bandwidth::Bxml::Root
  4. # Initializer
  5. # @param nested_verbs [Verb] or [Array<Verb>] XML element children. Defaults to an empty array.
  6. 1 def initialize(nested_verbs = [])
  7. 6 super(tag = 'Response', nested_verbs)
  8. end
  9. end
  10. end
  11. end

lib/bandwidth-sdk/models/bxml/root.rb

100.0% lines covered

25 relevant lines. 25 lines covered and 0 lines missed.
    
  1. 1 require 'ox'
  2. 1 module Bandwidth
  3. 1 module Bxml
  4. 1 SPEAK_SENTENCE_REGEX = /<SpeakSentence.*?>(.*?)<\/SpeakSentence>/
  5. 1 SSML_REGEX = /&lt;([a-zA-Z\/\/].*?)&gt;/
  6. 1 class Root
  7. # Initializer
  8. # @param tag [String] Name of the XML element.
  9. # @param nested_verbs [Verb] or [Array<Verb>] XML element children. Defaults to an empty array.
  10. 1 def initialize(tag, nested_verbs = [])
  11. 12 @tag = tag
  12. 12 @nested_verbs = Array(nested_verbs)
  13. end
  14. # Generate an XML element for the BXML response
  15. # @return [Document] The XML element.
  16. 1 def generate_xml
  17. 10 xml = Ox::Document.new
  18. 10 instruct = Ox::Instruct.new(:xml)
  19. 10 instruct[:version] = '1.0'
  20. 10 instruct[:encoding] = 'UTF-8'
  21. 10 xml << instruct
  22. 10 root = Ox::Element.new(@tag)
  23. 10 @nested_verbs.each do |verb|
  24. 12 root << verb.generate_xml
  25. end
  26. 10 xml << root
  27. 10 xml
  28. end
  29. # Add a verb or verbs to the nested verbs array
  30. # @param *nested_verbs [Verb] or [Array<Verb>] Verb or verbs to add to the array.
  31. 1 def add_verbs(nested_verbs)
  32. 4 @nested_verbs.push(*nested_verbs)
  33. end
  34. # Return BXML representaion of this response
  35. # @return [String] The XML response in string format.
  36. 1 def to_bxml
  37. 10 bxml = Ox.dump(generate_xml)
  38. 10 bxml.gsub(SPEAK_SENTENCE_REGEX) { |text| text.gsub(SSML_REGEX, '<\1>') }
  39. end
  40. end
  41. end
  42. end

lib/bandwidth-sdk/models/bxml/verb.rb

95.45% lines covered

22 relevant lines. 21 lines covered and 1 lines missed.
    
  1. 1 require 'ox'
  2. 1 module Bandwidth
  3. 1 module Bxml
  4. 1 class Verb
  5. # Initializer
  6. # @param tag [String] Name of the XML element.
  7. # @param content [String] XML element content. Defaults to nil.
  8. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  9. 1 def initialize(tag, content = nil, attributes = {})
  10. 92 @tag = tag
  11. 92 @content = content
  12. 92 @attributes = attributes
  13. end
  14. # Set XML attributes for the verb
  15. # @param attributes [Hash] The attributes to add to the element.
  16. 1 def set_attributes(attributes)
  17. 22 @attributes = attributes
  18. end
  19. # Generate an XML element for the verb
  20. # @return [Node] The XML element.
  21. 1 def generate_xml
  22. 83 root = Ox::Element.new(@tag)
  23. 83 if @content
  24. 29 root << @content
  25. end
  26. 83 if !@attributes.empty? && !@attribute_map.nil?
  27. 50 @attributes.each do |key, value|
  28. 258 if @attribute_map.include? key.to_sym
  29. 258 root[@attribute_map[key.to_sym]] = value
  30. else
  31. raise NoMethodError.new("attribute '#{key}' is not a valid attribute for this verb")
  32. end
  33. end
  34. end
  35. 83 root
  36. end
  37. # Return BXML representaion of this element
  38. # @return [String] The XML element in string format.
  39. 1 def to_bxml
  40. 56 Ox.dump(generate_xml)
  41. end
  42. end
  43. end
  44. end

lib/bandwidth-sdk/models/bxml/verbs/bridge.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class Bridge < Bandwidth::Bxml::Verb
  4. # Initializer
  5. # @param target_call [String] The callId of the call to be bridged.
  6. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  7. 1 def initialize(target_call, attributes = {})
  8. 3 super('Bridge', target_call, attributes)
  9. @attribute_map = {
  10. 3 bridge_complete_url: 'bridgeCompleteUrl', # Optional [String]: URL to send the Bridge Complete event to and request new BXML. If this attribute is specified, then Verbs following the <Bridge> verb will be ignored and the BXML returned in this webhook is executed on the call. If this attribute is not specified then no webhook will be sent, and execution of the verbs following the <Bridge> verb continues. May be a relative URL. Defaults to None.
  11. bridge_complete_method: 'bridgeCompleteMethod', # Optional [String]: The HTTP method to use for the request to bridgeCompleteUrl. GET or POST. Default value is POST.
  12. bridge_complete_fallback_url: 'bridgeCompleteFallbackUrl', # Optional [String]: A fallback url which, if provided, will be used to retry the Bridge Complete webhook delivery in case bridgeCompleteUrl fails to respond. Defaults to None.
  13. bridge_complete_fallback_method: 'bridgeCompleteFallbackMethod', # Optional [String]: The HTTP method to use to deliver the Bridge Complete webhook to bridgeCompleteFallbackUrl. GET or POST. Default value is POST.
  14. bridge_target_complete_url: 'bridgeTargetCompleteUrl', # Optional [String]: URL to send the Bridge Target Complete event to and request new BXML. If this attribute is specified, then the BXML returned in this webhook is executed on the target call. If this attribute is not specified then no webhook will be sent, and the target call will be hung up. May be a relative URL. Defaults to None.
  15. bridge_target_complete_method: 'bridgeTargetCompleteMethod', # Optional [String]: The HTTP method to use for the request to bridgeTargetCompleteUrl. GET or POST. Default value is POST.
  16. bridge_target_complete_fallback_url: 'bridgeTargetCompleteFallbackUrl', # Optional [String]: A fallback url which, if provided, will be used to retry the Bridge Target Complete webhook delivery in case bridgeTargetCompleteUrl fails to respond. Defaults to None.
  17. bridge_target_complete_fallback_method: 'bridgeTargetCompleteFallbackMethod', # Optional [String]: The HTTP method to use to deliver the Bridge Target Complete webhook to bridgeTargetCompleteFallbackUrl. GET or POST. Default value is POST.
  18. username: 'username', # Optional [String]: The username to send in the HTTP request to bridgeCompleteUrl and to bridgeTargetCompleteUrl. Defaults to None.
  19. password: 'password', # Optional [String]: The password to send in the HTTP request to bridgeCompleteUrl and to bridgeTargetCompleteUrl. Defaults to None.
  20. fallback_username: 'fallbackUsername', # Optional [String]: The username to send in the HTTP request to bridgeCompleteFallbackUrl and to bridgeTargetCompleteFallbackUrl. Defaults to None.
  21. fallback_password: 'fallbackPassword', # Optional [String]: The password to send in the HTTP request to bridgeCompleteFallbackUrl and to bridgeTargetCompleteFallbackUrl. Defaults to None.
  22. tag: 'tag', # Optional [String]: A custom string that will be sent with the bridgeComplete webhook and all future webhooks of the call unless overwritten by a future tag attribute or <Tag> verb, or cleared. May be cleared by setting tag="". Max length 256 characters. Defaults to None.
  23. }
  24. end
  25. end
  26. end
  27. end

lib/bandwidth-sdk/models/bxml/verbs/conference.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class Conference < Bandwidth::Bxml::Verb
  4. # Initializer
  5. # @param name [String] The name of the conference. Can contain up to 100 characters of letters, numbers, and the symbols -, _, and .
  6. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  7. 1 def initialize(name, attributes = {})
  8. 3 super('Conference', name, attributes)
  9. @attribute_map = {
  10. 3 mute: 'mute', # Optional [Boolean]: A boolean value to indicate whether the member should be on mute in the conference. When muted, a member can hear others speak, but others cannot hear them speak. Defaults to false.
  11. hold: 'hold', # Optional [Boolean]: A boolean value to indicate whether the member should be on hold in the conference. When on hold, a member cannot hear others, and they cannot be heard. Defaults to false.
  12. call_ids_to_coach: 'callIdsToCoach', # Optional [String]: A comma-separated list of call ids to coach. When a call joins a conference with this attribute set, it will coach the listed calls. Those calls will be able to hear and be heard by the coach, but other calls in the conference will not hear the coach.
  13. conference_event_url: 'conferenceEventUrl', # Optional [String]: URL to send Conference events to. The URL, method, username, and password are set by the BXML document that creates the conference, and all events related to that conference will be delivered to that same endpoint. If more calls join afterwards and also have this property (or any other webhook related properties like username and password), they will be ignored and the original webhook information will be used. This URL may be a relative endpoint.
  14. conference_event_method: 'conferenceEventMethod', # Optional [String]: The HTTP method to use for the request to conferenceEventUrl. GET or POST. Default value is POST.
  15. conference_event_fallback_url: 'conferenceEventFallbackUrl', # Optional [String]: A fallback url which, if provided, will be used to retry the conference webhook deliveries in case conferenceEventUrl fails to respond.
  16. conference_event_fallback_method: 'conferenceEventFallbackMethod', # Optional [String]: The HTTP method to use to deliver the conference webhooks to conferenceEventFallbackUrl. GET or POST. Default value is POST.
  17. username: 'username', # Optional [String]: The username to send in the HTTP request to conferenceEventUrl.
  18. password: 'password', # Optional [String]: The password to send in the HTTP request to conferenceEventUrl.
  19. fallback_username: 'fallbackUsername', # Optional [String]: The username to send in the HTTP request to conferenceEventFallbackUrl.
  20. fallback_password: 'fallbackPassword', # Optional [String]: The password to send in the HTTP request to conferenceEventFallbackUrl.
  21. tag: 'tag', # Optional [String]: A custom string that will be sent with this and all future callbacks unless overwritten by a future tag attribute or <Tag> verb, or cleared. May be cleared by setting tag="". Max length 256 characters. Defaults to None.
  22. callback_timeout: 'callbackTimeout', # Optional [Number]: This is the timeout (in seconds) to use when delivering webhooks for the conference. If not set, it will inherit the webhook timeout from the call that creates the conference. Can be any numeric value (including decimals) between 1 and 25.
  23. }
  24. end
  25. end
  26. end
  27. end

lib/bandwidth-sdk/models/bxml/verbs/custom_param.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class CustomParam < Bandwidth::Bxml::Verb
  4. # Initializer
  5. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  6. 1 def initialize(attributes = {})
  7. 7 super('CustomParam', nil, attributes)
  8. @attribute_map = {
  9. 7 name: 'name', # [String]: The name of this parameter, up to 256 characters.
  10. value: 'value', # [String]: The value of this parameter, up to 2048 characters.
  11. }
  12. end
  13. end
  14. end
  15. end

lib/bandwidth-sdk/models/bxml/verbs/forward.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class Forward < Bandwidth::Bxml::Verb
  4. # Initializer
  5. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  6. 1 def initialize(attributes = {})
  7. 3 super('Forward', nil, attributes)
  8. @attribute_map = {
  9. 3 to: 'to', # [String]: The phone number destination of the call.
  10. from: 'from', # Optional [String]: The phone number that the recipient will receive the call from.
  11. call_timeout: 'callTimeout', # Optional [Number]: The number of seconds to wait before timing out the call.
  12. diversion_treatment: 'diversionTreatment', # Optional [String]: Can be any of the following: - none: No diversion headers are sent on the outbound leg of the transferred call. - propagate: Copy the Diversion header from the inbound leg to the outbound leg. Ignored if there is no Diversion header present on the inbound leg. - stack: After propagating any Diversion header from the inbound leg to the outbound leg, stack on top another Diversion header based on the Request-URI of the inbound call. If diversionTreatment is not specified, no diversion header will be included for the transfer even if one came with the inbound call. Defaults to None.
  13. diversion_reason: 'diversionReason', # Optional [String]: Can be any of the following values: unknown, user-busy, no-answer, unavailable, unconditional, time-of-day, do-not-disturb, deflection, follow-me, out-of-service, away. This parameter is considered only when diversionTreatment is set to stack. Defaults to None.
  14. uui: 'uui', # Optional [String]: The value of the User-To-User header to send within the outbound INVITE when forwarding to a SIP URI. Must include the encoding parameter as specified in RFC 7433. Only base64 and jwt encoding are currently allowed. This value, including the encoding specifier, may not exceed 256 characters.
  15. }
  16. end
  17. end
  18. end
  19. end

lib/bandwidth-sdk/models/bxml/verbs/gather.rb

100.0% lines covered

11 relevant lines. 11 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class Gather < Bandwidth::Bxml::NestableVerb
  4. # Initializer
  5. # @param audio_verbs [Verb] or [Array<Verb>] XML element children. Defaults to an empty array. Valid nested audio verbs are: SpeakSentence, PlayAudio.
  6. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  7. 1 def initialize(audio_verbs = [], attributes = {})
  8. 6 super('Gather', nil, audio_verbs, attributes)
  9. @attribute_map = {
  10. 6 gather_url: 'gatherUrl', # Optional [String]: URL to send Gather event to and request new BXML. May be a relative URL.
  11. gather_method: 'gatherMethod', # Optional [String]: The HTTP method to use for the request to gather_url. GET or POST. Default value is POST.
  12. gather_fallback_url: 'gatherFallbackUrl', # Optional [String]: A fallback url which, if provided, will be used to retry the Gather event callback delivery in case gather_url fails to respond.
  13. gather_fallback_method: 'gatherFallbackMethod', # Optional [String]: The HTTP method to use to deliver the Gather event callback to gather_fallback_url. GET or POST. Default value is POST.
  14. username: 'username', # Optional [String]: The username to send in the HTTP request to gather_url.
  15. password: 'password', # Optional [String]: The password to send in the HTTP request to gather_url.
  16. fallback_username: 'fallbackUsername', # Optional [String]: The username to send in the HTTP request to gather_fallback_url.
  17. fallback_password: 'fallbackPassword', # Optional [String]: The password to send in the HTTP request to gather_fallback_url.
  18. tag: 'tag', # Optional [String]: A custom string that will be sent with this and all future callbacks unless overwritten by a future tag attribute or <Tag> verb, or cleared. May be cleared by setting tag="". Max length 256 characters.
  19. terminating_digits: 'terminatingDigits', # Optional [String]: When any of these digits are pressed, it will terminate the Gather. Default value is "", which disables this feature.
  20. max_digits: 'maxDigits', # Optional [Number]: Max number of digits to collect. Default value is 50. Range: decimal values between 1 - 50.
  21. inter_digit_timeout: 'interDigitTimeout', # Optional [Number]: Time (in seconds) allowed between digit presses before automatically terminating the Gather. Default value is 5. Range: decimal values between 1 - 60.
  22. first_digit_timeout: 'firstDigitTimeout', # Optional [Number]: Time (in seconds) to pause after any audio from nested <SpeakSentence> or <PlayAudio> verb is played (in seconds) before terminating the Gather. Default value is 5. Range: decimal values between 0 - 60.
  23. repeat_count: 'repeatCount', # Optional [Number]: The number of times the audio prompt should be played if no digits are pressed. For example, if this value is 3, the nested audio clip will be played a maximum of three times. The delay between repetitions will be equal to first_digit_timeout. Default value is 1. repeatCount * number of verbs must not be greater than 20.
  24. }
  25. end
  26. # Return BXML representaion of this response
  27. # @return [String] The XML response in string format.
  28. 1 def to_bxml
  29. 5 bxml = Ox.dump(generate_xml)
  30. 8 bxml.gsub(SPEAK_SENTENCE_REGEX) { |text| text.gsub(SSML_REGEX, '<\1>') }
  31. end
  32. # Add audio verb or verbs to the nested verbs array
  33. # @param audio_verbs [SpeakSentence] or [PlayAudio] or [Array<SpeakSentence || PlayAudio>] Verb or verbs to add to the array.
  34. 1 def add_audio_verbs(audio_verbs)
  35. 2 @nested_verbs.push(*audio_verbs)
  36. end
  37. end
  38. end
  39. end

lib/bandwidth-sdk/models/bxml/verbs/hangup.rb

100.0% lines covered

5 relevant lines. 5 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class Hangup < Bandwidth::Bxml::Verb
  4. # Initializer
  5. 1 def initialize
  6. 2 super('Hangup', nil, {})
  7. end
  8. end
  9. end
  10. end

lib/bandwidth-sdk/models/bxml/verbs/pause.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class Pause < Bandwidth::Bxml::Verb
  4. # Initializer
  5. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  6. 1 def initialize(attributes = {})
  7. 3 super('Pause', nil, attributes)
  8. @attribute_map = {
  9. 3 duration: 'duration', # Optional [Number]: The time in seconds to pause. Default value is 1.
  10. }
  11. end
  12. end
  13. end
  14. end

lib/bandwidth-sdk/models/bxml/verbs/pause_recording.rb

100.0% lines covered

5 relevant lines. 5 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class PauseRecording < Bandwidth::Bxml::Verb
  4. # Initializer
  5. 1 def initialize
  6. 10 super('PauseRecording', nil, {})
  7. end
  8. end
  9. end
  10. end

lib/bandwidth-sdk/models/bxml/verbs/phone_number.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class PhoneNumber < Bandwidth::Bxml::Verb
  4. # Initializer
  5. # @param number [String] A phone number to transfer the call to. Value must be in E.164 format (e.g. +15555555555).
  6. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  7. 1 def initialize(number, attributes = {})
  8. 6 super('PhoneNumber', number, attributes)
  9. @attribute_map = {
  10. 6 transfer_answer_url: 'transferAnswerUrl', # Optional [String]: URL, if any, to send the Transfer Answer event to and request BXML to be executed for the called party before the call is bridged. May be a relative URL. Defaults to None.
  11. transfer_answer_method: 'transferAnswerMethod', # Optional [String]: The HTTP method to use for the request to transferAnswerUrl. GET or POST. Default value is POST. Defaults to None.
  12. transfer_answer_fallback_url: 'transferAnswerFallbackUrl', # Optional [String]: A fallback url which, if provided, will be used to retry the Transfer Answer callback delivery in case transferAnswerUrl fails to respond. Defaults to None.
  13. transfer_answer_fallback_method: 'transferAnswerFallbackMethod', # Optional [String]: The HTTP method to use to deliver the Transfer Answer callback to transferAnswerFallbackUrl. GET or POST. Default value is POST. Defaults to None.
  14. transfer_disconnect_url: 'transferDisconnectUrl', # Optional [String]: URL, if any, to send the Transfer Disconnect event to. This event will be sent regardless of how the transfer ends and may not be responded to with BXML. May be a relative URL. Defaults to None.
  15. transfer_disconnect_method: 'transferDisconnectMethod', # Optional [String]: The HTTP method to use for the request to transferDisconnectUrl. GET or POST. Default value is POST. Defaults to Defaults to Defaults to None.
  16. username: 'username', # Optional [String]: The username to send in the HTTP request to transferAnswerUrl and transferDisconnectUrl. Defaults to Defaults to None.
  17. password: 'password', # Optional [String]: The password to send in the HTTP request to transferAnswerUrl and transferDisconnectUrl. Defaults to Defaults to None.
  18. fallback_username: 'fallbackUsername', # Optional [String]: The username to send in the HTTP request to transferAnswerFallbackUrl. Defaults to None.
  19. fallback_password: 'fallbackPassword', # Optional [String]: The password to send in the HTTP request to transferAnswerFallbackUrl. Defaults to None.
  20. tag: 'tag', # Optional [String]: A custom string that will be sent with these and all future callbacks unless overwritten by a future tag attribute or cleared. May be cleared by setting tag="" Max length 256 characters. Defaults to None.
  21. uui: 'uui', # Optional [String]: The value of the User-To-User header to send within the initial INVITE. Must include the encoding parameter as specified in RFC 7433. Only base64, jwt and hex encoding are currently allowed. This value, including the encoding specifier, may not exceed 256 characters.
  22. }
  23. end
  24. end
  25. end
  26. end

lib/bandwidth-sdk/models/bxml/verbs/play_audio.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class PlayAudio < Bandwidth::Bxml::Verb
  4. # Initializer
  5. # @param audio_uri [String] The URL of the audio file to play. May be a relative URL.
  6. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  7. 1 def initialize(audio_uri, attributes = {})
  8. 6 super('PlayAudio', audio_uri, attributes)
  9. @attribute_map = {
  10. 6 username: 'username', # Optional [String]: The username to send in the HTTP request to audio_uri.
  11. password: 'password', # Optional [String]: The password to send in the HTTP request to audio_uri.
  12. }
  13. end
  14. end
  15. end
  16. end

lib/bandwidth-sdk/models/bxml/verbs/record.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class Record < Bandwidth::Bxml::Verb
  4. # Initializer
  5. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  6. 1 def initialize(attributes = {})
  7. 3 super('Record', nil, attributes)
  8. @attribute_map = {
  9. 3 record_complete_url: 'recordCompleteUrl', # Optional [String]: URL to send the Record Complete event to once the recording has ended. Accepts BXML, and may be a relative URL. This callback will not be sent if the recording ended due to the call hanging up. Defaults to None.
  10. record_complete_method: 'recordCompleteMethod', # Optional [String]: The HTTP method to use for the request to recordCompleteUrl. GET or POST. Default value is POST. Defaults to None.
  11. record_complete_fallback_url: 'recordCompleteFallbackUrl', # Optional [String]: A fallback url which, if provided, will be used to retry the Record Complete callback delivery in case recordCompleteUrl fails to respond. Defaults to None.
  12. record_complete_fallback_method: 'recordCompleteFallbackMethod', # Optional [String]: The HTTP method to use to deliver the Record Complete callback to recordCompleteFallbackUrl. GET or POST. Default value is POST. Defaults to None.
  13. recording_available_url: 'recordingAvailableUrl', # Optional [String]: URL to send the Recording Available event to once it has been processed. Does not accept BXML. May be a relative URL. Defaults to None.
  14. recording_available_method: 'recordingAvailableMethod', # Optional [String]: The HTTP method to use for the request to recordingAvailableUrl. GET or POST. Default value is POST. Defaults to None.
  15. transcribe: 'transcribe', # Optional [Boolean]: A boolean value to indicate that recording should be transcribed. Transcription can succeed only for recordings of length greater than 500 milliseconds and less than 4 hours. Default is false. Defaults to None.
  16. transcription_available_url: 'transcriptionAvailableUrl', # Optional [String]: URL to send the Transcription Available event to once it has been processed. Does not accept BXML. May be a relative URL. Defaults to None.
  17. transcription_available_method: 'transcriptionAvailableMethod', # Optional [String]: The HTTP method to use for the request to transcriptionAvailableUrl. GET or POST. Default value is POST. Defaults to None.
  18. username: 'username', # Optional [String]: The username to send in the HTTP request to recordCompleteUrl, recordingAvailableUrl or transcriptionAvailableUrl. If specified, the URLs must be TLS-encrypted (i.e., https). Defaults to None.
  19. password: 'password', # Optional [String]: The password to send in the HTTP request to recordCompleteUrl, recordingAvailableUrl or transcriptionAvailableUrl. If specified, the URLs must be TLS-encrypted (i.e., https). Defaults to None.
  20. fallback_username: 'fallbackUsername', # Optional [String]: The username to send in the HTTP request to recordCompleteFallbackUrl. If specified, the URLs must be TLS-encrypted (i.e., https). Defaults to None.
  21. fallback_password: 'fallbackPassword', # Optional [String]: The password to send in the HTTP request to recordCompleteFallbackUrl. If specified, the URLs must be TLS-encrypted (i.e., https). Defaults to None.
  22. tag: 'tag', # Optional [String]: A custom string that will be sent with this and all future callbacks unless overwritten by a future tag attribute or <Tag> verb, or cleared. May be cleared by setting tag="". Max length 256 characters. Defaults to None.
  23. terminating_digits: 'terminatingDigits', # Optional [String]: When pressed, this digit will terminate the recording. Default value is “#”. This feature can be disabled with "". Defaults to None.
  24. max_duration: 'maxDuration', # Optional [Number]: Maximum length of recording (in seconds). Max 10800 (3 hours). Default value is 60. Defaults to None.
  25. silence_timeout: 'silenceTimeout', # Optional [Number]: Length of silence after which to end the recording (in seconds). Max is equivalent to the maximum maxDuration value. Default value is 0, which means no timeout. Defaults to None.
  26. file_format: 'fileFormat', # Optional [String]: The audio format that the recording will be saved as: mp3 or wav. Default value is wav. Defaults to None.
  27. }
  28. end
  29. end
  30. end
  31. end

lib/bandwidth-sdk/models/bxml/verbs/redirect.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class Redirect < Bandwidth::Bxml::Verb
  4. # Initializer
  5. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  6. 1 def initialize(attributes = {})
  7. 3 super('Redirect', nil, attributes)
  8. @attribute_map = {
  9. 3 redirect_url: 'redirectUrl', # [String]: URL to request new BXML from. A Redirect event will be sent to this endpoint. May be a relative URL. Defaults to None.
  10. redirect_method: 'redirectMethod', # Optional [String]: The HTTP method to use for the request to redirectUrl. GET or POST. Defaults to None.
  11. redirect_fallback_url: 'redirectFallbackUrl', # Optional [String]: A fallback url which, if provided, will be used to retry the Redirect callback delivery in case redirectUrl fails to respond. Defaults to None.
  12. redirect_fallback_method: 'redirectFallbackMethod', # Optional [String]: The HTTP method to use to deliver the Redirect callback to redirectFallbackUrl. GET or POST. Default value is POST. Defaults to None.
  13. username: 'username', # Optional [String]: The username to send in the HTTP request to redirectUrl. Defaults to None.
  14. password: 'password', # Optional [String]: The password to send in the HTTP request to redirectUrl. Defaults to None.
  15. fallback_username: 'fallbackUsername', # Optional [String]: The username to send in the HTTP request to redirectFallbackUrl. Defaults to None.
  16. fallback_password: 'fallbackPassword', # Optional [String]: The password to send in the HTTP request to redirectFallbackUrl. Defaults to None.
  17. tag: 'tag', # Optional [String]: A custom string that will be sent with this and all future callbacks unless overwritten by a future tag attribute or <Tag> verb, or cleared. May be cleared by setting tag="". Max length 256 characters. Defaults to None.
  18. }
  19. end
  20. end
  21. end
  22. end

lib/bandwidth-sdk/models/bxml/verbs/resume_recording.rb

100.0% lines covered

5 relevant lines. 5 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class ResumeRecording < Bandwidth::Bxml::Verb
  4. # Initializer
  5. 1 def initialize
  6. 2 super('ResumeRecording', nil, {})
  7. end
  8. end
  9. end
  10. end

lib/bandwidth-sdk/models/bxml/verbs/ring.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class Ring < Bandwidth::Bxml::Verb
  4. # Initializer
  5. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  6. 1 def initialize(attributes = {})
  7. 3 super('Ring', nil, attributes)
  8. @attribute_map = {
  9. 3 duration: 'duration', # Optional [Number]: How many seconds to play ringing on the call. Default value is 5. Range: decimal values between 0.1 - 86400.
  10. answer_call: 'answerCall', # Optional [Boolean]: A boolean indicating whether or not to answer the call when Ring is executed on an unanswered incoming call. Default value is 'true'.
  11. }
  12. end
  13. end
  14. end
  15. end

lib/bandwidth-sdk/models/bxml/verbs/send_dtmf.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class SendDtmf < Bandwidth::Bxml::Verb
  4. # Initializer
  5. # @param digits [String] String containing the DTMF characters to be sent in a call. Allows a maximum of 50 characters. The digits will be sent one-by-one with a marginal delay.
  6. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  7. 1 def initialize(digits, attributes = {})
  8. 3 super('SendDtmf', digits, attributes)
  9. @attribute_map = {
  10. 3 tone_duration: 'toneDuration', # Optional [Number]: The length (in milliseconds) of each DTMF tone. Default value is 200. Range: decimal values between 50 - 5000.
  11. tone_interval: 'toneInterval', # Optional [Number]: The duration of silence (in milliseconds) following each DTMF tone. Default value is 400. Range: decimal values between 50 - 5000.
  12. }
  13. end
  14. end
  15. end
  16. end

lib/bandwidth-sdk/models/bxml/verbs/sip_uri.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class SipUri < Bandwidth::Bxml::Verb
  4. # Initializer
  5. # @param uri [String] A SIP URI to transfer the call to (e.g. sip:user@server.com)
  6. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  7. 1 def initialize(uri, attributes = {})
  8. 4 super('SipUri', uri, attributes)
  9. @attribute_map = {
  10. 4 uui: 'uui', # Optional [String]: The value of the User-To-User header to send within the initial INVITE. Must include the encoding parameter as specified in RFC 7433. Only base64 and jwt encoding are currently allowed. This value, including the encoding specifier, may not exceed 256 characters. Defaults to None.
  11. transfer_answer_url: 'transferAnswerUrl', # Optional [String]: URL, if any, to send the Transfer Answer event to and request BXML to be executed for the called party before the call is bridged. May be a relative URL. Defaults to None.
  12. transfer_answer_method: 'transferAnswerMethod', # Optional [String]: The HTTP method to use for the request to transferAnswerUrl. GET or POST. Default value is POST. Defaults to None.
  13. transfer_answer_fallback_url: 'transferAnswerFallbackUrl', # Optional [String]: A fallback url which, if provided, will be used to retry the Transfer Answer callback delivery in case transferAnswerUrl fails to respond. Defaults to None.
  14. transfer_answer_fallback_method: 'transferAnswerFallbackMethod', # Optional [String]: The HTTP method to use to deliver the Transfer Answer callback to transferAnswerFallbackUrl. GET or POST. Default value is POST. Defaults to None.
  15. transfer_disconnect_url: 'transferDisconnectUrl', # Optional [String]: URL, if any, to send the Transfer Disconnect event to. This event will be sent regardless of how the transfer ends and may not be responded to with BXML. May be a relative URL. Defaults to None.
  16. transfer_disconnect_method: 'transferDisconnectMethod', # Optional [String]: The HTTP method to use for the request to transferDisconnectUrl. GET or POST. Default value is POST. Defaults to Defaults to Defaults to None.
  17. username: 'username', # Optional [String]: The username to send in the HTTP request to transferAnswerUrl and transferDisconnectUrl. Defaults to Defaults to None.
  18. password: 'password', # Optional [String]: The password to send in the HTTP request to transferAnswerUrl and transferDisconnectUrl. Defaults to Defaults to None.
  19. fallback_username: 'fallbackUsername', # Optional [String]: The username to send in the HTTP request to transferAnswerFallbackUrl. Defaults to None.
  20. fallback_password: 'fallbackPassword', # Optional [String]: The password to send in the HTTP request to transferAnswerFallbackUrl. Defaults to None.
  21. tag: 'tag', # Optional [String]: A custom string that will be sent with these and all future callbacks unless overwritten by a future tag attribute or cleared. May be cleared by setting tag="" Max length 256 characters. Defaults to None.
  22. }
  23. end
  24. end
  25. end
  26. end

lib/bandwidth-sdk/models/bxml/verbs/speak_sentence.rb

100.0% lines covered

9 relevant lines. 9 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class SpeakSentence < Bandwidth::Bxml::Verb
  4. # Initializer
  5. # @param text [String] The text to speak. Cannot be blank. Can be a mixture of plain text and SSML tags.
  6. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  7. 1 def initialize(text, attributes = {})
  8. 4 super('SpeakSentence', text, attributes)
  9. @attribute_map = {
  10. 4 voice: 'voice', # Optional [String]: Selects the voice of the speaker. If the voice attribute is present, gender and locale are ignored. You can find a list of supported voices here: https://dev.bandwidth.com/docs/voice/bxml/speakSentence/#supported-voices
  11. gender: 'gender', # Optional [String]: Selects the gender of the speaker. Valid values are "male" or "female". Default "female".
  12. locale: 'locale', # Optional [String]: Selects the locale of the speaker. Default "en_US"
  13. }
  14. end
  15. # Return BXML representaion of this response
  16. # @return [String] The XML response in string format.
  17. 1 def to_bxml
  18. 2 bxml = Ox.dump(generate_xml)
  19. 4 bxml.gsub(SPEAK_SENTENCE_REGEX) { |text| text.gsub(SSML_REGEX, '<\1>') }
  20. end
  21. end
  22. end
  23. end

lib/bandwidth-sdk/models/bxml/verbs/start_gather.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class StartGather < Bandwidth::Bxml::Verb
  4. # Initializer
  5. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  6. 1 def initialize(attributes = {})
  7. 3 super('StartGather', nil, attributes)
  8. @attribute_map = {
  9. 3 dtmf_url: 'dtmfUrl', # [String]: URL to send the DTMF event to. May be a relative URL.
  10. dtmf_method: 'dtmfMethod', # Optional [String]: The HTTP method to use for the request to dtmfUrl. GET or POST. Default value is POST.
  11. username: 'username', # Optional [String]: The username to send in the HTTP request to dtmfUrl. Defaults to None.
  12. password: 'password', # Optional [String]: The password to send in the HTTP request to dtmfUrl. Defaults to None.
  13. tag: 'tag', # Optional [String]: A custom string that will be sent with these and all future callbacks unless overwritten by a future tag attribute or cleared. May be cleared by setting tag="" Max length 256 characters. Defaults to None.
  14. }
  15. end
  16. end
  17. end
  18. end

lib/bandwidth-sdk/models/bxml/verbs/start_recording.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class StartRecording < Bandwidth::Bxml::Verb
  4. # Initializer
  5. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  6. 1 def initialize(attributes = {})
  7. 3 super('StartRecording', nil, attributes)
  8. @attribute_map = {
  9. 3 recording_available_url: 'recordingAvailableUrl', # Optional [String]: URL to send the Recording Available event to once it has been processed. Does not accept BXML. May be a relative URL. Defaults to None.
  10. recording_available_method: 'recordingAvailableMethod', # Optional [String]: The HTTP method to use for the request to recordingAvailableUrl. GET or POST. Default value is POST.
  11. transcribe: 'transcribe', # Optional [Boolean]: A boolean value to indicate that recording should be transcribed. Transcription can succeed only for recordings of length greater than 500 milliseconds and less than 4 hours. Default is false. Defaults to None.
  12. transcription_available_url: 'transcriptionAvailableUrl', # Optional [String]: URL to send the Transcription Available event to once it has been processed. Does not accept BXML. May be a relative URL. Defaults to None.
  13. transcription_available_method: 'transcriptionAvailableMethod', # Optional [String]: The HTTP method to use for the request to transcriptionAvailableUrl. GET or POST. Default value is POST. Defaults to None.
  14. username: 'username', # Optional [String]: The username to send in the HTTP request to recordingAvailableUrl or transcriptionAvailableUrl. If specified, the URLs must be TLS-encrypted (i.e., https). Defaults to None.
  15. password: 'password', # Optional [String]: The password to send in the HTTP request to recordingAvailableUrl or transcriptionAvailableUrl. If specified, the URLs must be TLS-encrypted (i.e., https). Defaults to None.
  16. tag: 'tag', # Optional [String]: A custom string that will be sent with this and all future callbacks unless overwritten by a future tag attribute or <Tag> verb, or cleared. May be cleared by setting tag="". Max length 256 characters. Defaults to None.
  17. file_format: 'fileFormat', # Optional [String]: The audio format that the recording will be saved as: mp3 or wav. Default value is wav.
  18. multi_channel: 'multiChannel', # Optional [Boolean]: A boolean value indicating whether or not the recording file should separate each side of the call into its own audio channel. Default value is false.
  19. }
  20. end
  21. end
  22. end
  23. end

lib/bandwidth-sdk/models/bxml/verbs/start_stream.rb

100.0% lines covered

8 relevant lines. 8 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class StartStream < Bandwidth::Bxml::NestableVerb
  4. # Initializer
  5. # @param stream_params [Verb] or [Array<Verb>] XML element children. Defaults to an empty array. Valid nested stream params are: StreamParam. You may specify up to 12 <StreamParam/> elements nested within a <StartStream> tag.
  6. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  7. 1 def initialize(stream_params = [], attributes = {})
  8. 6 super('StartStream', nil, stream_params, attributes)
  9. @attribute_map = {
  10. 6 name: 'name', # Optional [String]: A name to refer to this stream by. Used when sending <StopStream>. If not provided, it will default to the generated stream id as sent in the Media Stream Started webhook.
  11. mode: 'mode', # Optional [String]: The mode to use for the stream. unidirectional or bidirectional. Specifies whether the audio being streamed over the WebSocket is bidirectional (the service can both read and write audio over the WebSocket) or unidirectional (one-way, read-only). Default is unidirectional.
  12. tracks: 'tracks', # Optional [String]: The part of the call to send a stream from. inbound, outbound or both. Default is inbound.
  13. destination: 'destination', # Optional [String]: A websocket URI to send the stream to. The audio from the specified tracks will be sent via websocket to this URL as base64-encoded PCMU/G711 audio.
  14. destination_username: 'destination_username', # Optional [String]: The username to send in the `Authorization` header of the initial websocket connection to the `destination` URL.
  15. destination_password: 'destination_password', # Optional [String]: The password to send in the `Authorization` header of the initial websocket connection to the `destination` URL.
  16. stream_event_url: 'streamEventUrl', # Optional [String]: URL to send the associated Webhook events to during this stream's lifetime. Does not accept BXML. May be a relative URL.
  17. stream_event_method: 'streamEventMethod', # Optional [String]: The HTTP method to use for the request to streamEventUrl. GET or POST. Default value is POST.
  18. username: 'username', # Optional [String]: The username to send in the HTTP request to streamEventUrl. If specified, the URLs must be TLS-encrypted (i.e., https).
  19. password: 'password', # Optional [String]: The password to send in the HTTP request to streamEventUrl. If specified, the URLs must be TLS-encrypted (i.e., https).
  20. }
  21. end
  22. # Add stream param or params to the nested verbs array
  23. # @param stream_params [StreamParam] or [Array<StreamParam>] Verb or verbs to add to the array.
  24. 1 def add_stream_params(stream_params)
  25. 2 @nested_verbs.push(*stream_params)
  26. end
  27. end
  28. end
  29. end

lib/bandwidth-sdk/models/bxml/verbs/start_transcription.rb

100.0% lines covered

8 relevant lines. 8 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class StartTranscription < Bandwidth::Bxml::NestableVerb
  4. # Initializer
  5. # @param custom_params [Verb] or [Array<Verb>] XML element children. Defaults to an empty array. Valid nested custom params are: CustomParam. You may specify up to 12 <CustomParam/> elements nested within a <StartTranscription> tag.
  6. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  7. 1 def initialize(custom_params = [], attributes = {})
  8. 6 super('StartTranscription', nil, custom_params, attributes)
  9. @attribute_map = {
  10. 6 name: 'name', # Optional [String]: A name to refer to this transcription by. Used when sending <StopTranscription>. If not provided, it will default to the generated transcription id as sent in the Real-Time Transcription Started webhook.
  11. tracks: 'tracks', # Optional [String]: The part of the call to send a transcription from. inbound, outbound or both. Default is inbound.
  12. transcription_event_url: 'transcriptionEventUrl', # Optional [String]: URL to send the associated Webhook events to during this real-time transcription's lifetime. Does not accept BXML. May be a relative URL.
  13. transcription_event_method: 'transcriptionEventMethod', # Optional [String]: The HTTP method to use for the request to transcriptionEventUrl. GET or POST. Default value is POST.
  14. username: 'username', # Optional [String]: The username to send in the HTTP request to transcriptionEventUrl. If specified, the transcriptionEventUrl must be TLS-encrypted (i.e., https).
  15. password: 'password', # Optional [String]: The password to send in the HTTP request to transcriptionEventUrl. If specified, the transcriptionEventUrl must be TLS-encrypted (i.e., https).
  16. destination: 'destination', # Optional [String]: A websocket URI to send the transcription to. A transcription of the specified tracks will be sent via websocket to this URL as a series of JSON messages. See below for more details on the websocket packet format.
  17. stabilized: 'stabilized', # Optional [Boolean]: Whether to send transcription update events to the specified destination only after they have become stable. Requires destination. Defaults to true.
  18. }
  19. end
  20. # Add custom param or params to the nested verbs array
  21. # @param custom_params [CustomParam] or [Array<CustomParam>] Verb or verbs to add to the array.
  22. 1 def add_custom_params(custom_params)
  23. 2 @nested_verbs.push(*custom_params)
  24. end
  25. end
  26. end
  27. end

lib/bandwidth-sdk/models/bxml/verbs/stop_gather.rb

100.0% lines covered

5 relevant lines. 5 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class StopGather < Bandwidth::Bxml::Verb
  4. # Initializer
  5. 1 def initialize
  6. 2 super('StopGather', nil, {})
  7. end
  8. end
  9. end
  10. end

lib/bandwidth-sdk/models/bxml/verbs/stop_recording.rb

100.0% lines covered

5 relevant lines. 5 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class StopRecording < Bandwidth::Bxml::Verb
  4. # Initializer
  5. 1 def initialize
  6. 2 super('StopRecording', nil, {})
  7. end
  8. end
  9. end
  10. end

lib/bandwidth-sdk/models/bxml/verbs/stop_stream.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class StopStream < Bandwidth::Bxml::Verb
  4. # Initializer
  5. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  6. 1 def initialize(attributes = {})
  7. 3 super('StopStream', nil, attributes)
  8. @attribute_map = {
  9. 3 name: 'name', # [String]: The name of the stream to stop. This is either the user selected name when sending the <StartStream> verb, or the system generated name returned in the Media Stream Started webhook if <StartStream> was sent with no name attribute.
  10. wait: 'wait' # Optional [Boolean]: If true, the BXML interpreter will wait for the stream to stop before processing the next verb.
  11. }
  12. end
  13. end
  14. end
  15. end

lib/bandwidth-sdk/models/bxml/verbs/stop_transcription.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class StopTranscription < Bandwidth::Bxml::Verb
  4. # Initializer
  5. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  6. 1 def initialize(attributes = {})
  7. 3 super('StopTranscription', nil, attributes)
  8. @attribute_map = {
  9. 3 name: 'name' # [String]: The name of the real-time transcription to stop. This is either the user selected name when sending the <StartTranscription> verb, or the system generated name returned in the Real-Time Transcription Started webhook if <StartTranscription> was sent with no name attribute. If no name is specified, then all active call transcriptions will be stopped.
  10. }
  11. end
  12. end
  13. end
  14. end

lib/bandwidth-sdk/models/bxml/verbs/stream_param.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class StreamParam < Bandwidth::Bxml::Verb
  4. # Initializer
  5. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  6. 1 def initialize(attributes = {})
  7. 7 super('StreamParam', nil, attributes)
  8. @attribute_map = {
  9. 7 name: 'name', # [String]: The name of this parameter, up to 256 characters.
  10. value: 'value', # [String]: The value of this parameter, up to 2048 characters.
  11. }
  12. end
  13. end
  14. end
  15. end

lib/bandwidth-sdk/models/bxml/verbs/tag.rb

100.0% lines covered

5 relevant lines. 5 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class Tag < Bandwidth::Bxml::Verb
  4. # Initializer
  5. # @param content [String] Custom tag value. Defaults to nil.
  6. 1 def initialize(content = nil)
  7. 2 super('Tag', content, {})
  8. end
  9. end
  10. end
  11. end

lib/bandwidth-sdk/models/bxml/verbs/transfer.rb

100.0% lines covered

8 relevant lines. 8 lines covered and 0 lines missed.
    
  1. 1 module Bandwidth
  2. 1 module Bxml
  3. 1 class Transfer < Bandwidth::Bxml::NestableVerb
  4. # Initializer
  5. # @param transfer_to [Verb] or [Array<Verb>] XML element children. Defaults to an empty array. Valid nested transfer verbs are: PhoneNumber, SipUri.
  6. # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash.
  7. 1 def initialize(transfer_to = [], attributes = {})
  8. 6 super('Transfer', nil, transfer_to, attributes)
  9. @attribute_map = {
  10. 6 transfer_caller_id: 'transferCallerId', # Optional [String]: The caller ID to use when the call is transferred, if different. Must be in E.164 format (e.g. +15555555555) or be one of the following strings Restricted, Anonymous, Private, or Unavailable. Leave as default to pass along the number of the remote party. Defaults to None.
  11. transfer_caller_display_name: 'transferCallerDisplayName', # Optional [String]: The caller display name to use when the call is transferred. May not exceed 256 characters nor contain control characters such as new lines. Defaults to None.
  12. call_timeout: 'callTimeout', # Optional [Number]: The timeout (in seconds) for the callee to answer the call after it starts ringing. If the call does not start ringing within 30s, the call will be cancelled regardless of this value. Range: decimal values between 1 - 300. Default value is 30 seconds. Defaults to None.
  13. transfer_complete_url: 'transferCompleteUrl', # Optional [String]: URL to send the Transfer Complete event to and request new BXML. Optional but recommended. See below for further details. May be a relative URL. Defaults to None.
  14. transfer_complete_method: 'transferCompleteMethod', # Optional [String]: The HTTP method to use for the request to transferCompleteUrl. GET or POST. Default value is POST. Defaults to None.
  15. transfer_complete_fallback_url: 'transferCompleteFallbackUrl', # Optional [String]: A fallback url which, if provided, will be used to retry the Transfer Complete callback delivery in case transferCompleteUrl fails to respond. Defaults to None.
  16. transfer_complete_fallback_method: 'transferCompleteFallbackMethod', # Optional [String]: The HTTP method to use to deliver the Transfer Complete callback to transferCompleteFallbackUrl. GET or POST. Default value is POST. Defaults to None.
  17. username: 'username', # Optional [String]: The username to send in the HTTP request to transferCompleteUrl. Defaults to None.
  18. password: 'password', # Optional [String]: The password to send in the HTTP request to transferCompleteUrl. Defaults to None.
  19. fallback_username: 'fallbackUsername', # Optional [String]: The username to send in the HTTP request to transferCompleteFallbackUrl. Defaults to None.
  20. fallback_password: 'fallbackPassword', # Optional [String]: The password to send in the HTTP request to transferCompleteFallbackUrl. Defaults to None.
  21. tag: 'tag', # Optional [String]: A custom string that will be sent with this and all future callbacks unless overwritten by a future tag attribute or cleared. May be cleared by setting tag="" Max length 256 characters. Defaults to None.
  22. diversion_treatment: 'diversionTreatment', # Optional [String]: Can be any of the following: - none: No diversion headers are sent on the outbound leg of the transferred call. - propagate: Copy the Diversion header from the inbound leg to the outbound leg. Ignored if there is no Diversion header present on the inbound leg. - stack: After propagating any Diversion header from the inbound leg to the outbound leg, stack on top another Diversion header based on the Request-URI of the inbound call. If diversionTreatment is not specified, no diversion header will be included for the transfer even if one came with the inbound call. Defaults to None.
  23. diversion_reason: 'diversionReason', # Optional [String]: Can be any of the following values: unknown, user-busy, no-answer, unavailable, unconditional, time-of-day, do-not-disturb, deflection, follow-me, out-of-service, away. This parameter is considered only when diversionTreatment is set to stack. Defaults to None.
  24. }
  25. end
  26. # Add transfer recipient or recipients to the nested verbs array
  27. # @param recipients [PhoneNumber] or [SipUri] or [Array<PhoneNumber || SipUri>] Verb or verbs to add to the array.
  28. 1 def add_transfer_recipients(recipients)
  29. 2 @nested_verbs.push(*recipients)
  30. end
  31. end
  32. end
  33. end

lib/bandwidth-sdk/models/call_direction_enum.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CallDirectionEnum
  13. 1 INBOUND = 'inbound'.freeze
  14. 1 OUTBOUND = 'outbound'.freeze
  15. 1 def self.all_vars
  16. 29 @all_vars ||= [INBOUND, OUTBOUND].freeze
  17. end
  18. # Builds the enum from string
  19. # @param [String] The enum value in the form of the string
  20. # @return [String] The enum value
  21. 1 def self.build_from_hash(value)
  22. 24 new.build_from_hash(value)
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def build_from_hash(value)
  28. 24 return value if CallDirectionEnum.all_vars.include?(value)
  29. 1 raise "Invalid ENUM value #{value} for class #CallDirectionEnum"
  30. end
  31. end
  32. end

lib/bandwidth-sdk/models/call_recording_metadata.rb

86.51% lines covered

126 relevant lines. 109 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CallRecordingMetadata < ApiModelBase
  13. # The id of the application associated with the call.
  14. 1 attr_accessor :application_id
  15. # The user account associated with the call.
  16. 1 attr_accessor :account_id
  17. # The call id associated with the event.
  18. 1 attr_accessor :call_id
  19. # (optional) If the event is related to the B leg of a <Transfer>, the call id of the original call leg that executed the <Transfer>. Otherwise, this field will not be present.
  20. 1 attr_accessor :parent_call_id
  21. # The unique ID of this recording
  22. 1 attr_accessor :recording_id
  23. # The phone number that received the call, in E.164 format (e.g. +15555555555).
  24. 1 attr_accessor :to
  25. # The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555).
  26. 1 attr_accessor :from
  27. # The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555).
  28. 1 attr_accessor :transfer_caller_id
  29. # The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555).
  30. 1 attr_accessor :transfer_to
  31. # The duration of the recording in ISO-8601 format
  32. 1 attr_accessor :duration
  33. 1 attr_accessor :direction
  34. # Always `1` for conference recordings; multi-channel recordings are not supported on conferences.
  35. 1 attr_accessor :channels
  36. # Time the call was started, in ISO 8601 format.
  37. 1 attr_accessor :start_time
  38. # The time that the recording ended in ISO-8601 format
  39. 1 attr_accessor :end_time
  40. 1 attr_accessor :file_format
  41. # The current status of the process. For recording, current possible values are 'processing', 'partial', 'complete', 'deleted', and 'error'. For transcriptions, current possible values are 'none', 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and 'file-size-too-small'. Additional states may be added in the future, so your application must be tolerant of unknown values.
  42. 1 attr_accessor :status
  43. # The URL that can be used to download the recording. Only present if the recording is finished and may be downloaded.
  44. 1 attr_accessor :media_url
  45. 1 attr_accessor :transcription
  46. # A name to identify this recording.
  47. 1 attr_accessor :recording_name
  48. 1 class EnumAttributeValidator
  49. 1 attr_reader :datatype
  50. 1 attr_reader :allowable_values
  51. 1 def initialize(datatype, allowable_values)
  52. @allowable_values = allowable_values.map do |value|
  53. case datatype.to_s
  54. when /Integer/i
  55. value.to_i
  56. when /Float/i
  57. value.to_f
  58. else
  59. value
  60. end
  61. end
  62. end
  63. 1 def valid?(value)
  64. !value || allowable_values.include?(value)
  65. end
  66. end
  67. # Attribute mapping from ruby-style variable name to JSON key.
  68. 1 def self.attribute_map
  69. 239 {
  70. :'application_id' => :'applicationId',
  71. :'account_id' => :'accountId',
  72. :'call_id' => :'callId',
  73. :'parent_call_id' => :'parentCallId',
  74. :'recording_id' => :'recordingId',
  75. :'to' => :'to',
  76. :'from' => :'from',
  77. :'transfer_caller_id' => :'transferCallerId',
  78. :'transfer_to' => :'transferTo',
  79. :'duration' => :'duration',
  80. :'direction' => :'direction',
  81. :'channels' => :'channels',
  82. :'start_time' => :'startTime',
  83. :'end_time' => :'endTime',
  84. :'file_format' => :'fileFormat',
  85. :'status' => :'status',
  86. :'media_url' => :'mediaUrl',
  87. :'transcription' => :'transcription',
  88. :'recording_name' => :'recordingName'
  89. }
  90. end
  91. # Returns attribute mapping this model knows about
  92. 1 def self.acceptable_attribute_map
  93. 10 attribute_map
  94. end
  95. # Returns all the JSON keys this model knows about
  96. 1 def self.acceptable_attributes
  97. 1 acceptable_attribute_map.values
  98. end
  99. # Attribute type mapping.
  100. 1 def self.openapi_types
  101. 3 {
  102. :'application_id' => :'String',
  103. :'account_id' => :'String',
  104. :'call_id' => :'String',
  105. :'parent_call_id' => :'String',
  106. :'recording_id' => :'String',
  107. :'to' => :'String',
  108. :'from' => :'String',
  109. :'transfer_caller_id' => :'String',
  110. :'transfer_to' => :'String',
  111. :'duration' => :'String',
  112. :'direction' => :'CallDirectionEnum',
  113. :'channels' => :'Integer',
  114. :'start_time' => :'Time',
  115. :'end_time' => :'Time',
  116. :'file_format' => :'FileFormatEnum',
  117. :'status' => :'String',
  118. :'media_url' => :'String',
  119. :'transcription' => :'RecordingTranscriptionMetadata',
  120. :'recording_name' => :'String'
  121. }
  122. end
  123. # List of attributes with nullable: true
  124. 1 def self.openapi_nullable
  125. 1 Set.new([
  126. :'media_url',
  127. :'transcription',
  128. ])
  129. end
  130. # Initializes the object
  131. # @param [Hash] attributes Model attributes in the form of hash
  132. 1 def initialize(attributes = {})
  133. 10 if (!attributes.is_a?(Hash))
  134. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CallRecordingMetadata` initialize method'
  135. end
  136. # check to see if the attribute exists and convert string to symbol for hash key
  137. 9 acceptable_attribute_map = self.class.acceptable_attribute_map
  138. 9 attributes = attributes.each_with_object({}) { |(k, v), h|
  139. 114 if (!acceptable_attribute_map.key?(k.to_sym))
  140. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CallRecordingMetadata`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  141. end
  142. 113 h[k.to_sym] = v
  143. }
  144. 8 if attributes.key?(:'application_id')
  145. 6 self.application_id = attributes[:'application_id']
  146. end
  147. 8 if attributes.key?(:'account_id')
  148. 6 self.account_id = attributes[:'account_id']
  149. end
  150. 8 if attributes.key?(:'call_id')
  151. 6 self.call_id = attributes[:'call_id']
  152. end
  153. 8 if attributes.key?(:'parent_call_id')
  154. 6 self.parent_call_id = attributes[:'parent_call_id']
  155. end
  156. 8 if attributes.key?(:'recording_id')
  157. 6 self.recording_id = attributes[:'recording_id']
  158. end
  159. 8 if attributes.key?(:'to')
  160. 6 self.to = attributes[:'to']
  161. end
  162. 8 if attributes.key?(:'from')
  163. 6 self.from = attributes[:'from']
  164. end
  165. 8 if attributes.key?(:'transfer_caller_id')
  166. 6 self.transfer_caller_id = attributes[:'transfer_caller_id']
  167. end
  168. 8 if attributes.key?(:'transfer_to')
  169. 6 self.transfer_to = attributes[:'transfer_to']
  170. end
  171. 8 if attributes.key?(:'duration')
  172. 6 self.duration = attributes[:'duration']
  173. end
  174. 8 if attributes.key?(:'direction')
  175. 6 self.direction = attributes[:'direction']
  176. end
  177. 8 if attributes.key?(:'channels')
  178. 6 self.channels = attributes[:'channels']
  179. end
  180. 8 if attributes.key?(:'start_time')
  181. 6 self.start_time = attributes[:'start_time']
  182. end
  183. 8 if attributes.key?(:'end_time')
  184. 6 self.end_time = attributes[:'end_time']
  185. end
  186. 8 if attributes.key?(:'file_format')
  187. 6 self.file_format = attributes[:'file_format']
  188. end
  189. 8 if attributes.key?(:'status')
  190. 6 self.status = attributes[:'status']
  191. end
  192. 8 if attributes.key?(:'media_url')
  193. 6 self.media_url = attributes[:'media_url']
  194. end
  195. 8 if attributes.key?(:'transcription')
  196. 5 self.transcription = attributes[:'transcription']
  197. end
  198. 8 if attributes.key?(:'recording_name')
  199. 6 self.recording_name = attributes[:'recording_name']
  200. end
  201. end
  202. # Show invalid properties with the reasons. Usually used together with valid?
  203. # @return Array for valid properties with the reasons
  204. 1 def list_invalid_properties
  205. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  206. invalid_properties = Array.new
  207. invalid_properties
  208. end
  209. # Check to see if the all the properties in the model are valid
  210. # @return true if the model is valid
  211. 1 def valid?
  212. warn '[DEPRECATED] the `valid?` method is obsolete'
  213. true
  214. end
  215. # Checks equality by comparing each attribute.
  216. # @param [Object] Object to be compared
  217. 1 def ==(o)
  218. 2 return true if self.equal?(o)
  219. 2 self.class == o.class &&
  220. application_id == o.application_id &&
  221. account_id == o.account_id &&
  222. call_id == o.call_id &&
  223. parent_call_id == o.parent_call_id &&
  224. recording_id == o.recording_id &&
  225. to == o.to &&
  226. from == o.from &&
  227. transfer_caller_id == o.transfer_caller_id &&
  228. transfer_to == o.transfer_to &&
  229. duration == o.duration &&
  230. direction == o.direction &&
  231. channels == o.channels &&
  232. start_time == o.start_time &&
  233. end_time == o.end_time &&
  234. file_format == o.file_format &&
  235. status == o.status &&
  236. media_url == o.media_url &&
  237. transcription == o.transcription &&
  238. recording_name == o.recording_name
  239. end
  240. # @see the `==` method
  241. # @param [Object] Object to be compared
  242. 1 def eql?(o)
  243. 2 self == o
  244. end
  245. # Calculates hash code according to all attributes.
  246. # @return [Integer] Hash code
  247. 1 def hash
  248. [application_id, account_id, call_id, parent_call_id, recording_id, to, from, transfer_caller_id, transfer_to, duration, direction, channels, start_time, end_time, file_format, status, media_url, transcription, recording_name].hash
  249. end
  250. # Builds the object from hash
  251. # @param [Hash] attributes Model attributes in the form of hash
  252. # @return [Object] Returns the model itself
  253. 1 def self.build_from_hash(attributes)
  254. 3 return nil unless attributes.is_a?(Hash)
  255. 3 attributes = attributes.transform_keys(&:to_sym)
  256. 3 transformed_hash = {}
  257. 3 openapi_types.each_pair do |key, type|
  258. 57 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  259. transformed_hash["#{key}"] = nil
  260. 57 elsif type =~ /\AArray<(.*)>/i
  261. # check to ensure the input is an array given that the attribute
  262. # is documented as an array but the input is not
  263. if attributes[attribute_map[key]].is_a?(Array)
  264. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  265. end
  266. 57 elsif !attributes[attribute_map[key]].nil?
  267. 56 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  268. end
  269. end
  270. 3 new(transformed_hash)
  271. end
  272. # Returns the object in the form of hash
  273. # @return [Hash] Returns the object in the form of hash
  274. 1 def to_hash
  275. 2 hash = {}
  276. 2 self.class.attribute_map.each_pair do |attr, param|
  277. 38 value = self.send(attr)
  278. 38 if value.nil?
  279. is_nullable = self.class.openapi_nullable.include?(attr)
  280. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  281. end
  282. 38 hash[param] = _to_hash(value)
  283. end
  284. 2 hash
  285. end
  286. end
  287. end

lib/bandwidth-sdk/models/call_state.rb

88.71% lines covered

124 relevant lines. 110 lines covered and 14 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CallState < ApiModelBase
  13. # The application id associated with the call.
  14. 1 attr_accessor :application_id
  15. # The account id associated with the call.
  16. 1 attr_accessor :account_id
  17. # The programmable voice API call ID.
  18. 1 attr_accessor :call_id
  19. # The A-leg call id, set only if this call is the B-leg of a [`<Transfer>`](/docs/voice/bxml/transfer).
  20. 1 attr_accessor :parent_call_id
  21. # The phone number that received the call, in E.164 format (e.g. +15555555555), or if the call was to a SIP URI, the SIP URI.
  22. 1 attr_accessor :to
  23. # The phone number that made the call, in E.164 format (e.g. +15555555555).
  24. 1 attr_accessor :from
  25. 1 attr_accessor :direction
  26. # The current state of the call. Current possible values are `queued`, `initiated`, `answered` and `disconnected`. Additional states may be added in the future, so your application must be tolerant of unknown values.
  27. 1 attr_accessor :state
  28. # For inbound calls, the Bandwidth STIR/SHAKEN implementation will verify the information provided in the inbound invite request `Identity` header. The verification status is stored in the call state `stirShaken` property as follows. | Property | Description | |:------------------|:------------| | verstat | (optional) The verification status indicating whether the verification was successful or not. Possible values are `TN-Validation-Passed` or `TN-Validation-Failed`. | | attestationIndicator | (optional) The attestation level verified by Bandwidth. Possible values are `A` (full), `B` (partial) or `C` (gateway). | | originatingId | (optional) A unique origination identifier. | Note that these are common properties but that the `stirShaken` object is free form and can contain other key-value pairs. More information: [Understanding STIR/SHAKEN](https://www.bandwidth.com/regulations/stir-shaken).
  29. 1 attr_accessor :stir_shaken
  30. # The value of the `Identity` header from the inbound invite request. Only present for inbound calls and if the account is configured to forward this header.
  31. 1 attr_accessor :identity
  32. # The time this call was placed in queue.
  33. 1 attr_accessor :enqueued_time
  34. # The time the call was initiated, in ISO 8601 format. `null` if the call is still in your queue.
  35. 1 attr_accessor :start_time
  36. # Populated once the call has been answered, with the time in ISO 8601 format.
  37. 1 attr_accessor :answer_time
  38. # Populated once the call has ended, with the time in ISO 8601 format.
  39. 1 attr_accessor :end_time
  40. # | Cause | Description | |:------|:------------| | `hangup`| One party hung up the call, a [`<Hangup>`](../../bxml/verbs/hangup.md) verb was executed, or there was no more BXML to execute; it indicates that the call ended normally. | | `busy` | Callee was busy. | | `timeout` | Call wasn't answered before the `callTimeout` was reached. | | `cancel` | Call was cancelled by its originator while it was ringing. | | `rejected` | Call was rejected by the callee. | | `callback-error` | BXML callback couldn't be delivered to your callback server. | | `invalid-bxml` | Invalid BXML was returned in response to a callback. | | `application-error` | An unsupported action was tried on the call, e.g. trying to play a .ogg audio. | | `account-limit` | Account rate limits were reached. | | `node-capacity-exceeded` | System maximum capacity was reached. | | `error` | Some error not described in any of the other causes happened on the call. | | `unknown` | Unknown error happened on the call. | Note: This list is not exhaustive and other values can appear in the future.
  41. 1 attr_accessor :disconnect_cause
  42. # Populated only if the call ended with an error, with text explaining the reason.
  43. 1 attr_accessor :error_message
  44. # Populated only if the call ended with an error, with a Bandwidth internal id that references the error event.
  45. 1 attr_accessor :error_id
  46. # The last time the call had a state update, in ISO 8601 format.
  47. 1 attr_accessor :last_update
  48. 1 class EnumAttributeValidator
  49. 1 attr_reader :datatype
  50. 1 attr_reader :allowable_values
  51. 1 def initialize(datatype, allowable_values)
  52. @allowable_values = allowable_values.map do |value|
  53. case datatype.to_s
  54. when /Integer/i
  55. value.to_i
  56. when /Float/i
  57. value.to_f
  58. else
  59. value
  60. end
  61. end
  62. end
  63. 1 def valid?(value)
  64. !value || allowable_values.include?(value)
  65. end
  66. end
  67. # Attribute mapping from ruby-style variable name to JSON key.
  68. 1 def self.attribute_map
  69. 217 {
  70. :'application_id' => :'applicationId',
  71. :'account_id' => :'accountId',
  72. :'call_id' => :'callId',
  73. :'parent_call_id' => :'parentCallId',
  74. :'to' => :'to',
  75. :'from' => :'from',
  76. :'direction' => :'direction',
  77. :'state' => :'state',
  78. :'stir_shaken' => :'stirShaken',
  79. :'identity' => :'identity',
  80. :'enqueued_time' => :'enqueuedTime',
  81. :'start_time' => :'startTime',
  82. :'answer_time' => :'answerTime',
  83. :'end_time' => :'endTime',
  84. :'disconnect_cause' => :'disconnectCause',
  85. :'error_message' => :'errorMessage',
  86. :'error_id' => :'errorId',
  87. :'last_update' => :'lastUpdate'
  88. }
  89. end
  90. # Returns attribute mapping this model knows about
  91. 1 def self.acceptable_attribute_map
  92. 10 attribute_map
  93. end
  94. # Returns all the JSON keys this model knows about
  95. 1 def self.acceptable_attributes
  96. 1 acceptable_attribute_map.values
  97. end
  98. # Attribute type mapping.
  99. 1 def self.openapi_types
  100. 3 {
  101. :'application_id' => :'String',
  102. :'account_id' => :'String',
  103. :'call_id' => :'String',
  104. :'parent_call_id' => :'String',
  105. :'to' => :'String',
  106. :'from' => :'String',
  107. :'direction' => :'CallDirectionEnum',
  108. :'state' => :'String',
  109. :'stir_shaken' => :'Hash<String, String>',
  110. :'identity' => :'String',
  111. :'enqueued_time' => :'Time',
  112. :'start_time' => :'Time',
  113. :'answer_time' => :'Time',
  114. :'end_time' => :'Time',
  115. :'disconnect_cause' => :'String',
  116. :'error_message' => :'String',
  117. :'error_id' => :'String',
  118. :'last_update' => :'Time'
  119. }
  120. end
  121. # List of attributes with nullable: true
  122. 1 def self.openapi_nullable
  123. 5 Set.new([
  124. :'parent_call_id',
  125. :'stir_shaken',
  126. :'identity',
  127. :'enqueued_time',
  128. :'start_time',
  129. :'answer_time',
  130. :'end_time',
  131. :'disconnect_cause',
  132. :'error_message',
  133. :'error_id',
  134. ])
  135. end
  136. # Initializes the object
  137. # @param [Hash] attributes Model attributes in the form of hash
  138. 1 def initialize(attributes = {})
  139. 10 if (!attributes.is_a?(Hash))
  140. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CallState` initialize method'
  141. end
  142. # check to see if the attribute exists and convert string to symbol for hash key
  143. 9 acceptable_attribute_map = self.class.acceptable_attribute_map
  144. 9 attributes = attributes.each_with_object({}) { |(k, v), h|
  145. 109 if (!acceptable_attribute_map.key?(k.to_sym))
  146. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CallState`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  147. end
  148. 108 h[k.to_sym] = v
  149. }
  150. 8 if attributes.key?(:'application_id')
  151. 6 self.application_id = attributes[:'application_id']
  152. end
  153. 8 if attributes.key?(:'account_id')
  154. 6 self.account_id = attributes[:'account_id']
  155. end
  156. 8 if attributes.key?(:'call_id')
  157. 6 self.call_id = attributes[:'call_id']
  158. end
  159. 8 if attributes.key?(:'parent_call_id')
  160. 6 self.parent_call_id = attributes[:'parent_call_id']
  161. end
  162. 8 if attributes.key?(:'to')
  163. 6 self.to = attributes[:'to']
  164. end
  165. 8 if attributes.key?(:'from')
  166. 6 self.from = attributes[:'from']
  167. end
  168. 8 if attributes.key?(:'direction')
  169. 6 self.direction = attributes[:'direction']
  170. end
  171. 8 if attributes.key?(:'state')
  172. 6 self.state = attributes[:'state']
  173. end
  174. 8 if attributes.key?(:'stir_shaken')
  175. 6 if (value = attributes[:'stir_shaken']).is_a?(Hash)
  176. 6 self.stir_shaken = value
  177. end
  178. end
  179. 8 if attributes.key?(:'identity')
  180. 6 self.identity = attributes[:'identity']
  181. end
  182. 8 if attributes.key?(:'enqueued_time')
  183. 6 self.enqueued_time = attributes[:'enqueued_time']
  184. end
  185. 8 if attributes.key?(:'start_time')
  186. 6 self.start_time = attributes[:'start_time']
  187. end
  188. 8 if attributes.key?(:'answer_time')
  189. 6 self.answer_time = attributes[:'answer_time']
  190. end
  191. 8 if attributes.key?(:'end_time')
  192. 6 self.end_time = attributes[:'end_time']
  193. end
  194. 8 if attributes.key?(:'disconnect_cause')
  195. 6 self.disconnect_cause = attributes[:'disconnect_cause']
  196. end
  197. 8 if attributes.key?(:'error_message')
  198. 6 self.error_message = attributes[:'error_message']
  199. end
  200. 8 if attributes.key?(:'error_id')
  201. 6 self.error_id = attributes[:'error_id']
  202. end
  203. 8 if attributes.key?(:'last_update')
  204. 6 self.last_update = attributes[:'last_update']
  205. end
  206. end
  207. # Show invalid properties with the reasons. Usually used together with valid?
  208. # @return Array for valid properties with the reasons
  209. 1 def list_invalid_properties
  210. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  211. invalid_properties = Array.new
  212. invalid_properties
  213. end
  214. # Check to see if the all the properties in the model are valid
  215. # @return true if the model is valid
  216. 1 def valid?
  217. warn '[DEPRECATED] the `valid?` method is obsolete'
  218. true
  219. end
  220. # Checks equality by comparing each attribute.
  221. # @param [Object] Object to be compared
  222. 1 def ==(o)
  223. 2 return true if self.equal?(o)
  224. 2 self.class == o.class &&
  225. application_id == o.application_id &&
  226. account_id == o.account_id &&
  227. call_id == o.call_id &&
  228. parent_call_id == o.parent_call_id &&
  229. to == o.to &&
  230. from == o.from &&
  231. direction == o.direction &&
  232. state == o.state &&
  233. stir_shaken == o.stir_shaken &&
  234. identity == o.identity &&
  235. enqueued_time == o.enqueued_time &&
  236. start_time == o.start_time &&
  237. answer_time == o.answer_time &&
  238. end_time == o.end_time &&
  239. disconnect_cause == o.disconnect_cause &&
  240. error_message == o.error_message &&
  241. error_id == o.error_id &&
  242. last_update == o.last_update
  243. end
  244. # @see the `==` method
  245. # @param [Object] Object to be compared
  246. 1 def eql?(o)
  247. 2 self == o
  248. end
  249. # Calculates hash code according to all attributes.
  250. # @return [Integer] Hash code
  251. 1 def hash
  252. [application_id, account_id, call_id, parent_call_id, to, from, direction, state, stir_shaken, identity, enqueued_time, start_time, answer_time, end_time, disconnect_cause, error_message, error_id, last_update].hash
  253. end
  254. # Builds the object from hash
  255. # @param [Hash] attributes Model attributes in the form of hash
  256. # @return [Object] Returns the model itself
  257. 1 def self.build_from_hash(attributes)
  258. 3 return nil unless attributes.is_a?(Hash)
  259. 3 attributes = attributes.transform_keys(&:to_sym)
  260. 3 transformed_hash = {}
  261. 3 openapi_types.each_pair do |key, type|
  262. 54 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  263. 6 transformed_hash["#{key}"] = nil
  264. 48 elsif type =~ /\AArray<(.*)>/i
  265. # check to ensure the input is an array given that the attribute
  266. # is documented as an array but the input is not
  267. if attributes[attribute_map[key]].is_a?(Array)
  268. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  269. end
  270. 48 elsif !attributes[attribute_map[key]].nil?
  271. 48 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  272. end
  273. end
  274. 3 new(transformed_hash)
  275. end
  276. # Returns the object in the form of hash
  277. # @return [Hash] Returns the object in the form of hash
  278. 1 def to_hash
  279. 2 hash = {}
  280. 2 self.class.attribute_map.each_pair do |attr, param|
  281. 36 value = self.send(attr)
  282. 36 if value.nil?
  283. 4 is_nullable = self.class.openapi_nullable.include?(attr)
  284. 4 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  285. end
  286. 36 hash[param] = _to_hash(value)
  287. end
  288. 2 hash
  289. end
  290. end
  291. end

lib/bandwidth-sdk/models/call_state_enum.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CallStateEnum
  13. 1 ACTIVE = 'active'.freeze
  14. 1 COMPLETED = 'completed'.freeze
  15. 1 def self.all_vars
  16. 5 @all_vars ||= [ACTIVE, COMPLETED].freeze
  17. end
  18. # Builds the enum from string
  19. # @param [String] The enum value in the form of the string
  20. # @return [String] The enum value
  21. 1 def self.build_from_hash(value)
  22. 4 new.build_from_hash(value)
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def build_from_hash(value)
  28. 4 return value if CallStateEnum.all_vars.include?(value)
  29. 1 raise "Invalid ENUM value #{value} for class #CallStateEnum"
  30. end
  31. end
  32. end

lib/bandwidth-sdk/models/call_transcription.rb

75.79% lines covered

95 relevant lines. 72 lines covered and 23 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CallTranscription < ApiModelBase
  13. 1 attr_accessor :detected_language
  14. 1 attr_accessor :track
  15. # The transcription itself.
  16. 1 attr_accessor :transcript
  17. # How confident the transcription engine was in transcribing the associated audio (from `0` to `1`).
  18. 1 attr_accessor :confidence
  19. 1 class EnumAttributeValidator
  20. 1 attr_reader :datatype
  21. 1 attr_reader :allowable_values
  22. 1 def initialize(datatype, allowable_values)
  23. @allowable_values = allowable_values.map do |value|
  24. case datatype.to_s
  25. when /Integer/i
  26. value.to_i
  27. when /Float/i
  28. value.to_f
  29. else
  30. value
  31. end
  32. end
  33. end
  34. 1 def valid?(value)
  35. !value || allowable_values.include?(value)
  36. end
  37. end
  38. # Attribute mapping from ruby-style variable name to JSON key.
  39. 1 def self.attribute_map
  40. 69 {
  41. :'detected_language' => :'detectedLanguage',
  42. :'track' => :'track',
  43. :'transcript' => :'transcript',
  44. :'confidence' => :'confidence'
  45. }
  46. end
  47. # Returns attribute mapping this model knows about
  48. 1 def self.acceptable_attribute_map
  49. 16 attribute_map
  50. end
  51. # Returns all the JSON keys this model knows about
  52. 1 def self.acceptable_attributes
  53. 1 acceptable_attribute_map.values
  54. end
  55. # Attribute type mapping.
  56. 1 def self.openapi_types
  57. 3 {
  58. :'detected_language' => :'CallTranscriptionDetectedLanguageEnum',
  59. :'track' => :'CallTranscriptionTrackEnum',
  60. :'transcript' => :'String',
  61. :'confidence' => :'Float'
  62. }
  63. end
  64. # List of attributes with nullable: true
  65. 1 def self.openapi_nullable
  66. 1 Set.new([
  67. ])
  68. end
  69. # Initializes the object
  70. # @param [Hash] attributes Model attributes in the form of hash
  71. 1 def initialize(attributes = {})
  72. 16 if (!attributes.is_a?(Hash))
  73. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CallTranscription` initialize method'
  74. end
  75. # check to see if the attribute exists and convert string to symbol for hash key
  76. 15 acceptable_attribute_map = self.class.acceptable_attribute_map
  77. 15 attributes = attributes.each_with_object({}) { |(k, v), h|
  78. 40 if (!acceptable_attribute_map.key?(k.to_sym))
  79. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CallTranscription`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  80. end
  81. 39 h[k.to_sym] = v
  82. }
  83. 14 if attributes.key?(:'detected_language')
  84. 9 self.detected_language = attributes[:'detected_language']
  85. end
  86. 14 if attributes.key?(:'track')
  87. 9 self.track = attributes[:'track']
  88. end
  89. 14 if attributes.key?(:'transcript')
  90. 9 self.transcript = attributes[:'transcript']
  91. end
  92. 14 if attributes.key?(:'confidence')
  93. 12 self.confidence = attributes[:'confidence']
  94. end
  95. end
  96. # Show invalid properties with the reasons. Usually used together with valid?
  97. # @return Array for valid properties with the reasons
  98. 1 def list_invalid_properties
  99. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  100. invalid_properties = Array.new
  101. if !@confidence.nil? && @confidence > 1
  102. invalid_properties.push('invalid value for "confidence", must be smaller than or equal to 1.')
  103. end
  104. if !@confidence.nil? && @confidence < 0
  105. invalid_properties.push('invalid value for "confidence", must be greater than or equal to 0.')
  106. end
  107. invalid_properties
  108. end
  109. # Check to see if the all the properties in the model are valid
  110. # @return true if the model is valid
  111. 1 def valid?
  112. warn '[DEPRECATED] the `valid?` method is obsolete'
  113. return false if !@confidence.nil? && @confidence > 1
  114. return false if !@confidence.nil? && @confidence < 0
  115. true
  116. end
  117. # Custom attribute writer method with validation
  118. # @param [Object] confidence Value to be assigned
  119. 1 def confidence=(confidence)
  120. 12 if confidence.nil?
  121. 1 fail ArgumentError, 'confidence cannot be nil'
  122. end
  123. 11 if confidence > 1
  124. 1 fail ArgumentError, 'invalid value for "confidence", must be smaller than or equal to 1.'
  125. end
  126. 10 if confidence < 0
  127. 1 fail ArgumentError, 'invalid value for "confidence", must be greater than or equal to 0.'
  128. end
  129. 9 @confidence = confidence
  130. end
  131. # Checks equality by comparing each attribute.
  132. # @param [Object] Object to be compared
  133. 1 def ==(o)
  134. 2 return true if self.equal?(o)
  135. 2 self.class == o.class &&
  136. detected_language == o.detected_language &&
  137. track == o.track &&
  138. transcript == o.transcript &&
  139. confidence == o.confidence
  140. end
  141. # @see the `==` method
  142. # @param [Object] Object to be compared
  143. 1 def eql?(o)
  144. 2 self == o
  145. end
  146. # Calculates hash code according to all attributes.
  147. # @return [Integer] Hash code
  148. 1 def hash
  149. [detected_language, track, transcript, confidence].hash
  150. end
  151. # Builds the object from hash
  152. # @param [Hash] attributes Model attributes in the form of hash
  153. # @return [Object] Returns the model itself
  154. 1 def self.build_from_hash(attributes)
  155. 3 return nil unless attributes.is_a?(Hash)
  156. 3 attributes = attributes.transform_keys(&:to_sym)
  157. 3 transformed_hash = {}
  158. 3 openapi_types.each_pair do |key, type|
  159. 12 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  160. transformed_hash["#{key}"] = nil
  161. 12 elsif type =~ /\AArray<(.*)>/i
  162. # check to ensure the input is an array given that the attribute
  163. # is documented as an array but the input is not
  164. if attributes[attribute_map[key]].is_a?(Array)
  165. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  166. end
  167. 12 elsif !attributes[attribute_map[key]].nil?
  168. 12 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  169. end
  170. end
  171. 3 new(transformed_hash)
  172. end
  173. # Returns the object in the form of hash
  174. # @return [Hash] Returns the object in the form of hash
  175. 1 def to_hash
  176. 4 hash = {}
  177. 4 self.class.attribute_map.each_pair do |attr, param|
  178. 16 value = self.send(attr)
  179. 16 if value.nil?
  180. is_nullable = self.class.openapi_nullable.include?(attr)
  181. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  182. end
  183. 16 hash[param] = _to_hash(value)
  184. end
  185. 4 hash
  186. end
  187. end
  188. end

lib/bandwidth-sdk/models/call_transcription_detected_language_enum.rb

100.0% lines covered

14 relevant lines. 14 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CallTranscriptionDetectedLanguageEnum
  13. 1 EN_US = 'en-US'.freeze
  14. 1 ES_US = 'es-US'.freeze
  15. 1 FR_FR = 'fr-FR'.freeze
  16. 1 def self.all_vars
  17. 9 @all_vars ||= [EN_US, ES_US, FR_FR].freeze
  18. end
  19. # Builds the enum from string
  20. # @param [String] The enum value in the form of the string
  21. # @return [String] The enum value
  22. 1 def self.build_from_hash(value)
  23. 7 new.build_from_hash(value)
  24. end
  25. # Builds the enum from string
  26. # @param [String] The enum value in the form of the string
  27. # @return [String] The enum value
  28. 1 def build_from_hash(value)
  29. 7 return value if CallTranscriptionDetectedLanguageEnum.all_vars.include?(value)
  30. 1 raise "Invalid ENUM value #{value} for class #CallTranscriptionDetectedLanguageEnum"
  31. end
  32. end
  33. end

lib/bandwidth-sdk/models/call_transcription_metadata.rb

83.58% lines covered

67 relevant lines. 56 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CallTranscriptionMetadata < ApiModelBase
  13. # The programmable voice API transcription ID.
  14. 1 attr_accessor :transcription_id
  15. # The programmable voice API transcription name. This name could be provided by the user when creating the transcription.
  16. 1 attr_accessor :transcription_name
  17. # A URL that may be used to retrieve the transcription itself. This points to the [Get Call Transcription](/apis/voice-apis/voice/#tag/Transcriptions/operation/getRealTimeTranscription) endpoint.
  18. 1 attr_accessor :transcription_url
  19. # Attribute mapping from ruby-style variable name to JSON key.
  20. 1 def self.attribute_map
  21. 36 {
  22. :'transcription_id' => :'transcriptionId',
  23. :'transcription_name' => :'transcriptionName',
  24. :'transcription_url' => :'transcriptionUrl'
  25. }
  26. end
  27. # Returns attribute mapping this model knows about
  28. 1 def self.acceptable_attribute_map
  29. 9 attribute_map
  30. end
  31. # Returns all the JSON keys this model knows about
  32. 1 def self.acceptable_attributes
  33. 1 acceptable_attribute_map.values
  34. end
  35. # Attribute type mapping.
  36. 1 def self.openapi_types
  37. 2 {
  38. :'transcription_id' => :'String',
  39. :'transcription_name' => :'String',
  40. :'transcription_url' => :'String'
  41. }
  42. end
  43. # List of attributes with nullable: true
  44. 1 def self.openapi_nullable
  45. 1 Set.new([
  46. ])
  47. end
  48. # Initializes the object
  49. # @param [Hash] attributes Model attributes in the form of hash
  50. 1 def initialize(attributes = {})
  51. 9 if (!attributes.is_a?(Hash))
  52. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CallTranscriptionMetadata` initialize method'
  53. end
  54. # check to see if the attribute exists and convert string to symbol for hash key
  55. 8 acceptable_attribute_map = self.class.acceptable_attribute_map
  56. 8 attributes = attributes.each_with_object({}) { |(k, v), h|
  57. 16 if (!acceptable_attribute_map.key?(k.to_sym))
  58. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CallTranscriptionMetadata`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  59. end
  60. 15 h[k.to_sym] = v
  61. }
  62. 7 if attributes.key?(:'transcription_id')
  63. 5 self.transcription_id = attributes[:'transcription_id']
  64. end
  65. 7 if attributes.key?(:'transcription_name')
  66. 5 self.transcription_name = attributes[:'transcription_name']
  67. end
  68. 7 if attributes.key?(:'transcription_url')
  69. 5 self.transcription_url = attributes[:'transcription_url']
  70. end
  71. end
  72. # Show invalid properties with the reasons. Usually used together with valid?
  73. # @return Array for valid properties with the reasons
  74. 1 def list_invalid_properties
  75. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  76. invalid_properties = Array.new
  77. invalid_properties
  78. end
  79. # Check to see if the all the properties in the model are valid
  80. # @return true if the model is valid
  81. 1 def valid?
  82. warn '[DEPRECATED] the `valid?` method is obsolete'
  83. true
  84. end
  85. # Checks equality by comparing each attribute.
  86. # @param [Object] Object to be compared
  87. 1 def ==(o)
  88. 2 return true if self.equal?(o)
  89. 2 self.class == o.class &&
  90. transcription_id == o.transcription_id &&
  91. transcription_name == o.transcription_name &&
  92. transcription_url == o.transcription_url
  93. end
  94. # @see the `==` method
  95. # @param [Object] Object to be compared
  96. 1 def eql?(o)
  97. 2 self == o
  98. end
  99. # Calculates hash code according to all attributes.
  100. # @return [Integer] Hash code
  101. 1 def hash
  102. [transcription_id, transcription_name, transcription_url].hash
  103. end
  104. # Builds the object from hash
  105. # @param [Hash] attributes Model attributes in the form of hash
  106. # @return [Object] Returns the model itself
  107. 1 def self.build_from_hash(attributes)
  108. 2 return nil unless attributes.is_a?(Hash)
  109. 2 attributes = attributes.transform_keys(&:to_sym)
  110. 2 transformed_hash = {}
  111. 2 openapi_types.each_pair do |key, type|
  112. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  113. transformed_hash["#{key}"] = nil
  114. 6 elsif type =~ /\AArray<(.*)>/i
  115. # check to ensure the input is an array given that the attribute
  116. # is documented as an array but the input is not
  117. if attributes[attribute_map[key]].is_a?(Array)
  118. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  119. end
  120. 6 elsif !attributes[attribute_map[key]].nil?
  121. 6 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  122. end
  123. end
  124. 2 new(transformed_hash)
  125. end
  126. # Returns the object in the form of hash
  127. # @return [Hash] Returns the object in the form of hash
  128. 1 def to_hash
  129. 2 hash = {}
  130. 2 self.class.attribute_map.each_pair do |attr, param|
  131. 6 value = self.send(attr)
  132. 6 if value.nil?
  133. is_nullable = self.class.openapi_nullable.include?(attr)
  134. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  135. end
  136. 6 hash[param] = _to_hash(value)
  137. end
  138. 2 hash
  139. end
  140. end
  141. end

lib/bandwidth-sdk/models/call_transcription_response.rb

87.32% lines covered

71 relevant lines. 62 lines covered and 9 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CallTranscriptionResponse < ApiModelBase
  13. # The user account associated with the call.
  14. 1 attr_accessor :account_id
  15. # The call id associated with the event.
  16. 1 attr_accessor :call_id
  17. # The programmable voice API transcription ID.
  18. 1 attr_accessor :transcription_id
  19. 1 attr_accessor :tracks
  20. # Attribute mapping from ruby-style variable name to JSON key.
  21. 1 def self.attribute_map
  22. 44 {
  23. :'account_id' => :'accountId',
  24. :'call_id' => :'callId',
  25. :'transcription_id' => :'transcriptionId',
  26. :'tracks' => :'tracks'
  27. }
  28. end
  29. # Returns attribute mapping this model knows about
  30. 1 def self.acceptable_attribute_map
  31. 9 attribute_map
  32. end
  33. # Returns all the JSON keys this model knows about
  34. 1 def self.acceptable_attributes
  35. 1 acceptable_attribute_map.values
  36. end
  37. # Attribute type mapping.
  38. 1 def self.openapi_types
  39. 2 {
  40. :'account_id' => :'String',
  41. :'call_id' => :'String',
  42. :'transcription_id' => :'String',
  43. :'tracks' => :'Array<CallTranscription>'
  44. }
  45. end
  46. # List of attributes with nullable: true
  47. 1 def self.openapi_nullable
  48. 1 Set.new([
  49. ])
  50. end
  51. # Initializes the object
  52. # @param [Hash] attributes Model attributes in the form of hash
  53. 1 def initialize(attributes = {})
  54. 9 if (!attributes.is_a?(Hash))
  55. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CallTranscriptionResponse` initialize method'
  56. end
  57. # check to see if the attribute exists and convert string to symbol for hash key
  58. 8 acceptable_attribute_map = self.class.acceptable_attribute_map
  59. 8 attributes = attributes.each_with_object({}) { |(k, v), h|
  60. 21 if (!acceptable_attribute_map.key?(k.to_sym))
  61. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CallTranscriptionResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  62. end
  63. 20 h[k.to_sym] = v
  64. }
  65. 7 if attributes.key?(:'account_id')
  66. 5 self.account_id = attributes[:'account_id']
  67. end
  68. 7 if attributes.key?(:'call_id')
  69. 5 self.call_id = attributes[:'call_id']
  70. end
  71. 7 if attributes.key?(:'transcription_id')
  72. 5 self.transcription_id = attributes[:'transcription_id']
  73. end
  74. 7 if attributes.key?(:'tracks')
  75. 5 if (value = attributes[:'tracks']).is_a?(Array)
  76. 5 self.tracks = value
  77. end
  78. end
  79. end
  80. # Show invalid properties with the reasons. Usually used together with valid?
  81. # @return Array for valid properties with the reasons
  82. 1 def list_invalid_properties
  83. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  84. invalid_properties = Array.new
  85. invalid_properties
  86. end
  87. # Check to see if the all the properties in the model are valid
  88. # @return true if the model is valid
  89. 1 def valid?
  90. warn '[DEPRECATED] the `valid?` method is obsolete'
  91. true
  92. end
  93. # Checks equality by comparing each attribute.
  94. # @param [Object] Object to be compared
  95. 1 def ==(o)
  96. 2 return true if self.equal?(o)
  97. 2 self.class == o.class &&
  98. account_id == o.account_id &&
  99. call_id == o.call_id &&
  100. transcription_id == o.transcription_id &&
  101. tracks == o.tracks
  102. end
  103. # @see the `==` method
  104. # @param [Object] Object to be compared
  105. 1 def eql?(o)
  106. 2 self == o
  107. end
  108. # Calculates hash code according to all attributes.
  109. # @return [Integer] Hash code
  110. 1 def hash
  111. [account_id, call_id, transcription_id, tracks].hash
  112. end
  113. # Builds the object from hash
  114. # @param [Hash] attributes Model attributes in the form of hash
  115. # @return [Object] Returns the model itself
  116. 1 def self.build_from_hash(attributes)
  117. 2 return nil unless attributes.is_a?(Hash)
  118. 2 attributes = attributes.transform_keys(&:to_sym)
  119. 2 transformed_hash = {}
  120. 2 openapi_types.each_pair do |key, type|
  121. 8 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  122. transformed_hash["#{key}"] = nil
  123. 8 elsif type =~ /\AArray<(.*)>/i
  124. # check to ensure the input is an array given that the attribute
  125. # is documented as an array but the input is not
  126. 2 if attributes[attribute_map[key]].is_a?(Array)
  127. 4 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  128. end
  129. 6 elsif !attributes[attribute_map[key]].nil?
  130. 6 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  131. end
  132. end
  133. 2 new(transformed_hash)
  134. end
  135. # Returns the object in the form of hash
  136. # @return [Hash] Returns the object in the form of hash
  137. 1 def to_hash
  138. 2 hash = {}
  139. 2 self.class.attribute_map.each_pair do |attr, param|
  140. 8 value = self.send(attr)
  141. 8 if value.nil?
  142. is_nullable = self.class.openapi_nullable.include?(attr)
  143. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  144. end
  145. 8 hash[param] = _to_hash(value)
  146. end
  147. 2 hash
  148. end
  149. end
  150. end

lib/bandwidth-sdk/models/call_transcription_track_enum.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CallTranscriptionTrackEnum
  13. 1 INBOUND = 'inbound'.freeze
  14. 1 OUTBOUND = 'outbound'.freeze
  15. 1 def self.all_vars
  16. 8 @all_vars ||= [INBOUND, OUTBOUND].freeze
  17. end
  18. # Builds the enum from string
  19. # @param [String] The enum value in the form of the string
  20. # @return [String] The enum value
  21. 1 def self.build_from_hash(value)
  22. 6 new.build_from_hash(value)
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def build_from_hash(value)
  28. 6 return value if CallTranscriptionTrackEnum.all_vars.include?(value)
  29. 1 raise "Invalid ENUM value #{value} for class #CallTranscriptionTrackEnum"
  30. end
  31. end
  32. end

lib/bandwidth-sdk/models/callback.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # Callbacks are divided into two types based on direction of the related message: - `statusCallback` indicates status of an outbound MT SMS, MMS, or RBM message. - `inboundCallback` indicates an inbound MO message or a multichannel message client's response to a suggestion or location request.
  13. 1 module Callback
  14. 1 class << self
  15. # List of class defined in oneOf (OpenAPI v3)
  16. 1 def openapi_one_of
  17. 2 [
  18. :'InboundCallback',
  19. :'StatusCallback'
  20. ]
  21. end
  22. # Discriminator's property name (OpenAPI v3)
  23. 1 def openapi_discriminator_name
  24. 11 :'type'
  25. end
  26. # Discriminator's mapping (OpenAPI v3)
  27. 1 def openapi_discriminator_mapping
  28. 13 {
  29. :'message-delivered' => :'StatusCallback',
  30. :'message-failed' => :'StatusCallback',
  31. :'message-read' => :'StatusCallback',
  32. :'message-received' => :'InboundCallback',
  33. :'message-sending' => :'StatusCallback',
  34. :'message-sent' => :'StatusCallback',
  35. :'request-location-response' => :'InboundCallback',
  36. :'suggestion-response' => :'InboundCallback'
  37. }
  38. end
  39. # Builds the object
  40. # @param [Mixed] Data to be matched against the list of oneOf items
  41. # @return [Object] Returns the model or the data itself
  42. 1 def build(data)
  43. 10 discriminator_value = data[openapi_discriminator_name]
  44. 10 return nil if discriminator_value.nil?
  45. 9 klass = openapi_discriminator_mapping[discriminator_value.to_s.to_sym]
  46. 9 return nil unless klass
  47. 8 Bandwidth.const_get(klass).build_from_hash(data)
  48. end
  49. end
  50. end
  51. end

lib/bandwidth-sdk/models/callback_method_enum.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CallbackMethodEnum
  13. 1 GET = 'GET'.freeze
  14. 1 POST = 'POST'.freeze
  15. 1 def self.all_vars
  16. 24 @all_vars ||= [GET, POST].freeze
  17. end
  18. # Builds the enum from string
  19. # @param [String] The enum value in the form of the string
  20. # @return [String] The enum value
  21. 1 def self.build_from_hash(value)
  22. 18 new.build_from_hash(value)
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def build_from_hash(value)
  28. 18 return value if CallbackMethodEnum.all_vars.include?(value)
  29. 1 raise "Invalid ENUM value #{value} for class #CallbackMethodEnum"
  30. end
  31. end
  32. end

lib/bandwidth-sdk/models/card_width_enum.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CardWidthEnum
  13. 1 SMALL = 'SMALL'.freeze
  14. 1 MEDIUM = 'MEDIUM'.freeze
  15. 1 def self.all_vars
  16. 6 @all_vars ||= [SMALL, MEDIUM].freeze
  17. end
  18. # Builds the enum from string
  19. # @param [String] The enum value in the form of the string
  20. # @return [String] The enum value
  21. 1 def self.build_from_hash(value)
  22. 5 new.build_from_hash(value)
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def build_from_hash(value)
  28. 5 return value if CardWidthEnum.all_vars.include?(value)
  29. 1 raise "Invalid ENUM value #{value} for class #CardWidthEnum"
  30. end
  31. end
  32. end

lib/bandwidth-sdk/models/code_request.rb

66.46% lines covered

164 relevant lines. 109 lines covered and 55 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CodeRequest < ApiModelBase
  13. # The phone number to send the mfa code to.
  14. 1 attr_accessor :to
  15. # The application phone number, the sender of the mfa code.
  16. 1 attr_accessor :from
  17. # The application unique ID, obtained from Bandwidth.
  18. 1 attr_accessor :application_id
  19. # An optional field to denote what scope or action the mfa code is addressing. If not supplied, defaults to \"2FA\".
  20. 1 attr_accessor :scope
  21. # The message format of the mfa code. There are three values that the system will replace \"{CODE}\", \"{NAME}\", \"{SCOPE}\". The \"{SCOPE}\" and \"{NAME} value template are optional, while \"{CODE}\" must be supplied. As the name would suggest, code will be replace with the actual mfa code. Name is replaced with the application name, configured during provisioning of mfa. The scope value is the same value sent during the call and partitioned by the server.
  22. 1 attr_accessor :message
  23. # The number of digits for your mfa code. The valid number ranges from 2 to 8, inclusively.
  24. 1 attr_accessor :digits
  25. # Attribute mapping from ruby-style variable name to JSON key.
  26. 1 def self.attribute_map
  27. 53 {
  28. :'to' => :'to',
  29. :'from' => :'from',
  30. :'application_id' => :'applicationId',
  31. :'scope' => :'scope',
  32. :'message' => :'message',
  33. :'digits' => :'digits'
  34. }
  35. end
  36. # Returns attribute mapping this model knows about
  37. 1 def self.acceptable_attribute_map
  38. 24 attribute_map
  39. end
  40. # Returns all the JSON keys this model knows about
  41. 1 def self.acceptable_attributes
  42. 1 acceptable_attribute_map.values
  43. end
  44. # Attribute type mapping.
  45. 1 def self.openapi_types
  46. 1 {
  47. :'to' => :'String',
  48. :'from' => :'String',
  49. :'application_id' => :'String',
  50. :'scope' => :'String',
  51. :'message' => :'String',
  52. :'digits' => :'Integer'
  53. }
  54. end
  55. # List of attributes with nullable: true
  56. 1 def self.openapi_nullable
  57. 3 Set.new([
  58. ])
  59. end
  60. # Initializes the object
  61. # @param [Hash] attributes Model attributes in the form of hash
  62. 1 def initialize(attributes = {})
  63. 24 if (!attributes.is_a?(Hash))
  64. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CodeRequest` initialize method'
  65. end
  66. # check to see if the attribute exists and convert string to symbol for hash key
  67. 23 acceptable_attribute_map = self.class.acceptable_attribute_map
  68. 23 attributes = attributes.each_with_object({}) { |(k, v), h|
  69. 117 if (!acceptable_attribute_map.key?(k.to_sym))
  70. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CodeRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  71. end
  72. 116 h[k.to_sym] = v
  73. }
  74. 22 if attributes.key?(:'to')
  75. 22 self.to = attributes[:'to']
  76. else
  77. self.to = nil
  78. end
  79. 20 if attributes.key?(:'from')
  80. 20 self.from = attributes[:'from']
  81. else
  82. self.from = nil
  83. end
  84. 17 if attributes.key?(:'application_id')
  85. 17 self.application_id = attributes[:'application_id']
  86. else
  87. self.application_id = nil
  88. end
  89. 15 if attributes.key?(:'scope')
  90. 6 self.scope = attributes[:'scope']
  91. end
  92. 13 if attributes.key?(:'message')
  93. 13 self.message = attributes[:'message']
  94. else
  95. self.message = nil
  96. end
  97. 11 if attributes.key?(:'digits')
  98. 11 self.digits = attributes[:'digits']
  99. else
  100. self.digits = nil
  101. end
  102. end
  103. # Show invalid properties with the reasons. Usually used together with valid?
  104. # @return Array for valid properties with the reasons
  105. 1 def list_invalid_properties
  106. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  107. invalid_properties = Array.new
  108. if @to.nil?
  109. invalid_properties.push('invalid value for "to", to cannot be nil.')
  110. end
  111. pattern = Regexp.new(/^\+[1-9]\d{1,14}$/)
  112. if @to !~ pattern
  113. invalid_properties.push("invalid value for \"to\", must conform to the pattern #{pattern}.")
  114. end
  115. if @from.nil?
  116. invalid_properties.push('invalid value for "from", from cannot be nil.')
  117. end
  118. if @from.to_s.length > 32
  119. invalid_properties.push('invalid value for "from", the character length must be smaller than or equal to 32.')
  120. end
  121. pattern = Regexp.new(/^\+[1-9]\d{1,14}$/)
  122. if @from !~ pattern
  123. invalid_properties.push("invalid value for \"from\", must conform to the pattern #{pattern}.")
  124. end
  125. if @application_id.nil?
  126. invalid_properties.push('invalid value for "application_id", application_id cannot be nil.')
  127. end
  128. if @application_id.to_s.length > 50
  129. invalid_properties.push('invalid value for "application_id", the character length must be smaller than or equal to 50.')
  130. end
  131. if !@scope.nil? && @scope.to_s.length > 25
  132. invalid_properties.push('invalid value for "scope", the character length must be smaller than or equal to 25.')
  133. end
  134. if @message.nil?
  135. invalid_properties.push('invalid value for "message", message cannot be nil.')
  136. end
  137. if @message.to_s.length > 2048
  138. invalid_properties.push('invalid value for "message", the character length must be smaller than or equal to 2048.')
  139. end
  140. if @digits.nil?
  141. invalid_properties.push('invalid value for "digits", digits cannot be nil.')
  142. end
  143. if @digits > 8
  144. invalid_properties.push('invalid value for "digits", must be smaller than or equal to 8.')
  145. end
  146. if @digits < 4
  147. invalid_properties.push('invalid value for "digits", must be greater than or equal to 4.')
  148. end
  149. invalid_properties
  150. end
  151. # Check to see if the all the properties in the model are valid
  152. # @return true if the model is valid
  153. 1 def valid?
  154. warn '[DEPRECATED] the `valid?` method is obsolete'
  155. return false if @to.nil?
  156. return false if @to !~ Regexp.new(/^\+[1-9]\d{1,14}$/)
  157. return false if @from.nil?
  158. return false if @from.to_s.length > 32
  159. return false if @from !~ Regexp.new(/^\+[1-9]\d{1,14}$/)
  160. return false if @application_id.nil?
  161. return false if @application_id.to_s.length > 50
  162. return false if !@scope.nil? && @scope.to_s.length > 25
  163. return false if @message.nil?
  164. return false if @message.to_s.length > 2048
  165. return false if @digits.nil?
  166. return false if @digits > 8
  167. return false if @digits < 4
  168. true
  169. end
  170. # Custom attribute writer method with validation
  171. # @param [Object] to Value to be assigned
  172. 1 def to=(to)
  173. 22 if to.nil?
  174. 1 fail ArgumentError, 'to cannot be nil'
  175. end
  176. 21 pattern = Regexp.new(/^\+[1-9]\d{1,14}$/)
  177. 21 if to !~ pattern
  178. 1 fail ArgumentError, "invalid value for \"to\", must conform to the pattern #{pattern}."
  179. end
  180. 20 @to = to
  181. end
  182. # Custom attribute writer method with validation
  183. # @param [Object] from Value to be assigned
  184. 1 def from=(from)
  185. 20 if from.nil?
  186. 1 fail ArgumentError, 'from cannot be nil'
  187. end
  188. 19 if from.to_s.length > 32
  189. 1 fail ArgumentError, 'invalid value for "from", the character length must be smaller than or equal to 32.'
  190. end
  191. 18 pattern = Regexp.new(/^\+[1-9]\d{1,14}$/)
  192. 18 if from !~ pattern
  193. 1 fail ArgumentError, "invalid value for \"from\", must conform to the pattern #{pattern}."
  194. end
  195. 17 @from = from
  196. end
  197. # Custom attribute writer method with validation
  198. # @param [Object] application_id Value to be assigned
  199. 1 def application_id=(application_id)
  200. 17 if application_id.nil?
  201. 1 fail ArgumentError, 'application_id cannot be nil'
  202. end
  203. 16 if application_id.to_s.length > 50
  204. 1 fail ArgumentError, 'invalid value for "application_id", the character length must be smaller than or equal to 50.'
  205. end
  206. 15 @application_id = application_id
  207. end
  208. # Custom attribute writer method with validation
  209. # @param [Object] scope Value to be assigned
  210. 1 def scope=(scope)
  211. 6 if scope.nil?
  212. 1 fail ArgumentError, 'scope cannot be nil'
  213. end
  214. 5 if scope.to_s.length > 25
  215. 1 fail ArgumentError, 'invalid value for "scope", the character length must be smaller than or equal to 25.'
  216. end
  217. 4 @scope = scope
  218. end
  219. # Custom attribute writer method with validation
  220. # @param [Object] message Value to be assigned
  221. 1 def message=(message)
  222. 13 if message.nil?
  223. 1 fail ArgumentError, 'message cannot be nil'
  224. end
  225. 12 if message.to_s.length > 2048
  226. 1 fail ArgumentError, 'invalid value for "message", the character length must be smaller than or equal to 2048.'
  227. end
  228. 11 @message = message
  229. end
  230. # Custom attribute writer method with validation
  231. # @param [Object] digits Value to be assigned
  232. 1 def digits=(digits)
  233. 11 if digits.nil?
  234. 1 fail ArgumentError, 'digits cannot be nil'
  235. end
  236. 10 if digits > 8
  237. 1 fail ArgumentError, 'invalid value for "digits", must be smaller than or equal to 8.'
  238. end
  239. 9 if digits < 4
  240. 1 fail ArgumentError, 'invalid value for "digits", must be greater than or equal to 4.'
  241. end
  242. 8 @digits = digits
  243. end
  244. # Checks equality by comparing each attribute.
  245. # @param [Object] Object to be compared
  246. 1 def ==(o)
  247. 2 return true if self.equal?(o)
  248. 2 self.class == o.class &&
  249. to == o.to &&
  250. from == o.from &&
  251. application_id == o.application_id &&
  252. scope == o.scope &&
  253. message == o.message &&
  254. digits == o.digits
  255. end
  256. # @see the `==` method
  257. # @param [Object] Object to be compared
  258. 1 def eql?(o)
  259. 2 self == o
  260. end
  261. # Calculates hash code according to all attributes.
  262. # @return [Integer] Hash code
  263. 1 def hash
  264. [to, from, application_id, scope, message, digits].hash
  265. end
  266. # Builds the object from hash
  267. # @param [Hash] attributes Model attributes in the form of hash
  268. # @return [Object] Returns the model itself
  269. 1 def self.build_from_hash(attributes)
  270. 1 return nil unless attributes.is_a?(Hash)
  271. 1 attributes = attributes.transform_keys(&:to_sym)
  272. 1 transformed_hash = {}
  273. 1 openapi_types.each_pair do |key, type|
  274. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  275. transformed_hash["#{key}"] = nil
  276. 6 elsif type =~ /\AArray<(.*)>/i
  277. # check to ensure the input is an array given that the attribute
  278. # is documented as an array but the input is not
  279. if attributes[attribute_map[key]].is_a?(Array)
  280. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  281. end
  282. 6 elsif !attributes[attribute_map[key]].nil?
  283. 6 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  284. end
  285. end
  286. 1 new(transformed_hash)
  287. end
  288. # Returns the object in the form of hash
  289. # @return [Hash] Returns the object in the form of hash
  290. 1 def to_hash
  291. 4 hash = {}
  292. 4 self.class.attribute_map.each_pair do |attr, param|
  293. 24 value = self.send(attr)
  294. 24 if value.nil?
  295. 2 is_nullable = self.class.openapi_nullable.include?(attr)
  296. 2 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  297. end
  298. 22 hash[param] = _to_hash(value)
  299. end
  300. 4 hash
  301. end
  302. end
  303. end

lib/bandwidth-sdk/models/completed_lookup_status_enum.rb

100.0% lines covered

14 relevant lines. 14 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CompletedLookupStatusEnum
  13. 1 COMPLETE = 'COMPLETE'.freeze
  14. 1 PARTIAL_COMPLETE = 'PARTIAL_COMPLETE'.freeze
  15. 1 FAILED = 'FAILED'.freeze
  16. 1 def self.all_vars
  17. 8 @all_vars ||= [COMPLETE, PARTIAL_COMPLETE, FAILED].freeze
  18. end
  19. # Builds the enum from string
  20. # @param [String] The enum value in the form of the string
  21. # @return [String] The enum value
  22. 1 def self.build_from_hash(value)
  23. 7 new.build_from_hash(value)
  24. end
  25. # Builds the enum from string
  26. # @param [String] The enum value in the form of the string
  27. # @return [String] The enum value
  28. 1 def build_from_hash(value)
  29. 7 return value if CompletedLookupStatusEnum.all_vars.include?(value)
  30. 1 raise "Invalid ENUM value #{value} for class #CompletedLookupStatusEnum"
  31. end
  32. end
  33. end

lib/bandwidth-sdk/models/conference.rb

84.21% lines covered

95 relevant lines. 80 lines covered and 15 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class Conference < ApiModelBase
  13. # The Bandwidth-generated conference ID.
  14. 1 attr_accessor :id
  15. # The name of the conference, as specified by your application.
  16. 1 attr_accessor :name
  17. # The time the conference was initiated, in ISO 8601 format.
  18. 1 attr_accessor :created_time
  19. # The time the conference was terminated, in ISO 8601 format.
  20. 1 attr_accessor :completed_time
  21. # The URL to send the conference-related events.
  22. 1 attr_accessor :conference_event_url
  23. 1 attr_accessor :conference_event_method
  24. # The custom string attached to the conference that will be sent with callbacks.
  25. 1 attr_accessor :tag
  26. # A list of active members of the conference. Omitted if this is a response to the [Get Conferences endpoint](/apis/voice#tag/Conferences/operation/listConferences).
  27. 1 attr_accessor :active_members
  28. 1 class EnumAttributeValidator
  29. 1 attr_reader :datatype
  30. 1 attr_reader :allowable_values
  31. 1 def initialize(datatype, allowable_values)
  32. @allowable_values = allowable_values.map do |value|
  33. case datatype.to_s
  34. when /Integer/i
  35. value.to_i
  36. when /Float/i
  37. value.to_f
  38. else
  39. value
  40. end
  41. end
  42. end
  43. 1 def valid?(value)
  44. !value || allowable_values.include?(value)
  45. end
  46. end
  47. # Attribute mapping from ruby-style variable name to JSON key.
  48. 1 def self.attribute_map
  49. 107 {
  50. :'id' => :'id',
  51. :'name' => :'name',
  52. :'created_time' => :'createdTime',
  53. :'completed_time' => :'completedTime',
  54. :'conference_event_url' => :'conferenceEventUrl',
  55. :'conference_event_method' => :'conferenceEventMethod',
  56. :'tag' => :'tag',
  57. :'active_members' => :'activeMembers'
  58. }
  59. end
  60. # Returns attribute mapping this model knows about
  61. 1 def self.acceptable_attribute_map
  62. 10 attribute_map
  63. end
  64. # Returns all the JSON keys this model knows about
  65. 1 def self.acceptable_attributes
  66. 1 acceptable_attribute_map.values
  67. end
  68. # Attribute type mapping.
  69. 1 def self.openapi_types
  70. 3 {
  71. :'id' => :'String',
  72. :'name' => :'String',
  73. :'created_time' => :'Time',
  74. :'completed_time' => :'Time',
  75. :'conference_event_url' => :'String',
  76. :'conference_event_method' => :'CallbackMethodEnum',
  77. :'tag' => :'String',
  78. :'active_members' => :'Array<ConferenceMember>'
  79. }
  80. end
  81. # List of attributes with nullable: true
  82. 1 def self.openapi_nullable
  83. 1 Set.new([
  84. :'completed_time',
  85. :'conference_event_url',
  86. :'conference_event_method',
  87. :'tag',
  88. :'active_members'
  89. ])
  90. end
  91. # Initializes the object
  92. # @param [Hash] attributes Model attributes in the form of hash
  93. 1 def initialize(attributes = {})
  94. 10 if (!attributes.is_a?(Hash))
  95. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::Conference` initialize method'
  96. end
  97. # check to see if the attribute exists and convert string to symbol for hash key
  98. 9 acceptable_attribute_map = self.class.acceptable_attribute_map
  99. 9 attributes = attributes.each_with_object({}) { |(k, v), h|
  100. 48 if (!acceptable_attribute_map.key?(k.to_sym))
  101. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::Conference`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  102. end
  103. 47 h[k.to_sym] = v
  104. }
  105. 8 if attributes.key?(:'id')
  106. 6 self.id = attributes[:'id']
  107. end
  108. 8 if attributes.key?(:'name')
  109. 6 self.name = attributes[:'name']
  110. end
  111. 8 if attributes.key?(:'created_time')
  112. 6 self.created_time = attributes[:'created_time']
  113. end
  114. 8 if attributes.key?(:'completed_time')
  115. 6 self.completed_time = attributes[:'completed_time']
  116. end
  117. 8 if attributes.key?(:'conference_event_url')
  118. 6 self.conference_event_url = attributes[:'conference_event_url']
  119. end
  120. 8 if attributes.key?(:'conference_event_method')
  121. 6 self.conference_event_method = attributes[:'conference_event_method']
  122. else
  123. 2 self.conference_event_method = 'POST'
  124. end
  125. 8 if attributes.key?(:'tag')
  126. 6 self.tag = attributes[:'tag']
  127. end
  128. 8 if attributes.key?(:'active_members')
  129. 5 if (value = attributes[:'active_members']).is_a?(Array)
  130. 5 self.active_members = value
  131. end
  132. end
  133. end
  134. # Show invalid properties with the reasons. Usually used together with valid?
  135. # @return Array for valid properties with the reasons
  136. 1 def list_invalid_properties
  137. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  138. invalid_properties = Array.new
  139. invalid_properties
  140. end
  141. # Check to see if the all the properties in the model are valid
  142. # @return true if the model is valid
  143. 1 def valid?
  144. warn '[DEPRECATED] the `valid?` method is obsolete'
  145. true
  146. end
  147. # Checks equality by comparing each attribute.
  148. # @param [Object] Object to be compared
  149. 1 def ==(o)
  150. 2 return true if self.equal?(o)
  151. 2 self.class == o.class &&
  152. id == o.id &&
  153. name == o.name &&
  154. created_time == o.created_time &&
  155. completed_time == o.completed_time &&
  156. conference_event_url == o.conference_event_url &&
  157. conference_event_method == o.conference_event_method &&
  158. tag == o.tag &&
  159. active_members == o.active_members
  160. end
  161. # @see the `==` method
  162. # @param [Object] Object to be compared
  163. 1 def eql?(o)
  164. 2 self == o
  165. end
  166. # Calculates hash code according to all attributes.
  167. # @return [Integer] Hash code
  168. 1 def hash
  169. [id, name, created_time, completed_time, conference_event_url, conference_event_method, tag, active_members].hash
  170. end
  171. # Builds the object from hash
  172. # @param [Hash] attributes Model attributes in the form of hash
  173. # @return [Object] Returns the model itself
  174. 1 def self.build_from_hash(attributes)
  175. 3 return nil unless attributes.is_a?(Hash)
  176. 3 attributes = attributes.transform_keys(&:to_sym)
  177. 3 transformed_hash = {}
  178. 3 openapi_types.each_pair do |key, type|
  179. 24 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  180. transformed_hash["#{key}"] = nil
  181. 24 elsif type =~ /\AArray<(.*)>/i
  182. # check to ensure the input is an array given that the attribute
  183. # is documented as an array but the input is not
  184. 3 if attributes[attribute_map[key]].is_a?(Array)
  185. 4 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  186. end
  187. 21 elsif !attributes[attribute_map[key]].nil?
  188. 21 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  189. end
  190. end
  191. 3 new(transformed_hash)
  192. end
  193. # Returns the object in the form of hash
  194. # @return [Hash] Returns the object in the form of hash
  195. 1 def to_hash
  196. 2 hash = {}
  197. 2 self.class.attribute_map.each_pair do |attr, param|
  198. 16 value = self.send(attr)
  199. 16 if value.nil?
  200. is_nullable = self.class.openapi_nullable.include?(attr)
  201. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  202. end
  203. 16 hash[param] = _to_hash(value)
  204. end
  205. 2 hash
  206. end
  207. end
  208. end

lib/bandwidth-sdk/models/conference_completed_callback.rb

84.93% lines covered

73 relevant lines. 62 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The Conference Completed event is fired when the last member leaves the conference. The response to this event may not contain BXML.
  13. 1 class ConferenceCompletedCallback < ApiModelBase
  14. # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect.
  15. 1 attr_accessor :event_type
  16. # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.
  17. 1 attr_accessor :event_time
  18. # The unique, Bandwidth-generated ID of the conference that was recorded
  19. 1 attr_accessor :conference_id
  20. # The user-specified name of the conference that was recorded
  21. 1 attr_accessor :name
  22. # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.
  23. 1 attr_accessor :tag
  24. # Attribute mapping from ruby-style variable name to JSON key.
  25. 1 def self.attribute_map
  26. 31 {
  27. :'event_type' => :'eventType',
  28. :'event_time' => :'eventTime',
  29. :'conference_id' => :'conferenceId',
  30. :'name' => :'name',
  31. :'tag' => :'tag'
  32. }
  33. end
  34. # Returns attribute mapping this model knows about
  35. 1 def self.acceptable_attribute_map
  36. 8 attribute_map
  37. end
  38. # Returns all the JSON keys this model knows about
  39. 1 def self.acceptable_attributes
  40. 1 acceptable_attribute_map.values
  41. end
  42. # Attribute type mapping.
  43. 1 def self.openapi_types
  44. 1 {
  45. :'event_type' => :'String',
  46. :'event_time' => :'Time',
  47. :'conference_id' => :'String',
  48. :'name' => :'String',
  49. :'tag' => :'String'
  50. }
  51. end
  52. # List of attributes with nullable: true
  53. 1 def self.openapi_nullable
  54. 1 Set.new([
  55. :'tag'
  56. ])
  57. end
  58. # Initializes the object
  59. # @param [Hash] attributes Model attributes in the form of hash
  60. 1 def initialize(attributes = {})
  61. 8 if (!attributes.is_a?(Hash))
  62. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::ConferenceCompletedCallback` initialize method'
  63. end
  64. # check to see if the attribute exists and convert string to symbol for hash key
  65. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  66. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  67. 21 if (!acceptable_attribute_map.key?(k.to_sym))
  68. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ConferenceCompletedCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  69. end
  70. 20 h[k.to_sym] = v
  71. }
  72. 6 if attributes.key?(:'event_type')
  73. 4 self.event_type = attributes[:'event_type']
  74. end
  75. 6 if attributes.key?(:'event_time')
  76. 4 self.event_time = attributes[:'event_time']
  77. end
  78. 6 if attributes.key?(:'conference_id')
  79. 4 self.conference_id = attributes[:'conference_id']
  80. end
  81. 6 if attributes.key?(:'name')
  82. 4 self.name = attributes[:'name']
  83. end
  84. 6 if attributes.key?(:'tag')
  85. 4 self.tag = attributes[:'tag']
  86. end
  87. end
  88. # Show invalid properties with the reasons. Usually used together with valid?
  89. # @return Array for valid properties with the reasons
  90. 1 def list_invalid_properties
  91. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  92. invalid_properties = Array.new
  93. invalid_properties
  94. end
  95. # Check to see if the all the properties in the model are valid
  96. # @return true if the model is valid
  97. 1 def valid?
  98. warn '[DEPRECATED] the `valid?` method is obsolete'
  99. true
  100. end
  101. # Checks equality by comparing each attribute.
  102. # @param [Object] Object to be compared
  103. 1 def ==(o)
  104. 2 return true if self.equal?(o)
  105. 2 self.class == o.class &&
  106. event_type == o.event_type &&
  107. event_time == o.event_time &&
  108. conference_id == o.conference_id &&
  109. name == o.name &&
  110. tag == o.tag
  111. end
  112. # @see the `==` method
  113. # @param [Object] Object to be compared
  114. 1 def eql?(o)
  115. 2 self == o
  116. end
  117. # Calculates hash code according to all attributes.
  118. # @return [Integer] Hash code
  119. 1 def hash
  120. [event_type, event_time, conference_id, name, tag].hash
  121. end
  122. # Builds the object from hash
  123. # @param [Hash] attributes Model attributes in the form of hash
  124. # @return [Object] Returns the model itself
  125. 1 def self.build_from_hash(attributes)
  126. 1 return nil unless attributes.is_a?(Hash)
  127. 1 attributes = attributes.transform_keys(&:to_sym)
  128. 1 transformed_hash = {}
  129. 1 openapi_types.each_pair do |key, type|
  130. 5 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  131. transformed_hash["#{key}"] = nil
  132. 5 elsif type =~ /\AArray<(.*)>/i
  133. # check to ensure the input is an array given that the attribute
  134. # is documented as an array but the input is not
  135. if attributes[attribute_map[key]].is_a?(Array)
  136. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  137. end
  138. 5 elsif !attributes[attribute_map[key]].nil?
  139. 5 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  140. end
  141. end
  142. 1 new(transformed_hash)
  143. end
  144. # Returns the object in the form of hash
  145. # @return [Hash] Returns the object in the form of hash
  146. 1 def to_hash
  147. 2 hash = {}
  148. 2 self.class.attribute_map.each_pair do |attr, param|
  149. 10 value = self.send(attr)
  150. 10 if value.nil?
  151. is_nullable = self.class.openapi_nullable.include?(attr)
  152. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  153. end
  154. 10 hash[param] = _to_hash(value)
  155. end
  156. 2 hash
  157. end
  158. end
  159. end

lib/bandwidth-sdk/models/conference_created_callback.rb

84.93% lines covered

73 relevant lines. 62 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The Conference Created event is fired whenever a new conference that specified a callbackUrl is created. The response may be either empty or a BXML document. Only the following verbs are valid for conferences: PlayAudio, SpeakSentence, StartRecording, StopRecording, PauseRecording, ResumeRecording. Audio verbs will be heard by all members of the conference. Recordings capture audio from all members who are not muted or on hold, as well as any audio verbs that are played into the conference.
  13. 1 class ConferenceCreatedCallback < ApiModelBase
  14. # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect.
  15. 1 attr_accessor :event_type
  16. # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.
  17. 1 attr_accessor :event_time
  18. # The unique, Bandwidth-generated ID of the conference that was recorded
  19. 1 attr_accessor :conference_id
  20. # The user-specified name of the conference that was recorded
  21. 1 attr_accessor :name
  22. # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.
  23. 1 attr_accessor :tag
  24. # Attribute mapping from ruby-style variable name to JSON key.
  25. 1 def self.attribute_map
  26. 31 {
  27. :'event_type' => :'eventType',
  28. :'event_time' => :'eventTime',
  29. :'conference_id' => :'conferenceId',
  30. :'name' => :'name',
  31. :'tag' => :'tag'
  32. }
  33. end
  34. # Returns attribute mapping this model knows about
  35. 1 def self.acceptable_attribute_map
  36. 8 attribute_map
  37. end
  38. # Returns all the JSON keys this model knows about
  39. 1 def self.acceptable_attributes
  40. 1 acceptable_attribute_map.values
  41. end
  42. # Attribute type mapping.
  43. 1 def self.openapi_types
  44. 1 {
  45. :'event_type' => :'String',
  46. :'event_time' => :'Time',
  47. :'conference_id' => :'String',
  48. :'name' => :'String',
  49. :'tag' => :'String'
  50. }
  51. end
  52. # List of attributes with nullable: true
  53. 1 def self.openapi_nullable
  54. 1 Set.new([
  55. :'tag'
  56. ])
  57. end
  58. # Initializes the object
  59. # @param [Hash] attributes Model attributes in the form of hash
  60. 1 def initialize(attributes = {})
  61. 8 if (!attributes.is_a?(Hash))
  62. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::ConferenceCreatedCallback` initialize method'
  63. end
  64. # check to see if the attribute exists and convert string to symbol for hash key
  65. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  66. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  67. 21 if (!acceptable_attribute_map.key?(k.to_sym))
  68. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ConferenceCreatedCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  69. end
  70. 20 h[k.to_sym] = v
  71. }
  72. 6 if attributes.key?(:'event_type')
  73. 4 self.event_type = attributes[:'event_type']
  74. end
  75. 6 if attributes.key?(:'event_time')
  76. 4 self.event_time = attributes[:'event_time']
  77. end
  78. 6 if attributes.key?(:'conference_id')
  79. 4 self.conference_id = attributes[:'conference_id']
  80. end
  81. 6 if attributes.key?(:'name')
  82. 4 self.name = attributes[:'name']
  83. end
  84. 6 if attributes.key?(:'tag')
  85. 4 self.tag = attributes[:'tag']
  86. end
  87. end
  88. # Show invalid properties with the reasons. Usually used together with valid?
  89. # @return Array for valid properties with the reasons
  90. 1 def list_invalid_properties
  91. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  92. invalid_properties = Array.new
  93. invalid_properties
  94. end
  95. # Check to see if the all the properties in the model are valid
  96. # @return true if the model is valid
  97. 1 def valid?
  98. warn '[DEPRECATED] the `valid?` method is obsolete'
  99. true
  100. end
  101. # Checks equality by comparing each attribute.
  102. # @param [Object] Object to be compared
  103. 1 def ==(o)
  104. 2 return true if self.equal?(o)
  105. 2 self.class == o.class &&
  106. event_type == o.event_type &&
  107. event_time == o.event_time &&
  108. conference_id == o.conference_id &&
  109. name == o.name &&
  110. tag == o.tag
  111. end
  112. # @see the `==` method
  113. # @param [Object] Object to be compared
  114. 1 def eql?(o)
  115. 2 self == o
  116. end
  117. # Calculates hash code according to all attributes.
  118. # @return [Integer] Hash code
  119. 1 def hash
  120. [event_type, event_time, conference_id, name, tag].hash
  121. end
  122. # Builds the object from hash
  123. # @param [Hash] attributes Model attributes in the form of hash
  124. # @return [Object] Returns the model itself
  125. 1 def self.build_from_hash(attributes)
  126. 1 return nil unless attributes.is_a?(Hash)
  127. 1 attributes = attributes.transform_keys(&:to_sym)
  128. 1 transformed_hash = {}
  129. 1 openapi_types.each_pair do |key, type|
  130. 5 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  131. transformed_hash["#{key}"] = nil
  132. 5 elsif type =~ /\AArray<(.*)>/i
  133. # check to ensure the input is an array given that the attribute
  134. # is documented as an array but the input is not
  135. if attributes[attribute_map[key]].is_a?(Array)
  136. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  137. end
  138. 5 elsif !attributes[attribute_map[key]].nil?
  139. 5 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  140. end
  141. end
  142. 1 new(transformed_hash)
  143. end
  144. # Returns the object in the form of hash
  145. # @return [Hash] Returns the object in the form of hash
  146. 1 def to_hash
  147. 2 hash = {}
  148. 2 self.class.attribute_map.each_pair do |attr, param|
  149. 10 value = self.send(attr)
  150. 10 if value.nil?
  151. is_nullable = self.class.openapi_nullable.include?(attr)
  152. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  153. end
  154. 10 hash[param] = _to_hash(value)
  155. end
  156. 2 hash
  157. end
  158. end
  159. end

lib/bandwidth-sdk/models/conference_member.rb

90.91% lines covered

77 relevant lines. 70 lines covered and 7 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class ConferenceMember < ApiModelBase
  13. # The call id associated with the event.
  14. 1 attr_accessor :call_id
  15. # The unique, Bandwidth-generated ID of the conference that was recorded
  16. 1 attr_accessor :conference_id
  17. # A URL that may be used to retrieve information about or update the state of this conference member. This is the URL of this member's [Get Conference Member](/apis/voice-apis/voice/#tag/Conferences/operation/getConferenceMember) endpoint and [Modify Conference Member](/apis/voice-apis/voice/#tag/Conferences/operation/updateConferenceMember) endpoint.
  18. 1 attr_accessor :member_url
  19. # Whether or not this member is currently muted. Members who are muted are still able to hear other participants. If used in a PUT request, updates this member's mute status. Has no effect if omitted.
  20. 1 attr_accessor :mute
  21. # Whether or not this member is currently on hold. Members who are on hold are not able to hear or speak in the conference. If used in a PUT request, updates this member's hold status. Has no effect if omitted.
  22. 1 attr_accessor :hold
  23. # If this member had a value set for `callIdsToCoach` in its [Conference](/docs/voice/bxml/conference) verb or this list was added with a previous PUT request to modify the member, this is that list of calls. If present in a PUT request, modifies the calls that this member is coaching. Has no effect if omitted. See the documentation for the [Conference](/docs/voice/bxml/conference) verb for more details about coaching. Note that this will not add the matching calls to the conference; each call must individually execute a Conference verb to join.
  24. 1 attr_accessor :call_ids_to_coach
  25. # Attribute mapping from ruby-style variable name to JSON key.
  26. 1 def self.attribute_map
  27. 107 {
  28. :'call_id' => :'callId',
  29. :'conference_id' => :'conferenceId',
  30. :'member_url' => :'memberUrl',
  31. :'mute' => :'mute',
  32. :'hold' => :'hold',
  33. :'call_ids_to_coach' => :'callIdsToCoach'
  34. }
  35. end
  36. # Returns attribute mapping this model knows about
  37. 1 def self.acceptable_attribute_map
  38. 14 attribute_map
  39. end
  40. # Returns all the JSON keys this model knows about
  41. 1 def self.acceptable_attributes
  42. 1 acceptable_attribute_map.values
  43. end
  44. # Attribute type mapping.
  45. 1 def self.openapi_types
  46. 4 {
  47. :'call_id' => :'String',
  48. :'conference_id' => :'String',
  49. :'member_url' => :'String',
  50. :'mute' => :'Boolean',
  51. :'hold' => :'Boolean',
  52. :'call_ids_to_coach' => :'Array<String>'
  53. }
  54. end
  55. # List of attributes with nullable: true
  56. 1 def self.openapi_nullable
  57. 9 Set.new([
  58. :'call_ids_to_coach'
  59. ])
  60. end
  61. # Initializes the object
  62. # @param [Hash] attributes Model attributes in the form of hash
  63. 1 def initialize(attributes = {})
  64. 14 if (!attributes.is_a?(Hash))
  65. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::ConferenceMember` initialize method'
  66. end
  67. # check to see if the attribute exists and convert string to symbol for hash key
  68. 13 acceptable_attribute_map = self.class.acceptable_attribute_map
  69. 13 attributes = attributes.each_with_object({}) { |(k, v), h|
  70. 45 if (!acceptable_attribute_map.key?(k.to_sym))
  71. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ConferenceMember`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  72. end
  73. 44 h[k.to_sym] = v
  74. }
  75. 12 if attributes.key?(:'call_id')
  76. 10 self.call_id = attributes[:'call_id']
  77. end
  78. 12 if attributes.key?(:'conference_id')
  79. 10 self.conference_id = attributes[:'conference_id']
  80. end
  81. 12 if attributes.key?(:'member_url')
  82. 6 self.member_url = attributes[:'member_url']
  83. end
  84. 12 if attributes.key?(:'mute')
  85. 6 self.mute = attributes[:'mute']
  86. end
  87. 12 if attributes.key?(:'hold')
  88. 6 self.hold = attributes[:'hold']
  89. end
  90. 12 if attributes.key?(:'call_ids_to_coach')
  91. 6 if (value = attributes[:'call_ids_to_coach']).is_a?(Array)
  92. 6 self.call_ids_to_coach = value
  93. end
  94. end
  95. end
  96. # Show invalid properties with the reasons. Usually used together with valid?
  97. # @return Array for valid properties with the reasons
  98. 1 def list_invalid_properties
  99. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  100. invalid_properties = Array.new
  101. invalid_properties
  102. end
  103. # Check to see if the all the properties in the model are valid
  104. # @return true if the model is valid
  105. 1 def valid?
  106. warn '[DEPRECATED] the `valid?` method is obsolete'
  107. true
  108. end
  109. # Checks equality by comparing each attribute.
  110. # @param [Object] Object to be compared
  111. 1 def ==(o)
  112. 2 return true if self.equal?(o)
  113. 2 self.class == o.class &&
  114. call_id == o.call_id &&
  115. conference_id == o.conference_id &&
  116. member_url == o.member_url &&
  117. mute == o.mute &&
  118. hold == o.hold &&
  119. call_ids_to_coach == o.call_ids_to_coach
  120. end
  121. # @see the `==` method
  122. # @param [Object] Object to be compared
  123. 1 def eql?(o)
  124. 2 self == o
  125. end
  126. # Calculates hash code according to all attributes.
  127. # @return [Integer] Hash code
  128. 1 def hash
  129. [call_id, conference_id, member_url, mute, hold, call_ids_to_coach].hash
  130. end
  131. # Builds the object from hash
  132. # @param [Hash] attributes Model attributes in the form of hash
  133. # @return [Object] Returns the model itself
  134. 1 def self.build_from_hash(attributes)
  135. 4 return nil unless attributes.is_a?(Hash)
  136. 4 attributes = attributes.transform_keys(&:to_sym)
  137. 4 transformed_hash = {}
  138. 4 openapi_types.each_pair do |key, type|
  139. 24 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  140. transformed_hash["#{key}"] = nil
  141. 24 elsif type =~ /\AArray<(.*)>/i
  142. # check to ensure the input is an array given that the attribute
  143. # is documented as an array but the input is not
  144. 4 if attributes[attribute_map[key]].is_a?(Array)
  145. 6 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  146. end
  147. 20 elsif !attributes[attribute_map[key]].nil?
  148. 17 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  149. end
  150. end
  151. 4 new(transformed_hash)
  152. end
  153. # Returns the object in the form of hash
  154. # @return [Hash] Returns the object in the form of hash
  155. 1 def to_hash
  156. 4 hash = {}
  157. 4 self.class.attribute_map.each_pair do |attr, param|
  158. 24 value = self.send(attr)
  159. 24 if value.nil?
  160. 8 is_nullable = self.class.openapi_nullable.include?(attr)
  161. 8 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  162. end
  163. 16 hash[param] = _to_hash(value)
  164. end
  165. 4 hash
  166. end
  167. end
  168. end

lib/bandwidth-sdk/models/conference_member_exit_callback.rb

86.59% lines covered

82 relevant lines. 71 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The Conference Member Exit event is fired whenever a caller exits a conference that specified a callbackUrl. The response may be either empty or a BXML document. Only the following verbs are valid for conferences: PlayAudio, SpeakSentence, StartRecording, StopRecording, PauseRecording, ResumeRecording. Audio verbs will be heard by all members of the conference. Recordings capture audio from all members who are not muted or on hold, as well as any audio verbs that are played into the conference.
  13. 1 class ConferenceMemberExitCallback < ApiModelBase
  14. # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect.
  15. 1 attr_accessor :event_type
  16. # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.
  17. 1 attr_accessor :event_time
  18. # The unique, Bandwidth-generated ID of the conference that was recorded
  19. 1 attr_accessor :conference_id
  20. # The user-specified name of the conference that was recorded
  21. 1 attr_accessor :name
  22. # The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555).
  23. 1 attr_accessor :from
  24. # The phone number that received the call, in E.164 format (e.g. +15555555555).
  25. 1 attr_accessor :to
  26. # The call id associated with the event.
  27. 1 attr_accessor :call_id
  28. # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.
  29. 1 attr_accessor :tag
  30. # Attribute mapping from ruby-style variable name to JSON key.
  31. 1 def self.attribute_map
  32. 43 {
  33. :'event_type' => :'eventType',
  34. :'event_time' => :'eventTime',
  35. :'conference_id' => :'conferenceId',
  36. :'name' => :'name',
  37. :'from' => :'from',
  38. :'to' => :'to',
  39. :'call_id' => :'callId',
  40. :'tag' => :'tag'
  41. }
  42. end
  43. # Returns attribute mapping this model knows about
  44. 1 def self.acceptable_attribute_map
  45. 8 attribute_map
  46. end
  47. # Returns all the JSON keys this model knows about
  48. 1 def self.acceptable_attributes
  49. 1 acceptable_attribute_map.values
  50. end
  51. # Attribute type mapping.
  52. 1 def self.openapi_types
  53. 1 {
  54. :'event_type' => :'String',
  55. :'event_time' => :'Time',
  56. :'conference_id' => :'String',
  57. :'name' => :'String',
  58. :'from' => :'String',
  59. :'to' => :'String',
  60. :'call_id' => :'String',
  61. :'tag' => :'String'
  62. }
  63. end
  64. # List of attributes with nullable: true
  65. 1 def self.openapi_nullable
  66. 1 Set.new([
  67. :'tag'
  68. ])
  69. end
  70. # Initializes the object
  71. # @param [Hash] attributes Model attributes in the form of hash
  72. 1 def initialize(attributes = {})
  73. 8 if (!attributes.is_a?(Hash))
  74. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::ConferenceMemberExitCallback` initialize method'
  75. end
  76. # check to see if the attribute exists and convert string to symbol for hash key
  77. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  78. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  79. 33 if (!acceptable_attribute_map.key?(k.to_sym))
  80. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ConferenceMemberExitCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  81. end
  82. 32 h[k.to_sym] = v
  83. }
  84. 6 if attributes.key?(:'event_type')
  85. 4 self.event_type = attributes[:'event_type']
  86. end
  87. 6 if attributes.key?(:'event_time')
  88. 4 self.event_time = attributes[:'event_time']
  89. end
  90. 6 if attributes.key?(:'conference_id')
  91. 4 self.conference_id = attributes[:'conference_id']
  92. end
  93. 6 if attributes.key?(:'name')
  94. 4 self.name = attributes[:'name']
  95. end
  96. 6 if attributes.key?(:'from')
  97. 4 self.from = attributes[:'from']
  98. end
  99. 6 if attributes.key?(:'to')
  100. 4 self.to = attributes[:'to']
  101. end
  102. 6 if attributes.key?(:'call_id')
  103. 4 self.call_id = attributes[:'call_id']
  104. end
  105. 6 if attributes.key?(:'tag')
  106. 4 self.tag = attributes[:'tag']
  107. end
  108. end
  109. # Show invalid properties with the reasons. Usually used together with valid?
  110. # @return Array for valid properties with the reasons
  111. 1 def list_invalid_properties
  112. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  113. invalid_properties = Array.new
  114. invalid_properties
  115. end
  116. # Check to see if the all the properties in the model are valid
  117. # @return true if the model is valid
  118. 1 def valid?
  119. warn '[DEPRECATED] the `valid?` method is obsolete'
  120. true
  121. end
  122. # Checks equality by comparing each attribute.
  123. # @param [Object] Object to be compared
  124. 1 def ==(o)
  125. 2 return true if self.equal?(o)
  126. 2 self.class == o.class &&
  127. event_type == o.event_type &&
  128. event_time == o.event_time &&
  129. conference_id == o.conference_id &&
  130. name == o.name &&
  131. from == o.from &&
  132. to == o.to &&
  133. call_id == o.call_id &&
  134. tag == o.tag
  135. end
  136. # @see the `==` method
  137. # @param [Object] Object to be compared
  138. 1 def eql?(o)
  139. 2 self == o
  140. end
  141. # Calculates hash code according to all attributes.
  142. # @return [Integer] Hash code
  143. 1 def hash
  144. [event_type, event_time, conference_id, name, from, to, call_id, tag].hash
  145. end
  146. # Builds the object from hash
  147. # @param [Hash] attributes Model attributes in the form of hash
  148. # @return [Object] Returns the model itself
  149. 1 def self.build_from_hash(attributes)
  150. 1 return nil unless attributes.is_a?(Hash)
  151. 1 attributes = attributes.transform_keys(&:to_sym)
  152. 1 transformed_hash = {}
  153. 1 openapi_types.each_pair do |key, type|
  154. 8 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  155. transformed_hash["#{key}"] = nil
  156. 8 elsif type =~ /\AArray<(.*)>/i
  157. # check to ensure the input is an array given that the attribute
  158. # is documented as an array but the input is not
  159. if attributes[attribute_map[key]].is_a?(Array)
  160. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  161. end
  162. 8 elsif !attributes[attribute_map[key]].nil?
  163. 8 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  164. end
  165. end
  166. 1 new(transformed_hash)
  167. end
  168. # Returns the object in the form of hash
  169. # @return [Hash] Returns the object in the form of hash
  170. 1 def to_hash
  171. 2 hash = {}
  172. 2 self.class.attribute_map.each_pair do |attr, param|
  173. 16 value = self.send(attr)
  174. 16 if value.nil?
  175. is_nullable = self.class.openapi_nullable.include?(attr)
  176. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  177. end
  178. 16 hash[param] = _to_hash(value)
  179. end
  180. 2 hash
  181. end
  182. end
  183. end

lib/bandwidth-sdk/models/conference_member_join_callback.rb

86.59% lines covered

82 relevant lines. 71 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The Conference Member Join event is fired whenever a caller joins a conference that specified a callbackUrl. The response may be either empty or a BXML document. Only the following verbs are valid for conferences: PlayAudio, SpeakSentence, StartRecording, StopRecording, PauseRecording, ResumeRecording. Audio verbs will be heard by all members of the conference. Recordings capture audio from all members who are not muted or on hold, as well as any audio verbs that are played into the conference.
  13. 1 class ConferenceMemberJoinCallback < ApiModelBase
  14. # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect.
  15. 1 attr_accessor :event_type
  16. # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.
  17. 1 attr_accessor :event_time
  18. # The unique, Bandwidth-generated ID of the conference that was recorded
  19. 1 attr_accessor :conference_id
  20. # The user-specified name of the conference that was recorded
  21. 1 attr_accessor :name
  22. # The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555).
  23. 1 attr_accessor :from
  24. # The phone number that received the call, in E.164 format (e.g. +15555555555).
  25. 1 attr_accessor :to
  26. # The call id associated with the event.
  27. 1 attr_accessor :call_id
  28. # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.
  29. 1 attr_accessor :tag
  30. # Attribute mapping from ruby-style variable name to JSON key.
  31. 1 def self.attribute_map
  32. 43 {
  33. :'event_type' => :'eventType',
  34. :'event_time' => :'eventTime',
  35. :'conference_id' => :'conferenceId',
  36. :'name' => :'name',
  37. :'from' => :'from',
  38. :'to' => :'to',
  39. :'call_id' => :'callId',
  40. :'tag' => :'tag'
  41. }
  42. end
  43. # Returns attribute mapping this model knows about
  44. 1 def self.acceptable_attribute_map
  45. 8 attribute_map
  46. end
  47. # Returns all the JSON keys this model knows about
  48. 1 def self.acceptable_attributes
  49. 1 acceptable_attribute_map.values
  50. end
  51. # Attribute type mapping.
  52. 1 def self.openapi_types
  53. 1 {
  54. :'event_type' => :'String',
  55. :'event_time' => :'Time',
  56. :'conference_id' => :'String',
  57. :'name' => :'String',
  58. :'from' => :'String',
  59. :'to' => :'String',
  60. :'call_id' => :'String',
  61. :'tag' => :'String'
  62. }
  63. end
  64. # List of attributes with nullable: true
  65. 1 def self.openapi_nullable
  66. 1 Set.new([
  67. :'tag'
  68. ])
  69. end
  70. # Initializes the object
  71. # @param [Hash] attributes Model attributes in the form of hash
  72. 1 def initialize(attributes = {})
  73. 8 if (!attributes.is_a?(Hash))
  74. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::ConferenceMemberJoinCallback` initialize method'
  75. end
  76. # check to see if the attribute exists and convert string to symbol for hash key
  77. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  78. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  79. 33 if (!acceptable_attribute_map.key?(k.to_sym))
  80. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ConferenceMemberJoinCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  81. end
  82. 32 h[k.to_sym] = v
  83. }
  84. 6 if attributes.key?(:'event_type')
  85. 4 self.event_type = attributes[:'event_type']
  86. end
  87. 6 if attributes.key?(:'event_time')
  88. 4 self.event_time = attributes[:'event_time']
  89. end
  90. 6 if attributes.key?(:'conference_id')
  91. 4 self.conference_id = attributes[:'conference_id']
  92. end
  93. 6 if attributes.key?(:'name')
  94. 4 self.name = attributes[:'name']
  95. end
  96. 6 if attributes.key?(:'from')
  97. 4 self.from = attributes[:'from']
  98. end
  99. 6 if attributes.key?(:'to')
  100. 4 self.to = attributes[:'to']
  101. end
  102. 6 if attributes.key?(:'call_id')
  103. 4 self.call_id = attributes[:'call_id']
  104. end
  105. 6 if attributes.key?(:'tag')
  106. 4 self.tag = attributes[:'tag']
  107. end
  108. end
  109. # Show invalid properties with the reasons. Usually used together with valid?
  110. # @return Array for valid properties with the reasons
  111. 1 def list_invalid_properties
  112. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  113. invalid_properties = Array.new
  114. invalid_properties
  115. end
  116. # Check to see if the all the properties in the model are valid
  117. # @return true if the model is valid
  118. 1 def valid?
  119. warn '[DEPRECATED] the `valid?` method is obsolete'
  120. true
  121. end
  122. # Checks equality by comparing each attribute.
  123. # @param [Object] Object to be compared
  124. 1 def ==(o)
  125. 2 return true if self.equal?(o)
  126. 2 self.class == o.class &&
  127. event_type == o.event_type &&
  128. event_time == o.event_time &&
  129. conference_id == o.conference_id &&
  130. name == o.name &&
  131. from == o.from &&
  132. to == o.to &&
  133. call_id == o.call_id &&
  134. tag == o.tag
  135. end
  136. # @see the `==` method
  137. # @param [Object] Object to be compared
  138. 1 def eql?(o)
  139. 2 self == o
  140. end
  141. # Calculates hash code according to all attributes.
  142. # @return [Integer] Hash code
  143. 1 def hash
  144. [event_type, event_time, conference_id, name, from, to, call_id, tag].hash
  145. end
  146. # Builds the object from hash
  147. # @param [Hash] attributes Model attributes in the form of hash
  148. # @return [Object] Returns the model itself
  149. 1 def self.build_from_hash(attributes)
  150. 1 return nil unless attributes.is_a?(Hash)
  151. 1 attributes = attributes.transform_keys(&:to_sym)
  152. 1 transformed_hash = {}
  153. 1 openapi_types.each_pair do |key, type|
  154. 8 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  155. transformed_hash["#{key}"] = nil
  156. 8 elsif type =~ /\AArray<(.*)>/i
  157. # check to ensure the input is an array given that the attribute
  158. # is documented as an array but the input is not
  159. if attributes[attribute_map[key]].is_a?(Array)
  160. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  161. end
  162. 8 elsif !attributes[attribute_map[key]].nil?
  163. 8 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  164. end
  165. end
  166. 1 new(transformed_hash)
  167. end
  168. # Returns the object in the form of hash
  169. # @return [Hash] Returns the object in the form of hash
  170. 1 def to_hash
  171. 2 hash = {}
  172. 2 self.class.attribute_map.each_pair do |attr, param|
  173. 16 value = self.send(attr)
  174. 16 if value.nil?
  175. is_nullable = self.class.openapi_nullable.include?(attr)
  176. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  177. end
  178. 16 hash[param] = _to_hash(value)
  179. end
  180. 2 hash
  181. end
  182. end
  183. end

lib/bandwidth-sdk/models/conference_recording_available_callback.rb

84.68% lines covered

111 relevant lines. 94 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The Conference Recording Available event is sent after a conference recording has been processed. It indicates that the recording is available for download.
  13. 1 class ConferenceRecordingAvailableCallback < ApiModelBase
  14. # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect.
  15. 1 attr_accessor :event_type
  16. # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.
  17. 1 attr_accessor :event_time
  18. # The unique, Bandwidth-generated ID of the conference that was recorded
  19. 1 attr_accessor :conference_id
  20. # The user-specified name of the conference that was recorded
  21. 1 attr_accessor :name
  22. # The user account associated with the call.
  23. 1 attr_accessor :account_id
  24. # The unique ID of this recording
  25. 1 attr_accessor :recording_id
  26. # Always `1` for conference recordings; multi-channel recordings are not supported on conferences.
  27. 1 attr_accessor :channels
  28. # Time the call was started, in ISO 8601 format.
  29. 1 attr_accessor :start_time
  30. # The time that the recording ended in ISO-8601 format
  31. 1 attr_accessor :end_time
  32. # The duration of the recording in ISO-8601 format
  33. 1 attr_accessor :duration
  34. 1 attr_accessor :file_format
  35. # The URL that can be used to download the recording. Only present if the recording is finished and may be downloaded.
  36. 1 attr_accessor :media_url
  37. # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.
  38. 1 attr_accessor :tag
  39. # The current status of the process. For recording, current possible values are 'processing', 'partial', 'complete', 'deleted', and 'error'. For transcriptions, current possible values are 'none', 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and 'file-size-too-small'. Additional states may be added in the future, so your application must be tolerant of unknown values.
  40. 1 attr_accessor :status
  41. 1 class EnumAttributeValidator
  42. 1 attr_reader :datatype
  43. 1 attr_reader :allowable_values
  44. 1 def initialize(datatype, allowable_values)
  45. @allowable_values = allowable_values.map do |value|
  46. case datatype.to_s
  47. when /Integer/i
  48. value.to_i
  49. when /Float/i
  50. value.to_f
  51. else
  52. value
  53. end
  54. end
  55. end
  56. 1 def valid?(value)
  57. !value || allowable_values.include?(value)
  58. end
  59. end
  60. # Attribute mapping from ruby-style variable name to JSON key.
  61. 1 def self.attribute_map
  62. 67 {
  63. :'event_type' => :'eventType',
  64. :'event_time' => :'eventTime',
  65. :'conference_id' => :'conferenceId',
  66. :'name' => :'name',
  67. :'account_id' => :'accountId',
  68. :'recording_id' => :'recordingId',
  69. :'channels' => :'channels',
  70. :'start_time' => :'startTime',
  71. :'end_time' => :'endTime',
  72. :'duration' => :'duration',
  73. :'file_format' => :'fileFormat',
  74. :'media_url' => :'mediaUrl',
  75. :'tag' => :'tag',
  76. :'status' => :'status'
  77. }
  78. end
  79. # Returns attribute mapping this model knows about
  80. 1 def self.acceptable_attribute_map
  81. 8 attribute_map
  82. end
  83. # Returns all the JSON keys this model knows about
  84. 1 def self.acceptable_attributes
  85. 1 acceptable_attribute_map.values
  86. end
  87. # Attribute type mapping.
  88. 1 def self.openapi_types
  89. 1 {
  90. :'event_type' => :'String',
  91. :'event_time' => :'Time',
  92. :'conference_id' => :'String',
  93. :'name' => :'String',
  94. :'account_id' => :'String',
  95. :'recording_id' => :'String',
  96. :'channels' => :'Integer',
  97. :'start_time' => :'Time',
  98. :'end_time' => :'Time',
  99. :'duration' => :'String',
  100. :'file_format' => :'FileFormatEnum',
  101. :'media_url' => :'String',
  102. :'tag' => :'String',
  103. :'status' => :'String'
  104. }
  105. end
  106. # List of attributes with nullable: true
  107. 1 def self.openapi_nullable
  108. 1 Set.new([
  109. :'media_url',
  110. :'tag',
  111. ])
  112. end
  113. # Initializes the object
  114. # @param [Hash] attributes Model attributes in the form of hash
  115. 1 def initialize(attributes = {})
  116. 8 if (!attributes.is_a?(Hash))
  117. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::ConferenceRecordingAvailableCallback` initialize method'
  118. end
  119. # check to see if the attribute exists and convert string to symbol for hash key
  120. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  121. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  122. 57 if (!acceptable_attribute_map.key?(k.to_sym))
  123. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ConferenceRecordingAvailableCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  124. end
  125. 56 h[k.to_sym] = v
  126. }
  127. 6 if attributes.key?(:'event_type')
  128. 4 self.event_type = attributes[:'event_type']
  129. end
  130. 6 if attributes.key?(:'event_time')
  131. 4 self.event_time = attributes[:'event_time']
  132. end
  133. 6 if attributes.key?(:'conference_id')
  134. 4 self.conference_id = attributes[:'conference_id']
  135. end
  136. 6 if attributes.key?(:'name')
  137. 4 self.name = attributes[:'name']
  138. end
  139. 6 if attributes.key?(:'account_id')
  140. 4 self.account_id = attributes[:'account_id']
  141. end
  142. 6 if attributes.key?(:'recording_id')
  143. 4 self.recording_id = attributes[:'recording_id']
  144. end
  145. 6 if attributes.key?(:'channels')
  146. 4 self.channels = attributes[:'channels']
  147. end
  148. 6 if attributes.key?(:'start_time')
  149. 4 self.start_time = attributes[:'start_time']
  150. end
  151. 6 if attributes.key?(:'end_time')
  152. 4 self.end_time = attributes[:'end_time']
  153. end
  154. 6 if attributes.key?(:'duration')
  155. 4 self.duration = attributes[:'duration']
  156. end
  157. 6 if attributes.key?(:'file_format')
  158. 4 self.file_format = attributes[:'file_format']
  159. end
  160. 6 if attributes.key?(:'media_url')
  161. 4 self.media_url = attributes[:'media_url']
  162. end
  163. 6 if attributes.key?(:'tag')
  164. 4 self.tag = attributes[:'tag']
  165. end
  166. 6 if attributes.key?(:'status')
  167. 4 self.status = attributes[:'status']
  168. end
  169. end
  170. # Show invalid properties with the reasons. Usually used together with valid?
  171. # @return Array for valid properties with the reasons
  172. 1 def list_invalid_properties
  173. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  174. invalid_properties = Array.new
  175. invalid_properties
  176. end
  177. # Check to see if the all the properties in the model are valid
  178. # @return true if the model is valid
  179. 1 def valid?
  180. warn '[DEPRECATED] the `valid?` method is obsolete'
  181. true
  182. end
  183. # Checks equality by comparing each attribute.
  184. # @param [Object] Object to be compared
  185. 1 def ==(o)
  186. 2 return true if self.equal?(o)
  187. 2 self.class == o.class &&
  188. event_type == o.event_type &&
  189. event_time == o.event_time &&
  190. conference_id == o.conference_id &&
  191. name == o.name &&
  192. account_id == o.account_id &&
  193. recording_id == o.recording_id &&
  194. channels == o.channels &&
  195. start_time == o.start_time &&
  196. end_time == o.end_time &&
  197. duration == o.duration &&
  198. file_format == o.file_format &&
  199. media_url == o.media_url &&
  200. tag == o.tag &&
  201. status == o.status
  202. end
  203. # @see the `==` method
  204. # @param [Object] Object to be compared
  205. 1 def eql?(o)
  206. 2 self == o
  207. end
  208. # Calculates hash code according to all attributes.
  209. # @return [Integer] Hash code
  210. 1 def hash
  211. [event_type, event_time, conference_id, name, account_id, recording_id, channels, start_time, end_time, duration, file_format, media_url, tag, status].hash
  212. end
  213. # Builds the object from hash
  214. # @param [Hash] attributes Model attributes in the form of hash
  215. # @return [Object] Returns the model itself
  216. 1 def self.build_from_hash(attributes)
  217. 1 return nil unless attributes.is_a?(Hash)
  218. 1 attributes = attributes.transform_keys(&:to_sym)
  219. 1 transformed_hash = {}
  220. 1 openapi_types.each_pair do |key, type|
  221. 14 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  222. transformed_hash["#{key}"] = nil
  223. 14 elsif type =~ /\AArray<(.*)>/i
  224. # check to ensure the input is an array given that the attribute
  225. # is documented as an array but the input is not
  226. if attributes[attribute_map[key]].is_a?(Array)
  227. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  228. end
  229. 14 elsif !attributes[attribute_map[key]].nil?
  230. 14 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  231. end
  232. end
  233. 1 new(transformed_hash)
  234. end
  235. # Returns the object in the form of hash
  236. # @return [Hash] Returns the object in the form of hash
  237. 1 def to_hash
  238. 2 hash = {}
  239. 2 self.class.attribute_map.each_pair do |attr, param|
  240. 28 value = self.send(attr)
  241. 28 if value.nil?
  242. is_nullable = self.class.openapi_nullable.include?(attr)
  243. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  244. end
  245. 28 hash[param] = _to_hash(value)
  246. end
  247. 2 hash
  248. end
  249. end
  250. end

lib/bandwidth-sdk/models/conference_recording_metadata.rb

83.81% lines covered

105 relevant lines. 88 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class ConferenceRecordingMetadata < ApiModelBase
  13. # The user account associated with the call.
  14. 1 attr_accessor :account_id
  15. # The unique, Bandwidth-generated ID of the conference that was recorded
  16. 1 attr_accessor :conference_id
  17. # The user-specified name of the conference that was recorded
  18. 1 attr_accessor :name
  19. # The unique ID of this recording
  20. 1 attr_accessor :recording_id
  21. # The duration of the recording in ISO-8601 format
  22. 1 attr_accessor :duration
  23. # Always `1` for conference recordings; multi-channel recordings are not supported on conferences.
  24. 1 attr_accessor :channels
  25. # Time the call was started, in ISO 8601 format.
  26. 1 attr_accessor :start_time
  27. # The time that the recording ended in ISO-8601 format
  28. 1 attr_accessor :end_time
  29. 1 attr_accessor :file_format
  30. # The current status of the process. For recording, current possible values are 'processing', 'partial', 'complete', 'deleted', and 'error'. For transcriptions, current possible values are 'none', 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and 'file-size-too-small'. Additional states may be added in the future, so your application must be tolerant of unknown values.
  31. 1 attr_accessor :status
  32. # The URL that can be used to download the recording. Only present if the recording is finished and may be downloaded.
  33. 1 attr_accessor :media_url
  34. # A name to identify this recording.
  35. 1 attr_accessor :recording_name
  36. 1 class EnumAttributeValidator
  37. 1 attr_reader :datatype
  38. 1 attr_reader :allowable_values
  39. 1 def initialize(datatype, allowable_values)
  40. @allowable_values = allowable_values.map do |value|
  41. case datatype.to_s
  42. when /Integer/i
  43. value.to_i
  44. when /Float/i
  45. value.to_f
  46. else
  47. value
  48. end
  49. end
  50. end
  51. 1 def valid?(value)
  52. !value || allowable_values.include?(value)
  53. end
  54. end
  55. # Attribute mapping from ruby-style variable name to JSON key.
  56. 1 def self.attribute_map
  57. 157 {
  58. :'account_id' => :'accountId',
  59. :'conference_id' => :'conferenceId',
  60. :'name' => :'name',
  61. :'recording_id' => :'recordingId',
  62. :'duration' => :'duration',
  63. :'channels' => :'channels',
  64. :'start_time' => :'startTime',
  65. :'end_time' => :'endTime',
  66. :'file_format' => :'fileFormat',
  67. :'status' => :'status',
  68. :'media_url' => :'mediaUrl',
  69. :'recording_name' => :'recordingName'
  70. }
  71. end
  72. # Returns attribute mapping this model knows about
  73. 1 def self.acceptable_attribute_map
  74. 10 attribute_map
  75. end
  76. # Returns all the JSON keys this model knows about
  77. 1 def self.acceptable_attributes
  78. 1 acceptable_attribute_map.values
  79. end
  80. # Attribute type mapping.
  81. 1 def self.openapi_types
  82. 3 {
  83. :'account_id' => :'String',
  84. :'conference_id' => :'String',
  85. :'name' => :'String',
  86. :'recording_id' => :'String',
  87. :'duration' => :'String',
  88. :'channels' => :'Integer',
  89. :'start_time' => :'Time',
  90. :'end_time' => :'Time',
  91. :'file_format' => :'FileFormatEnum',
  92. :'status' => :'String',
  93. :'media_url' => :'String',
  94. :'recording_name' => :'String'
  95. }
  96. end
  97. # List of attributes with nullable: true
  98. 1 def self.openapi_nullable
  99. 1 Set.new([
  100. :'media_url',
  101. ])
  102. end
  103. # Initializes the object
  104. # @param [Hash] attributes Model attributes in the form of hash
  105. 1 def initialize(attributes = {})
  106. 10 if (!attributes.is_a?(Hash))
  107. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::ConferenceRecordingMetadata` initialize method'
  108. end
  109. # check to see if the attribute exists and convert string to symbol for hash key
  110. 9 acceptable_attribute_map = self.class.acceptable_attribute_map
  111. 9 attributes = attributes.each_with_object({}) { |(k, v), h|
  112. 73 if (!acceptable_attribute_map.key?(k.to_sym))
  113. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ConferenceRecordingMetadata`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  114. end
  115. 72 h[k.to_sym] = v
  116. }
  117. 8 if attributes.key?(:'account_id')
  118. 6 self.account_id = attributes[:'account_id']
  119. end
  120. 8 if attributes.key?(:'conference_id')
  121. 6 self.conference_id = attributes[:'conference_id']
  122. end
  123. 8 if attributes.key?(:'name')
  124. 6 self.name = attributes[:'name']
  125. end
  126. 8 if attributes.key?(:'recording_id')
  127. 6 self.recording_id = attributes[:'recording_id']
  128. end
  129. 8 if attributes.key?(:'duration')
  130. 6 self.duration = attributes[:'duration']
  131. end
  132. 8 if attributes.key?(:'channels')
  133. 6 self.channels = attributes[:'channels']
  134. end
  135. 8 if attributes.key?(:'start_time')
  136. 6 self.start_time = attributes[:'start_time']
  137. end
  138. 8 if attributes.key?(:'end_time')
  139. 6 self.end_time = attributes[:'end_time']
  140. end
  141. 8 if attributes.key?(:'file_format')
  142. 6 self.file_format = attributes[:'file_format']
  143. end
  144. 8 if attributes.key?(:'status')
  145. 6 self.status = attributes[:'status']
  146. end
  147. 8 if attributes.key?(:'media_url')
  148. 6 self.media_url = attributes[:'media_url']
  149. end
  150. 8 if attributes.key?(:'recording_name')
  151. 6 self.recording_name = attributes[:'recording_name']
  152. end
  153. end
  154. # Show invalid properties with the reasons. Usually used together with valid?
  155. # @return Array for valid properties with the reasons
  156. 1 def list_invalid_properties
  157. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  158. invalid_properties = Array.new
  159. invalid_properties
  160. end
  161. # Check to see if the all the properties in the model are valid
  162. # @return true if the model is valid
  163. 1 def valid?
  164. warn '[DEPRECATED] the `valid?` method is obsolete'
  165. true
  166. end
  167. # Checks equality by comparing each attribute.
  168. # @param [Object] Object to be compared
  169. 1 def ==(o)
  170. 2 return true if self.equal?(o)
  171. 2 self.class == o.class &&
  172. account_id == o.account_id &&
  173. conference_id == o.conference_id &&
  174. name == o.name &&
  175. recording_id == o.recording_id &&
  176. duration == o.duration &&
  177. channels == o.channels &&
  178. start_time == o.start_time &&
  179. end_time == o.end_time &&
  180. file_format == o.file_format &&
  181. status == o.status &&
  182. media_url == o.media_url &&
  183. recording_name == o.recording_name
  184. end
  185. # @see the `==` method
  186. # @param [Object] Object to be compared
  187. 1 def eql?(o)
  188. 2 self == o
  189. end
  190. # Calculates hash code according to all attributes.
  191. # @return [Integer] Hash code
  192. 1 def hash
  193. [account_id, conference_id, name, recording_id, duration, channels, start_time, end_time, file_format, status, media_url, recording_name].hash
  194. end
  195. # Builds the object from hash
  196. # @param [Hash] attributes Model attributes in the form of hash
  197. # @return [Object] Returns the model itself
  198. 1 def self.build_from_hash(attributes)
  199. 3 return nil unless attributes.is_a?(Hash)
  200. 3 attributes = attributes.transform_keys(&:to_sym)
  201. 3 transformed_hash = {}
  202. 3 openapi_types.each_pair do |key, type|
  203. 36 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  204. transformed_hash["#{key}"] = nil
  205. 36 elsif type =~ /\AArray<(.*)>/i
  206. # check to ensure the input is an array given that the attribute
  207. # is documented as an array but the input is not
  208. if attributes[attribute_map[key]].is_a?(Array)
  209. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  210. end
  211. 36 elsif !attributes[attribute_map[key]].nil?
  212. 36 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  213. end
  214. end
  215. 3 new(transformed_hash)
  216. end
  217. # Returns the object in the form of hash
  218. # @return [Hash] Returns the object in the form of hash
  219. 1 def to_hash
  220. 2 hash = {}
  221. 2 self.class.attribute_map.each_pair do |attr, param|
  222. 24 value = self.send(attr)
  223. 24 if value.nil?
  224. is_nullable = self.class.openapi_nullable.include?(attr)
  225. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  226. end
  227. 24 hash[param] = _to_hash(value)
  228. end
  229. 2 hash
  230. end
  231. end
  232. end

lib/bandwidth-sdk/models/conference_redirect_callback.rb

84.93% lines covered

73 relevant lines. 62 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The Conference Redirect event is fired whenever an existing conference is modified via a POST request made to the /conferences/{conferenceId} endpoint. The response may be either empty or a BXML document. Only the following verbs are valid for conferences: PlayAudio, SpeakSentence, StartRecording, StopRecording, PauseRecording, ResumeRecording. Audio verbs will be heard by all members of the conference. Recordings capture audio from all members who are not muted or on hold, as well as any audio verbs that are played into the conference.
  13. 1 class ConferenceRedirectCallback < ApiModelBase
  14. # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect.
  15. 1 attr_accessor :event_type
  16. # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.
  17. 1 attr_accessor :event_time
  18. # The unique, Bandwidth-generated ID of the conference that was recorded
  19. 1 attr_accessor :conference_id
  20. # The user-specified name of the conference that was recorded
  21. 1 attr_accessor :name
  22. # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.
  23. 1 attr_accessor :tag
  24. # Attribute mapping from ruby-style variable name to JSON key.
  25. 1 def self.attribute_map
  26. 31 {
  27. :'event_type' => :'eventType',
  28. :'event_time' => :'eventTime',
  29. :'conference_id' => :'conferenceId',
  30. :'name' => :'name',
  31. :'tag' => :'tag'
  32. }
  33. end
  34. # Returns attribute mapping this model knows about
  35. 1 def self.acceptable_attribute_map
  36. 8 attribute_map
  37. end
  38. # Returns all the JSON keys this model knows about
  39. 1 def self.acceptable_attributes
  40. 1 acceptable_attribute_map.values
  41. end
  42. # Attribute type mapping.
  43. 1 def self.openapi_types
  44. 1 {
  45. :'event_type' => :'String',
  46. :'event_time' => :'Time',
  47. :'conference_id' => :'String',
  48. :'name' => :'String',
  49. :'tag' => :'String'
  50. }
  51. end
  52. # List of attributes with nullable: true
  53. 1 def self.openapi_nullable
  54. 1 Set.new([
  55. :'tag'
  56. ])
  57. end
  58. # Initializes the object
  59. # @param [Hash] attributes Model attributes in the form of hash
  60. 1 def initialize(attributes = {})
  61. 8 if (!attributes.is_a?(Hash))
  62. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::ConferenceRedirectCallback` initialize method'
  63. end
  64. # check to see if the attribute exists and convert string to symbol for hash key
  65. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  66. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  67. 21 if (!acceptable_attribute_map.key?(k.to_sym))
  68. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ConferenceRedirectCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  69. end
  70. 20 h[k.to_sym] = v
  71. }
  72. 6 if attributes.key?(:'event_type')
  73. 4 self.event_type = attributes[:'event_type']
  74. end
  75. 6 if attributes.key?(:'event_time')
  76. 4 self.event_time = attributes[:'event_time']
  77. end
  78. 6 if attributes.key?(:'conference_id')
  79. 4 self.conference_id = attributes[:'conference_id']
  80. end
  81. 6 if attributes.key?(:'name')
  82. 4 self.name = attributes[:'name']
  83. end
  84. 6 if attributes.key?(:'tag')
  85. 4 self.tag = attributes[:'tag']
  86. end
  87. end
  88. # Show invalid properties with the reasons. Usually used together with valid?
  89. # @return Array for valid properties with the reasons
  90. 1 def list_invalid_properties
  91. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  92. invalid_properties = Array.new
  93. invalid_properties
  94. end
  95. # Check to see if the all the properties in the model are valid
  96. # @return true if the model is valid
  97. 1 def valid?
  98. warn '[DEPRECATED] the `valid?` method is obsolete'
  99. true
  100. end
  101. # Checks equality by comparing each attribute.
  102. # @param [Object] Object to be compared
  103. 1 def ==(o)
  104. 2 return true if self.equal?(o)
  105. 2 self.class == o.class &&
  106. event_type == o.event_type &&
  107. event_time == o.event_time &&
  108. conference_id == o.conference_id &&
  109. name == o.name &&
  110. tag == o.tag
  111. end
  112. # @see the `==` method
  113. # @param [Object] Object to be compared
  114. 1 def eql?(o)
  115. 2 self == o
  116. end
  117. # Calculates hash code according to all attributes.
  118. # @return [Integer] Hash code
  119. 1 def hash
  120. [event_type, event_time, conference_id, name, tag].hash
  121. end
  122. # Builds the object from hash
  123. # @param [Hash] attributes Model attributes in the form of hash
  124. # @return [Object] Returns the model itself
  125. 1 def self.build_from_hash(attributes)
  126. 1 return nil unless attributes.is_a?(Hash)
  127. 1 attributes = attributes.transform_keys(&:to_sym)
  128. 1 transformed_hash = {}
  129. 1 openapi_types.each_pair do |key, type|
  130. 5 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  131. transformed_hash["#{key}"] = nil
  132. 5 elsif type =~ /\AArray<(.*)>/i
  133. # check to ensure the input is an array given that the attribute
  134. # is documented as an array but the input is not
  135. if attributes[attribute_map[key]].is_a?(Array)
  136. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  137. end
  138. 5 elsif !attributes[attribute_map[key]].nil?
  139. 5 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  140. end
  141. end
  142. 1 new(transformed_hash)
  143. end
  144. # Returns the object in the form of hash
  145. # @return [Hash] Returns the object in the form of hash
  146. 1 def to_hash
  147. 2 hash = {}
  148. 2 self.class.attribute_map.each_pair do |attr, param|
  149. 10 value = self.send(attr)
  150. 10 if value.nil?
  151. is_nullable = self.class.openapi_nullable.include?(attr)
  152. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  153. end
  154. 10 hash[param] = _to_hash(value)
  155. end
  156. 2 hash
  157. end
  158. end
  159. end

lib/bandwidth-sdk/models/conference_state_enum.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class ConferenceStateEnum
  13. 1 ACTIVE = 'active'.freeze
  14. 1 COMPLETED = 'completed'.freeze
  15. 1 def self.all_vars
  16. 5 @all_vars ||= [ACTIVE, COMPLETED].freeze
  17. end
  18. # Builds the enum from string
  19. # @param [String] The enum value in the form of the string
  20. # @return [String] The enum value
  21. 1 def self.build_from_hash(value)
  22. 4 new.build_from_hash(value)
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def build_from_hash(value)
  28. 4 return value if ConferenceStateEnum.all_vars.include?(value)
  29. 1 raise "Invalid ENUM value #{value} for class #ConferenceStateEnum"
  30. end
  31. end
  32. end

lib/bandwidth-sdk/models/contact.rb

62.42% lines covered

149 relevant lines. 93 lines covered and 56 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class Contact < ApiModelBase
  13. # The first name of the business contact using the toll-free number.
  14. 1 attr_accessor :first_name
  15. # The last name of the business contact using the toll-free number.
  16. 1 attr_accessor :last_name
  17. 1 attr_accessor :email
  18. # Contact telephone number
  19. 1 attr_accessor :phone_number
  20. # Attribute mapping from ruby-style variable name to JSON key.
  21. 1 def self.attribute_map
  22. 128 {
  23. :'first_name' => :'firstName',
  24. :'last_name' => :'lastName',
  25. :'email' => :'email',
  26. :'phone_number' => :'phoneNumber'
  27. }
  28. end
  29. # Returns attribute mapping this model knows about
  30. 1 def self.acceptable_attribute_map
  31. 27 attribute_map
  32. end
  33. # Returns all the JSON keys this model knows about
  34. 1 def self.acceptable_attributes
  35. 1 acceptable_attribute_map.values
  36. end
  37. # Attribute type mapping.
  38. 1 def self.openapi_types
  39. 6 {
  40. :'first_name' => :'String',
  41. :'last_name' => :'String',
  42. :'email' => :'String',
  43. :'phone_number' => :'String'
  44. }
  45. end
  46. # List of attributes with nullable: true
  47. 1 def self.openapi_nullable
  48. 1 Set.new([
  49. ])
  50. end
  51. # Initializes the object
  52. # @param [Hash] attributes Model attributes in the form of hash
  53. 1 def initialize(attributes = {})
  54. 27 if (!attributes.is_a?(Hash))
  55. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::Contact` initialize method'
  56. end
  57. # check to see if the attribute exists and convert string to symbol for hash key
  58. 26 acceptable_attribute_map = self.class.acceptable_attribute_map
  59. 26 attributes = attributes.each_with_object({}) { |(k, v), h|
  60. 101 if (!acceptable_attribute_map.key?(k.to_sym))
  61. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::Contact`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  62. end
  63. 100 h[k.to_sym] = v
  64. }
  65. 25 if attributes.key?(:'first_name')
  66. 25 self.first_name = attributes[:'first_name']
  67. else
  68. self.first_name = nil
  69. end
  70. 22 if attributes.key?(:'last_name')
  71. 22 self.last_name = attributes[:'last_name']
  72. else
  73. self.last_name = nil
  74. end
  75. 19 if attributes.key?(:'email')
  76. 19 self.email = attributes[:'email']
  77. else
  78. self.email = nil
  79. end
  80. 16 if attributes.key?(:'phone_number')
  81. 16 self.phone_number = attributes[:'phone_number']
  82. else
  83. self.phone_number = nil
  84. end
  85. end
  86. # Show invalid properties with the reasons. Usually used together with valid?
  87. # @return Array for valid properties with the reasons
  88. 1 def list_invalid_properties
  89. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  90. invalid_properties = Array.new
  91. if @first_name.nil?
  92. invalid_properties.push('invalid value for "first_name", first_name cannot be nil.')
  93. end
  94. if @first_name.to_s.length > 500
  95. invalid_properties.push('invalid value for "first_name", the character length must be smaller than or equal to 500.')
  96. end
  97. if @first_name.to_s.length < 1
  98. invalid_properties.push('invalid value for "first_name", the character length must be greater than or equal to 1.')
  99. end
  100. if @last_name.nil?
  101. invalid_properties.push('invalid value for "last_name", last_name cannot be nil.')
  102. end
  103. if @last_name.to_s.length > 500
  104. invalid_properties.push('invalid value for "last_name", the character length must be smaller than or equal to 500.')
  105. end
  106. if @last_name.to_s.length < 1
  107. invalid_properties.push('invalid value for "last_name", the character length must be greater than or equal to 1.')
  108. end
  109. if @email.nil?
  110. invalid_properties.push('invalid value for "email", email cannot be nil.')
  111. end
  112. if @email.to_s.length > 500
  113. invalid_properties.push('invalid value for "email", the character length must be smaller than or equal to 500.')
  114. end
  115. if @email.to_s.length < 0
  116. invalid_properties.push('invalid value for "email", the character length must be greater than or equal to 0.')
  117. end
  118. pattern = Regexp.new(/^(?:[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)
  119. if @email !~ pattern
  120. invalid_properties.push("invalid value for \"email\", must conform to the pattern #{pattern}.")
  121. end
  122. if @phone_number.nil?
  123. invalid_properties.push('invalid value for "phone_number", phone_number cannot be nil.')
  124. end
  125. if @phone_number.to_s.length > 500
  126. invalid_properties.push('invalid value for "phone_number", the character length must be smaller than or equal to 500.')
  127. end
  128. if @phone_number.to_s.length < 1
  129. invalid_properties.push('invalid value for "phone_number", the character length must be greater than or equal to 1.')
  130. end
  131. invalid_properties
  132. end
  133. # Check to see if the all the properties in the model are valid
  134. # @return true if the model is valid
  135. 1 def valid?
  136. warn '[DEPRECATED] the `valid?` method is obsolete'
  137. return false if @first_name.nil?
  138. return false if @first_name.to_s.length > 500
  139. return false if @first_name.to_s.length < 1
  140. return false if @last_name.nil?
  141. return false if @last_name.to_s.length > 500
  142. return false if @last_name.to_s.length < 1
  143. return false if @email.nil?
  144. return false if @email.to_s.length > 500
  145. return false if @email.to_s.length < 0
  146. return false if @email !~ Regexp.new(/^(?:[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)
  147. return false if @phone_number.nil?
  148. return false if @phone_number.to_s.length > 500
  149. return false if @phone_number.to_s.length < 1
  150. true
  151. end
  152. # Custom attribute writer method with validation
  153. # @param [Object] first_name Value to be assigned
  154. 1 def first_name=(first_name)
  155. 25 if first_name.nil?
  156. 1 fail ArgumentError, 'first_name cannot be nil'
  157. end
  158. 24 if first_name.to_s.length > 500
  159. 1 fail ArgumentError, 'invalid value for "first_name", the character length must be smaller than or equal to 500.'
  160. end
  161. 23 if first_name.to_s.length < 1
  162. 1 fail ArgumentError, 'invalid value for "first_name", the character length must be greater than or equal to 1.'
  163. end
  164. 22 @first_name = first_name
  165. end
  166. # Custom attribute writer method with validation
  167. # @param [Object] last_name Value to be assigned
  168. 1 def last_name=(last_name)
  169. 22 if last_name.nil?
  170. 1 fail ArgumentError, 'last_name cannot be nil'
  171. end
  172. 21 if last_name.to_s.length > 500
  173. 1 fail ArgumentError, 'invalid value for "last_name", the character length must be smaller than or equal to 500.'
  174. end
  175. 20 if last_name.to_s.length < 1
  176. 1 fail ArgumentError, 'invalid value for "last_name", the character length must be greater than or equal to 1.'
  177. end
  178. 19 @last_name = last_name
  179. end
  180. # Custom attribute writer method with validation
  181. # @param [Object] email Value to be assigned
  182. 1 def email=(email)
  183. 19 if email.nil?
  184. 1 fail ArgumentError, 'email cannot be nil'
  185. end
  186. 18 if email.to_s.length > 500
  187. 1 fail ArgumentError, 'invalid value for "email", the character length must be smaller than or equal to 500.'
  188. end
  189. 17 if email.to_s.length < 0
  190. fail ArgumentError, 'invalid value for "email", the character length must be greater than or equal to 0.'
  191. end
  192. 17 pattern = Regexp.new(/^(?:[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)
  193. 17 if email !~ pattern
  194. 1 fail ArgumentError, "invalid value for \"email\", must conform to the pattern #{pattern}."
  195. end
  196. 16 @email = email
  197. end
  198. # Custom attribute writer method with validation
  199. # @param [Object] phone_number Value to be assigned
  200. 1 def phone_number=(phone_number)
  201. 16 if phone_number.nil?
  202. 1 fail ArgumentError, 'phone_number cannot be nil'
  203. end
  204. 15 if phone_number.to_s.length > 500
  205. 1 fail ArgumentError, 'invalid value for "phone_number", the character length must be smaller than or equal to 500.'
  206. end
  207. 14 if phone_number.to_s.length < 1
  208. 1 fail ArgumentError, 'invalid value for "phone_number", the character length must be greater than or equal to 1.'
  209. end
  210. 13 @phone_number = phone_number
  211. end
  212. # Checks equality by comparing each attribute.
  213. # @param [Object] Object to be compared
  214. 1 def ==(o)
  215. 2 return true if self.equal?(o)
  216. 2 self.class == o.class &&
  217. first_name == o.first_name &&
  218. last_name == o.last_name &&
  219. email == o.email &&
  220. phone_number == o.phone_number
  221. end
  222. # @see the `==` method
  223. # @param [Object] Object to be compared
  224. 1 def eql?(o)
  225. 2 self == o
  226. end
  227. # Calculates hash code according to all attributes.
  228. # @return [Integer] Hash code
  229. 1 def hash
  230. [first_name, last_name, email, phone_number].hash
  231. end
  232. # Builds the object from hash
  233. # @param [Hash] attributes Model attributes in the form of hash
  234. # @return [Object] Returns the model itself
  235. 1 def self.build_from_hash(attributes)
  236. 6 return nil unless attributes.is_a?(Hash)
  237. 6 attributes = attributes.transform_keys(&:to_sym)
  238. 6 transformed_hash = {}
  239. 6 openapi_types.each_pair do |key, type|
  240. 24 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  241. transformed_hash["#{key}"] = nil
  242. 24 elsif type =~ /\AArray<(.*)>/i
  243. # check to ensure the input is an array given that the attribute
  244. # is documented as an array but the input is not
  245. if attributes[attribute_map[key]].is_a?(Array)
  246. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  247. end
  248. 24 elsif !attributes[attribute_map[key]].nil?
  249. 24 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  250. end
  251. end
  252. 6 new(transformed_hash)
  253. end
  254. # Returns the object in the form of hash
  255. # @return [Hash] Returns the object in the form of hash
  256. 1 def to_hash
  257. 4 hash = {}
  258. 4 self.class.attribute_map.each_pair do |attr, param|
  259. 16 value = self.send(attr)
  260. 16 if value.nil?
  261. is_nullable = self.class.openapi_nullable.include?(attr)
  262. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  263. end
  264. 16 hash[param] = _to_hash(value)
  265. end
  266. 4 hash
  267. end
  268. end
  269. end

lib/bandwidth-sdk/models/create_async_bulk_lookup_response.rb

86.96% lines covered

69 relevant lines. 60 lines covered and 9 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CreateAsyncBulkLookupResponse < ApiModelBase
  13. # Links for pagination (if applicable)
  14. 1 attr_accessor :links
  15. 1 attr_accessor :data
  16. 1 attr_accessor :errors
  17. # Attribute mapping from ruby-style variable name to JSON key.
  18. 1 def self.attribute_map
  19. 36 {
  20. :'links' => :'links',
  21. :'data' => :'data',
  22. :'errors' => :'errors'
  23. }
  24. end
  25. # Returns attribute mapping this model knows about
  26. 1 def self.acceptable_attribute_map
  27. 9 attribute_map
  28. end
  29. # Returns all the JSON keys this model knows about
  30. 1 def self.acceptable_attributes
  31. 1 acceptable_attribute_map.values
  32. end
  33. # Attribute type mapping.
  34. 1 def self.openapi_types
  35. 2 {
  36. :'links' => :'Array<LinkSchema>',
  37. :'data' => :'CreateAsyncBulkLookupResponseData',
  38. :'errors' => :'Array<LookupErrorSchema>'
  39. }
  40. end
  41. # List of attributes with nullable: true
  42. 1 def self.openapi_nullable
  43. 1 Set.new([
  44. ])
  45. end
  46. # Initializes the object
  47. # @param [Hash] attributes Model attributes in the form of hash
  48. 1 def initialize(attributes = {})
  49. 9 if (!attributes.is_a?(Hash))
  50. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CreateAsyncBulkLookupResponse` initialize method'
  51. end
  52. # check to see if the attribute exists and convert string to symbol for hash key
  53. 8 acceptable_attribute_map = self.class.acceptable_attribute_map
  54. 8 attributes = attributes.each_with_object({}) { |(k, v), h|
  55. 16 if (!acceptable_attribute_map.key?(k.to_sym))
  56. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CreateAsyncBulkLookupResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  57. end
  58. 15 h[k.to_sym] = v
  59. }
  60. 7 if attributes.key?(:'links')
  61. 5 if (value = attributes[:'links']).is_a?(Array)
  62. 5 self.links = value
  63. end
  64. end
  65. 7 if attributes.key?(:'data')
  66. 5 self.data = attributes[:'data']
  67. end
  68. 7 if attributes.key?(:'errors')
  69. 5 if (value = attributes[:'errors']).is_a?(Array)
  70. 5 self.errors = value
  71. end
  72. end
  73. end
  74. # Show invalid properties with the reasons. Usually used together with valid?
  75. # @return Array for valid properties with the reasons
  76. 1 def list_invalid_properties
  77. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  78. invalid_properties = Array.new
  79. invalid_properties
  80. end
  81. # Check to see if the all the properties in the model are valid
  82. # @return true if the model is valid
  83. 1 def valid?
  84. warn '[DEPRECATED] the `valid?` method is obsolete'
  85. true
  86. end
  87. # Checks equality by comparing each attribute.
  88. # @param [Object] Object to be compared
  89. 1 def ==(o)
  90. 2 return true if self.equal?(o)
  91. 2 self.class == o.class &&
  92. links == o.links &&
  93. data == o.data &&
  94. errors == o.errors
  95. end
  96. # @see the `==` method
  97. # @param [Object] Object to be compared
  98. 1 def eql?(o)
  99. 2 self == o
  100. end
  101. # Calculates hash code according to all attributes.
  102. # @return [Integer] Hash code
  103. 1 def hash
  104. [links, data, errors].hash
  105. end
  106. # Builds the object from hash
  107. # @param [Hash] attributes Model attributes in the form of hash
  108. # @return [Object] Returns the model itself
  109. 1 def self.build_from_hash(attributes)
  110. 2 return nil unless attributes.is_a?(Hash)
  111. 2 attributes = attributes.transform_keys(&:to_sym)
  112. 2 transformed_hash = {}
  113. 2 openapi_types.each_pair do |key, type|
  114. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  115. transformed_hash["#{key}"] = nil
  116. 6 elsif type =~ /\AArray<(.*)>/i
  117. # check to ensure the input is an array given that the attribute
  118. # is documented as an array but the input is not
  119. 4 if attributes[attribute_map[key]].is_a?(Array)
  120. 7 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  121. end
  122. 2 elsif !attributes[attribute_map[key]].nil?
  123. 2 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  124. end
  125. end
  126. 2 new(transformed_hash)
  127. end
  128. # Returns the object in the form of hash
  129. # @return [Hash] Returns the object in the form of hash
  130. 1 def to_hash
  131. 2 hash = {}
  132. 2 self.class.attribute_map.each_pair do |attr, param|
  133. 6 value = self.send(attr)
  134. 6 if value.nil?
  135. is_nullable = self.class.openapi_nullable.include?(attr)
  136. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  137. end
  138. 6 hash[param] = _to_hash(value)
  139. end
  140. 2 hash
  141. end
  142. end
  143. end

lib/bandwidth-sdk/models/create_async_bulk_lookup_response_data.rb

77.33% lines covered

75 relevant lines. 58 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The phone number lookup response data
  13. 1 class CreateAsyncBulkLookupResponseData < ApiModelBase
  14. # The phone number lookup request ID from Bandwidth.
  15. 1 attr_accessor :request_id
  16. 1 attr_accessor :status
  17. 1 class EnumAttributeValidator
  18. 1 attr_reader :datatype
  19. 1 attr_reader :allowable_values
  20. 1 def initialize(datatype, allowable_values)
  21. @allowable_values = allowable_values.map do |value|
  22. case datatype.to_s
  23. when /Integer/i
  24. value.to_i
  25. when /Float/i
  26. value.to_f
  27. else
  28. value
  29. end
  30. end
  31. end
  32. 1 def valid?(value)
  33. !value || allowable_values.include?(value)
  34. end
  35. end
  36. # Attribute mapping from ruby-style variable name to JSON key.
  37. 1 def self.attribute_map
  38. 42 {
  39. :'request_id' => :'requestId',
  40. :'status' => :'status'
  41. }
  42. end
  43. # Returns attribute mapping this model knows about
  44. 1 def self.acceptable_attribute_map
  45. 13 attribute_map
  46. end
  47. # Returns all the JSON keys this model knows about
  48. 1 def self.acceptable_attributes
  49. 1 acceptable_attribute_map.values
  50. end
  51. # Attribute type mapping.
  52. 1 def self.openapi_types
  53. 3 {
  54. :'request_id' => :'String',
  55. :'status' => :'InProgressLookupStatusEnum'
  56. }
  57. end
  58. # List of attributes with nullable: true
  59. 1 def self.openapi_nullable
  60. 1 Set.new([
  61. ])
  62. end
  63. # Initializes the object
  64. # @param [Hash] attributes Model attributes in the form of hash
  65. 1 def initialize(attributes = {})
  66. 13 if (!attributes.is_a?(Hash))
  67. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CreateAsyncBulkLookupResponseData` initialize method'
  68. end
  69. # check to see if the attribute exists and convert string to symbol for hash key
  70. 12 acceptable_attribute_map = self.class.acceptable_attribute_map
  71. 12 attributes = attributes.each_with_object({}) { |(k, v), h|
  72. 19 if (!acceptable_attribute_map.key?(k.to_sym))
  73. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CreateAsyncBulkLookupResponseData`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  74. end
  75. 18 h[k.to_sym] = v
  76. }
  77. 11 if attributes.key?(:'request_id')
  78. 9 self.request_id = attributes[:'request_id']
  79. end
  80. 11 if attributes.key?(:'status')
  81. 9 self.status = attributes[:'status']
  82. end
  83. end
  84. # Show invalid properties with the reasons. Usually used together with valid?
  85. # @return Array for valid properties with the reasons
  86. 1 def list_invalid_properties
  87. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  88. invalid_properties = Array.new
  89. invalid_properties
  90. end
  91. # Check to see if the all the properties in the model are valid
  92. # @return true if the model is valid
  93. 1 def valid?
  94. warn '[DEPRECATED] the `valid?` method is obsolete'
  95. true
  96. end
  97. # Checks equality by comparing each attribute.
  98. # @param [Object] Object to be compared
  99. 1 def ==(o)
  100. 2 return true if self.equal?(o)
  101. 2 self.class == o.class &&
  102. request_id == o.request_id &&
  103. status == o.status
  104. end
  105. # @see the `==` method
  106. # @param [Object] Object to be compared
  107. 1 def eql?(o)
  108. 2 self == o
  109. end
  110. # Calculates hash code according to all attributes.
  111. # @return [Integer] Hash code
  112. 1 def hash
  113. [request_id, status].hash
  114. end
  115. # Builds the object from hash
  116. # @param [Hash] attributes Model attributes in the form of hash
  117. # @return [Object] Returns the model itself
  118. 1 def self.build_from_hash(attributes)
  119. 3 return nil unless attributes.is_a?(Hash)
  120. 3 attributes = attributes.transform_keys(&:to_sym)
  121. 3 transformed_hash = {}
  122. 3 openapi_types.each_pair do |key, type|
  123. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  124. transformed_hash["#{key}"] = nil
  125. 6 elsif type =~ /\AArray<(.*)>/i
  126. # check to ensure the input is an array given that the attribute
  127. # is documented as an array but the input is not
  128. if attributes[attribute_map[key]].is_a?(Array)
  129. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  130. end
  131. 6 elsif !attributes[attribute_map[key]].nil?
  132. 6 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  133. end
  134. end
  135. 3 new(transformed_hash)
  136. end
  137. # Returns the object in the form of hash
  138. # @return [Hash] Returns the object in the form of hash
  139. 1 def to_hash
  140. 4 hash = {}
  141. 4 self.class.attribute_map.each_pair do |attr, param|
  142. 8 value = self.send(attr)
  143. 8 if value.nil?
  144. is_nullable = self.class.openapi_nullable.include?(attr)
  145. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  146. end
  147. 8 hash[param] = _to_hash(value)
  148. end
  149. 4 hash
  150. end
  151. end
  152. end

lib/bandwidth-sdk/models/create_call.rb

71.54% lines covered

267 relevant lines. 191 lines covered and 76 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CreateCall < ApiModelBase
  13. # The destination to call (must be an E.164 formatted number (e.g. `+15555551212`) or a SIP URI (e.g. `sip:user@server.example`)).
  14. 1 attr_accessor :to
  15. # A Bandwidth phone number on your account the call should come from (must be in E.164 format, like `+15555551212`) even if `privacy` is set to true.
  16. 1 attr_accessor :from
  17. # Hide the calling number. The `displayName` field can be used to customize the displayed name.
  18. 1 attr_accessor :privacy
  19. # The caller display name to use when the call is created. May not exceed 256 characters nor contain control characters such as new lines. If `privacy` is true, only the following values are valid: `Restricted`, `Anonymous`, `Private`, or `Unavailable`.
  20. 1 attr_accessor :display_name
  21. # A comma-separated list of 'User-To-User' headers to be sent in the INVITE when calling a SIP URI. Each value must end with an 'encoding' parameter as described in <a href='https://tools.ietf.org/html/rfc7433'>RFC 7433</a>. Only 'jwt', 'base64' and 'hex' encodings are allowed. The entire value cannot exceed 350 characters, including parameters and separators.
  22. 1 attr_accessor :uui
  23. # The id of the application associated with the `from` number.
  24. 1 attr_accessor :application_id
  25. # The full URL to send the <a href='/docs/voice/webhooks/answer'>Answer</a> event to when the called party answers. This endpoint should return the first <a href='/docs/voice/bxml'>BXML document</a> to be executed in the call. Must use `https` if specifying `username` and `password`.
  26. 1 attr_accessor :answer_url
  27. 1 attr_accessor :answer_method
  28. # Basic auth username.
  29. 1 attr_accessor :username
  30. # Basic auth password.
  31. 1 attr_accessor :password
  32. # A fallback url which, if provided, will be used to retry the `answer` webhook delivery in case `answerUrl` fails to respond Must use `https` if specifying `fallbackUsername` and `fallbackPassword`.
  33. 1 attr_accessor :answer_fallback_url
  34. 1 attr_accessor :answer_fallback_method
  35. # Basic auth username.
  36. 1 attr_accessor :fallback_username
  37. # Basic auth password.
  38. 1 attr_accessor :fallback_password
  39. # The URL to send the <a href='/docs/voice/webhooks/disconnect'>Disconnect</a> event to when the call ends. This event does not expect a BXML response.
  40. 1 attr_accessor :disconnect_url
  41. 1 attr_accessor :disconnect_method
  42. # The timeout (in seconds) for the callee to answer the call after it starts ringing. If the call does not start ringing within 30s, the call will be cancelled regardless of this value. Can be any numeric value (including decimals) between 1 and 300.
  43. 1 attr_accessor :call_timeout
  44. # This is the timeout (in seconds) to use when delivering webhooks for the call. Can be any numeric value (including decimals) between 1 and 25.
  45. 1 attr_accessor :callback_timeout
  46. 1 attr_accessor :machine_detection
  47. # The priority of this call over other calls from your account. For example, if during a call your application needs to place a new call and bridge it with the current call, you might want to create the call with priority 1 so that it will be the next call picked off your queue, ahead of other less time sensitive calls. A lower value means higher priority, so a priority 1 call takes precedence over a priority 2 call.
  48. 1 attr_accessor :priority
  49. # A custom string that will be sent with all webhooks for this call unless overwritten by a future <a href='/docs/voice/bxml/tag'>`<Tag>`</a> verb or `tag` attribute on another verb, or cleared. May be cleared by setting `tag=\"\"` Max length 4096 characters.
  50. 1 attr_accessor :tag
  51. 1 class EnumAttributeValidator
  52. 1 attr_reader :datatype
  53. 1 attr_reader :allowable_values
  54. 1 def initialize(datatype, allowable_values)
  55. @allowable_values = allowable_values.map do |value|
  56. case datatype.to_s
  57. when /Integer/i
  58. value.to_i
  59. when /Float/i
  60. value.to_f
  61. else
  62. value
  63. end
  64. end
  65. end
  66. 1 def valid?(value)
  67. !value || allowable_values.include?(value)
  68. end
  69. end
  70. # Attribute mapping from ruby-style variable name to JSON key.
  71. 1 def self.attribute_map
  72. 114 {
  73. :'to' => :'to',
  74. :'from' => :'from',
  75. :'privacy' => :'privacy',
  76. :'display_name' => :'displayName',
  77. :'uui' => :'uui',
  78. :'application_id' => :'applicationId',
  79. :'answer_url' => :'answerUrl',
  80. :'answer_method' => :'answerMethod',
  81. :'username' => :'username',
  82. :'password' => :'password',
  83. :'answer_fallback_url' => :'answerFallbackUrl',
  84. :'answer_fallback_method' => :'answerFallbackMethod',
  85. :'fallback_username' => :'fallbackUsername',
  86. :'fallback_password' => :'fallbackPassword',
  87. :'disconnect_url' => :'disconnectUrl',
  88. :'disconnect_method' => :'disconnectMethod',
  89. :'call_timeout' => :'callTimeout',
  90. :'callback_timeout' => :'callbackTimeout',
  91. :'machine_detection' => :'machineDetection',
  92. :'priority' => :'priority',
  93. :'tag' => :'tag'
  94. }
  95. end
  96. # Returns attribute mapping this model knows about
  97. 1 def self.acceptable_attribute_map
  98. 28 attribute_map
  99. end
  100. # Returns all the JSON keys this model knows about
  101. 1 def self.acceptable_attributes
  102. 1 acceptable_attribute_map.values
  103. end
  104. # Attribute type mapping.
  105. 1 def self.openapi_types
  106. 1 {
  107. :'to' => :'String',
  108. :'from' => :'String',
  109. :'privacy' => :'Boolean',
  110. :'display_name' => :'String',
  111. :'uui' => :'String',
  112. :'application_id' => :'String',
  113. :'answer_url' => :'String',
  114. :'answer_method' => :'CallbackMethodEnum',
  115. :'username' => :'String',
  116. :'password' => :'String',
  117. :'answer_fallback_url' => :'String',
  118. :'answer_fallback_method' => :'CallbackMethodEnum',
  119. :'fallback_username' => :'String',
  120. :'fallback_password' => :'String',
  121. :'disconnect_url' => :'String',
  122. :'disconnect_method' => :'CallbackMethodEnum',
  123. :'call_timeout' => :'Float',
  124. :'callback_timeout' => :'Float',
  125. :'machine_detection' => :'MachineDetectionConfiguration',
  126. :'priority' => :'Integer',
  127. :'tag' => :'String'
  128. }
  129. end
  130. # List of attributes with nullable: true
  131. 1 def self.openapi_nullable
  132. 4 Set.new([
  133. :'privacy',
  134. :'display_name',
  135. :'uui',
  136. :'answer_method',
  137. :'username',
  138. :'password',
  139. :'answer_fallback_url',
  140. :'answer_fallback_method',
  141. :'fallback_username',
  142. :'fallback_password',
  143. :'disconnect_url',
  144. :'disconnect_method',
  145. :'call_timeout',
  146. :'callback_timeout',
  147. :'priority',
  148. :'tag'
  149. ])
  150. end
  151. # Initializes the object
  152. # @param [Hash] attributes Model attributes in the form of hash
  153. 1 def initialize(attributes = {})
  154. 28 if (!attributes.is_a?(Hash))
  155. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CreateCall` initialize method'
  156. end
  157. # check to see if the attribute exists and convert string to symbol for hash key
  158. 27 acceptable_attribute_map = self.class.acceptable_attribute_map
  159. 27 attributes = attributes.each_with_object({}) { |(k, v), h|
  160. 200 if (!acceptable_attribute_map.key?(k.to_sym))
  161. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CreateCall`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  162. end
  163. 199 h[k.to_sym] = v
  164. }
  165. 26 if attributes.key?(:'to')
  166. 26 self.to = attributes[:'to']
  167. else
  168. self.to = nil
  169. end
  170. 25 if attributes.key?(:'from')
  171. 25 self.from = attributes[:'from']
  172. else
  173. self.from = nil
  174. end
  175. 24 if attributes.key?(:'privacy')
  176. 4 self.privacy = attributes[:'privacy']
  177. end
  178. 24 if attributes.key?(:'display_name')
  179. 5 self.display_name = attributes[:'display_name']
  180. end
  181. 23 if attributes.key?(:'uui')
  182. 4 self.uui = attributes[:'uui']
  183. end
  184. 23 if attributes.key?(:'application_id')
  185. 23 self.application_id = attributes[:'application_id']
  186. else
  187. self.application_id = nil
  188. end
  189. 22 if attributes.key?(:'answer_url')
  190. 22 self.answer_url = attributes[:'answer_url']
  191. else
  192. self.answer_url = nil
  193. end
  194. 20 if attributes.key?(:'answer_method')
  195. 5 self.answer_method = attributes[:'answer_method']
  196. else
  197. 15 self.answer_method = 'POST'
  198. end
  199. 20 if attributes.key?(:'username')
  200. 6 self.username = attributes[:'username']
  201. end
  202. 19 if attributes.key?(:'password')
  203. 6 self.password = attributes[:'password']
  204. end
  205. 18 if attributes.key?(:'answer_fallback_url')
  206. 6 self.answer_fallback_url = attributes[:'answer_fallback_url']
  207. end
  208. 17 if attributes.key?(:'answer_fallback_method')
  209. 5 self.answer_fallback_method = attributes[:'answer_fallback_method']
  210. else
  211. 12 self.answer_fallback_method = 'POST'
  212. end
  213. 17 if attributes.key?(:'fallback_username')
  214. 6 self.fallback_username = attributes[:'fallback_username']
  215. end
  216. 16 if attributes.key?(:'fallback_password')
  217. 6 self.fallback_password = attributes[:'fallback_password']
  218. end
  219. 15 if attributes.key?(:'disconnect_url')
  220. 6 self.disconnect_url = attributes[:'disconnect_url']
  221. end
  222. 14 if attributes.key?(:'disconnect_method')
  223. 5 self.disconnect_method = attributes[:'disconnect_method']
  224. else
  225. 9 self.disconnect_method = 'POST'
  226. end
  227. 14 if attributes.key?(:'call_timeout')
  228. 7 self.call_timeout = attributes[:'call_timeout']
  229. else
  230. 7 self.call_timeout = 30
  231. end
  232. 12 if attributes.key?(:'callback_timeout')
  233. 7 self.callback_timeout = attributes[:'callback_timeout']
  234. else
  235. 5 self.callback_timeout = 15
  236. end
  237. 10 if attributes.key?(:'machine_detection')
  238. 4 self.machine_detection = attributes[:'machine_detection']
  239. end
  240. 10 if attributes.key?(:'priority')
  241. 7 self.priority = attributes[:'priority']
  242. else
  243. 3 self.priority = 5
  244. end
  245. 8 if attributes.key?(:'tag')
  246. 6 self.tag = attributes[:'tag']
  247. end
  248. end
  249. # Show invalid properties with the reasons. Usually used together with valid?
  250. # @return Array for valid properties with the reasons
  251. 1 def list_invalid_properties
  252. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  253. invalid_properties = Array.new
  254. if @to.nil?
  255. invalid_properties.push('invalid value for "to", to cannot be nil.')
  256. end
  257. if @from.nil?
  258. invalid_properties.push('invalid value for "from", from cannot be nil.')
  259. end
  260. if !@display_name.nil? && @display_name.to_s.length > 256
  261. invalid_properties.push('invalid value for "display_name", the character length must be smaller than or equal to 256.')
  262. end
  263. if @application_id.nil?
  264. invalid_properties.push('invalid value for "application_id", application_id cannot be nil.')
  265. end
  266. if @answer_url.nil?
  267. invalid_properties.push('invalid value for "answer_url", answer_url cannot be nil.')
  268. end
  269. if @answer_url.to_s.length > 2048
  270. invalid_properties.push('invalid value for "answer_url", the character length must be smaller than or equal to 2048.')
  271. end
  272. if !@username.nil? && @username.to_s.length > 1024
  273. invalid_properties.push('invalid value for "username", the character length must be smaller than or equal to 1024.')
  274. end
  275. if !@password.nil? && @password.to_s.length > 1024
  276. invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 1024.')
  277. end
  278. if !@answer_fallback_url.nil? && @answer_fallback_url.to_s.length > 2048
  279. invalid_properties.push('invalid value for "answer_fallback_url", the character length must be smaller than or equal to 2048.')
  280. end
  281. if !@fallback_username.nil? && @fallback_username.to_s.length > 1024
  282. invalid_properties.push('invalid value for "fallback_username", the character length must be smaller than or equal to 1024.')
  283. end
  284. if !@fallback_password.nil? && @fallback_password.to_s.length > 1024
  285. invalid_properties.push('invalid value for "fallback_password", the character length must be smaller than or equal to 1024.')
  286. end
  287. if !@disconnect_url.nil? && @disconnect_url.to_s.length > 2048
  288. invalid_properties.push('invalid value for "disconnect_url", the character length must be smaller than or equal to 2048.')
  289. end
  290. if !@call_timeout.nil? && @call_timeout > 300
  291. invalid_properties.push('invalid value for "call_timeout", must be smaller than or equal to 300.')
  292. end
  293. if !@call_timeout.nil? && @call_timeout < 1
  294. invalid_properties.push('invalid value for "call_timeout", must be greater than or equal to 1.')
  295. end
  296. if !@callback_timeout.nil? && @callback_timeout > 25
  297. invalid_properties.push('invalid value for "callback_timeout", must be smaller than or equal to 25.')
  298. end
  299. if !@callback_timeout.nil? && @callback_timeout < 1
  300. invalid_properties.push('invalid value for "callback_timeout", must be greater than or equal to 1.')
  301. end
  302. if !@priority.nil? && @priority > 5
  303. invalid_properties.push('invalid value for "priority", must be smaller than or equal to 5.')
  304. end
  305. if !@priority.nil? && @priority < 1
  306. invalid_properties.push('invalid value for "priority", must be greater than or equal to 1.')
  307. end
  308. if !@tag.nil? && @tag.to_s.length > 4096
  309. invalid_properties.push('invalid value for "tag", the character length must be smaller than or equal to 4096.')
  310. end
  311. invalid_properties
  312. end
  313. # Check to see if the all the properties in the model are valid
  314. # @return true if the model is valid
  315. 1 def valid?
  316. warn '[DEPRECATED] the `valid?` method is obsolete'
  317. return false if @to.nil?
  318. return false if @from.nil?
  319. return false if !@display_name.nil? && @display_name.to_s.length > 256
  320. return false if @application_id.nil?
  321. return false if @answer_url.nil?
  322. return false if @answer_url.to_s.length > 2048
  323. return false if !@username.nil? && @username.to_s.length > 1024
  324. return false if !@password.nil? && @password.to_s.length > 1024
  325. return false if !@answer_fallback_url.nil? && @answer_fallback_url.to_s.length > 2048
  326. return false if !@fallback_username.nil? && @fallback_username.to_s.length > 1024
  327. return false if !@fallback_password.nil? && @fallback_password.to_s.length > 1024
  328. return false if !@disconnect_url.nil? && @disconnect_url.to_s.length > 2048
  329. return false if !@call_timeout.nil? && @call_timeout > 300
  330. return false if !@call_timeout.nil? && @call_timeout < 1
  331. return false if !@callback_timeout.nil? && @callback_timeout > 25
  332. return false if !@callback_timeout.nil? && @callback_timeout < 1
  333. return false if !@priority.nil? && @priority > 5
  334. return false if !@priority.nil? && @priority < 1
  335. return false if !@tag.nil? && @tag.to_s.length > 4096
  336. true
  337. end
  338. # Custom attribute writer method with validation
  339. # @param [Object] to Value to be assigned
  340. 1 def to=(to)
  341. 26 if to.nil?
  342. 1 fail ArgumentError, 'to cannot be nil'
  343. end
  344. 25 @to = to
  345. end
  346. # Custom attribute writer method with validation
  347. # @param [Object] from Value to be assigned
  348. 1 def from=(from)
  349. 25 if from.nil?
  350. 1 fail ArgumentError, 'from cannot be nil'
  351. end
  352. 24 @from = from
  353. end
  354. # Custom attribute writer method with validation
  355. # @param [Object] display_name Value to be assigned
  356. 1 def display_name=(display_name)
  357. 5 if !display_name.nil? && display_name.to_s.length > 256
  358. 1 fail ArgumentError, 'invalid value for "display_name", the character length must be smaller than or equal to 256.'
  359. end
  360. 4 @display_name = display_name
  361. end
  362. # Custom attribute writer method with validation
  363. # @param [Object] application_id Value to be assigned
  364. 1 def application_id=(application_id)
  365. 23 if application_id.nil?
  366. 1 fail ArgumentError, 'application_id cannot be nil'
  367. end
  368. 22 @application_id = application_id
  369. end
  370. # Custom attribute writer method with validation
  371. # @param [Object] answer_url Value to be assigned
  372. 1 def answer_url=(answer_url)
  373. 22 if answer_url.nil?
  374. 1 fail ArgumentError, 'answer_url cannot be nil'
  375. end
  376. 21 if answer_url.to_s.length > 2048
  377. 1 fail ArgumentError, 'invalid value for "answer_url", the character length must be smaller than or equal to 2048.'
  378. end
  379. 20 @answer_url = answer_url
  380. end
  381. # Custom attribute writer method with validation
  382. # @param [Object] username Value to be assigned
  383. 1 def username=(username)
  384. 6 if !username.nil? && username.to_s.length > 1024
  385. 1 fail ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 1024.'
  386. end
  387. 5 @username = username
  388. end
  389. # Custom attribute writer method with validation
  390. # @param [Object] password Value to be assigned
  391. 1 def password=(password)
  392. 6 if !password.nil? && password.to_s.length > 1024
  393. 1 fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 1024.'
  394. end
  395. 5 @password = password
  396. end
  397. # Custom attribute writer method with validation
  398. # @param [Object] answer_fallback_url Value to be assigned
  399. 1 def answer_fallback_url=(answer_fallback_url)
  400. 6 if !answer_fallback_url.nil? && answer_fallback_url.to_s.length > 2048
  401. 1 fail ArgumentError, 'invalid value for "answer_fallback_url", the character length must be smaller than or equal to 2048.'
  402. end
  403. 5 @answer_fallback_url = answer_fallback_url
  404. end
  405. # Custom attribute writer method with validation
  406. # @param [Object] fallback_username Value to be assigned
  407. 1 def fallback_username=(fallback_username)
  408. 6 if !fallback_username.nil? && fallback_username.to_s.length > 1024
  409. 1 fail ArgumentError, 'invalid value for "fallback_username", the character length must be smaller than or equal to 1024.'
  410. end
  411. 5 @fallback_username = fallback_username
  412. end
  413. # Custom attribute writer method with validation
  414. # @param [Object] fallback_password Value to be assigned
  415. 1 def fallback_password=(fallback_password)
  416. 6 if !fallback_password.nil? && fallback_password.to_s.length > 1024
  417. 1 fail ArgumentError, 'invalid value for "fallback_password", the character length must be smaller than or equal to 1024.'
  418. end
  419. 5 @fallback_password = fallback_password
  420. end
  421. # Custom attribute writer method with validation
  422. # @param [Object] disconnect_url Value to be assigned
  423. 1 def disconnect_url=(disconnect_url)
  424. 6 if !disconnect_url.nil? && disconnect_url.to_s.length > 2048
  425. 1 fail ArgumentError, 'invalid value for "disconnect_url", the character length must be smaller than or equal to 2048.'
  426. end
  427. 5 @disconnect_url = disconnect_url
  428. end
  429. # Custom attribute writer method with validation
  430. # @param [Object] call_timeout Value to be assigned
  431. 1 def call_timeout=(call_timeout)
  432. 14 if !call_timeout.nil? && call_timeout > 300
  433. 1 fail ArgumentError, 'invalid value for "call_timeout", must be smaller than or equal to 300.'
  434. end
  435. 13 if !call_timeout.nil? && call_timeout < 1
  436. 1 fail ArgumentError, 'invalid value for "call_timeout", must be greater than or equal to 1.'
  437. end
  438. 12 @call_timeout = call_timeout
  439. end
  440. # Custom attribute writer method with validation
  441. # @param [Object] callback_timeout Value to be assigned
  442. 1 def callback_timeout=(callback_timeout)
  443. 12 if !callback_timeout.nil? && callback_timeout > 25
  444. 1 fail ArgumentError, 'invalid value for "callback_timeout", must be smaller than or equal to 25.'
  445. end
  446. 11 if !callback_timeout.nil? && callback_timeout < 1
  447. 1 fail ArgumentError, 'invalid value for "callback_timeout", must be greater than or equal to 1.'
  448. end
  449. 10 @callback_timeout = callback_timeout
  450. end
  451. # Custom attribute writer method with validation
  452. # @param [Object] priority Value to be assigned
  453. 1 def priority=(priority)
  454. 10 if !priority.nil? && priority > 5
  455. 1 fail ArgumentError, 'invalid value for "priority", must be smaller than or equal to 5.'
  456. end
  457. 9 if !priority.nil? && priority < 1
  458. 1 fail ArgumentError, 'invalid value for "priority", must be greater than or equal to 1.'
  459. end
  460. 8 @priority = priority
  461. end
  462. # Custom attribute writer method with validation
  463. # @param [Object] tag Value to be assigned
  464. 1 def tag=(tag)
  465. 6 if !tag.nil? && tag.to_s.length > 4096
  466. 1 fail ArgumentError, 'invalid value for "tag", the character length must be smaller than or equal to 4096.'
  467. end
  468. 5 @tag = tag
  469. end
  470. # Checks equality by comparing each attribute.
  471. # @param [Object] Object to be compared
  472. 1 def ==(o)
  473. 2 return true if self.equal?(o)
  474. 2 self.class == o.class &&
  475. to == o.to &&
  476. from == o.from &&
  477. privacy == o.privacy &&
  478. display_name == o.display_name &&
  479. uui == o.uui &&
  480. application_id == o.application_id &&
  481. answer_url == o.answer_url &&
  482. answer_method == o.answer_method &&
  483. username == o.username &&
  484. password == o.password &&
  485. answer_fallback_url == o.answer_fallback_url &&
  486. answer_fallback_method == o.answer_fallback_method &&
  487. fallback_username == o.fallback_username &&
  488. fallback_password == o.fallback_password &&
  489. disconnect_url == o.disconnect_url &&
  490. disconnect_method == o.disconnect_method &&
  491. call_timeout == o.call_timeout &&
  492. callback_timeout == o.callback_timeout &&
  493. machine_detection == o.machine_detection &&
  494. priority == o.priority &&
  495. tag == o.tag
  496. end
  497. # @see the `==` method
  498. # @param [Object] Object to be compared
  499. 1 def eql?(o)
  500. 2 self == o
  501. end
  502. # Calculates hash code according to all attributes.
  503. # @return [Integer] Hash code
  504. 1 def hash
  505. [to, from, privacy, display_name, uui, application_id, answer_url, answer_method, username, password, answer_fallback_url, answer_fallback_method, fallback_username, fallback_password, disconnect_url, disconnect_method, call_timeout, callback_timeout, machine_detection, priority, tag].hash
  506. end
  507. # Builds the object from hash
  508. # @param [Hash] attributes Model attributes in the form of hash
  509. # @return [Object] Returns the model itself
  510. 1 def self.build_from_hash(attributes)
  511. 1 return nil unless attributes.is_a?(Hash)
  512. 1 attributes = attributes.transform_keys(&:to_sym)
  513. 1 transformed_hash = {}
  514. 1 openapi_types.each_pair do |key, type|
  515. 21 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  516. transformed_hash["#{key}"] = nil
  517. 21 elsif type =~ /\AArray<(.*)>/i
  518. # check to ensure the input is an array given that the attribute
  519. # is documented as an array but the input is not
  520. if attributes[attribute_map[key]].is_a?(Array)
  521. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  522. end
  523. 21 elsif !attributes[attribute_map[key]].nil?
  524. 20 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  525. end
  526. end
  527. 1 new(transformed_hash)
  528. end
  529. # Returns the object in the form of hash
  530. # @return [Hash] Returns the object in the form of hash
  531. 1 def to_hash
  532. 3 hash = {}
  533. 3 self.class.attribute_map.each_pair do |attr, param|
  534. 63 value = self.send(attr)
  535. 63 if value.nil?
  536. 3 is_nullable = self.class.openapi_nullable.include?(attr)
  537. 3 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  538. end
  539. 60 hash[param] = _to_hash(value)
  540. end
  541. 3 hash
  542. end
  543. end
  544. end

lib/bandwidth-sdk/models/create_call_response.rb

73.97% lines covered

219 relevant lines. 162 lines covered and 57 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CreateCallResponse < ApiModelBase
  13. # The id of the application associated with the `from` number.
  14. 1 attr_accessor :application_id
  15. # The bandwidth account ID associated with the call.
  16. 1 attr_accessor :account_id
  17. # Programmable Voice API Call ID.
  18. 1 attr_accessor :call_id
  19. # Recipient of the outgoing call.
  20. 1 attr_accessor :to
  21. # Phone number that created the outbound call.
  22. 1 attr_accessor :from
  23. # The time at which the call was accepted into the queue.
  24. 1 attr_accessor :enqueued_time
  25. # The URL to update this call's state.
  26. 1 attr_accessor :call_url
  27. # The timeout (in seconds) for the callee to answer the call after it starts ringing.
  28. 1 attr_accessor :call_timeout
  29. # This is the timeout (in seconds) to use when delivering webhooks for the call.
  30. 1 attr_accessor :callback_timeout
  31. # Custom tag value.
  32. 1 attr_accessor :tag
  33. 1 attr_accessor :answer_method
  34. # URL to deliver the `answer` event webhook.
  35. 1 attr_accessor :answer_url
  36. 1 attr_accessor :answer_fallback_method
  37. # Fallback URL to deliver the `answer` event webhook.
  38. 1 attr_accessor :answer_fallback_url
  39. 1 attr_accessor :disconnect_method
  40. # URL to deliver the `disconnect` event webhook.
  41. 1 attr_accessor :disconnect_url
  42. # Basic auth username.
  43. 1 attr_accessor :username
  44. # Basic auth password.
  45. 1 attr_accessor :password
  46. # Basic auth username.
  47. 1 attr_accessor :fallback_username
  48. # Basic auth password.
  49. 1 attr_accessor :fallback_password
  50. # The priority of this call over other calls from your account.
  51. 1 attr_accessor :priority
  52. 1 class EnumAttributeValidator
  53. 1 attr_reader :datatype
  54. 1 attr_reader :allowable_values
  55. 1 def initialize(datatype, allowable_values)
  56. @allowable_values = allowable_values.map do |value|
  57. case datatype.to_s
  58. when /Integer/i
  59. value.to_i
  60. when /Float/i
  61. value.to_f
  62. else
  63. value
  64. end
  65. end
  66. end
  67. 1 def valid?(value)
  68. !value || allowable_values.include?(value)
  69. end
  70. end
  71. # Attribute mapping from ruby-style variable name to JSON key.
  72. 1 def self.attribute_map
  73. 191 {
  74. :'application_id' => :'applicationId',
  75. :'account_id' => :'accountId',
  76. :'call_id' => :'callId',
  77. :'to' => :'to',
  78. :'from' => :'from',
  79. :'enqueued_time' => :'enqueuedTime',
  80. :'call_url' => :'callUrl',
  81. :'call_timeout' => :'callTimeout',
  82. :'callback_timeout' => :'callbackTimeout',
  83. :'tag' => :'tag',
  84. :'answer_method' => :'answerMethod',
  85. :'answer_url' => :'answerUrl',
  86. :'answer_fallback_method' => :'answerFallbackMethod',
  87. :'answer_fallback_url' => :'answerFallbackUrl',
  88. :'disconnect_method' => :'disconnectMethod',
  89. :'disconnect_url' => :'disconnectUrl',
  90. :'username' => :'username',
  91. :'password' => :'password',
  92. :'fallback_username' => :'fallbackUsername',
  93. :'fallback_password' => :'fallbackPassword',
  94. :'priority' => :'priority'
  95. }
  96. end
  97. # Returns attribute mapping this model knows about
  98. 1 def self.acceptable_attribute_map
  99. 20 attribute_map
  100. end
  101. # Returns all the JSON keys this model knows about
  102. 1 def self.acceptable_attributes
  103. 1 acceptable_attribute_map.values
  104. end
  105. # Attribute type mapping.
  106. 1 def self.openapi_types
  107. 2 {
  108. :'application_id' => :'String',
  109. :'account_id' => :'String',
  110. :'call_id' => :'String',
  111. :'to' => :'String',
  112. :'from' => :'String',
  113. :'enqueued_time' => :'Time',
  114. :'call_url' => :'String',
  115. :'call_timeout' => :'Float',
  116. :'callback_timeout' => :'Float',
  117. :'tag' => :'String',
  118. :'answer_method' => :'CallbackMethodEnum',
  119. :'answer_url' => :'String',
  120. :'answer_fallback_method' => :'CallbackMethodEnum',
  121. :'answer_fallback_url' => :'String',
  122. :'disconnect_method' => :'CallbackMethodEnum',
  123. :'disconnect_url' => :'String',
  124. :'username' => :'String',
  125. :'password' => :'String',
  126. :'fallback_username' => :'String',
  127. :'fallback_password' => :'String',
  128. :'priority' => :'Integer'
  129. }
  130. end
  131. # List of attributes with nullable: true
  132. 1 def self.openapi_nullable
  133. 1 Set.new([
  134. :'enqueued_time',
  135. :'tag',
  136. :'answer_method',
  137. :'answer_fallback_method',
  138. :'answer_fallback_url',
  139. :'disconnect_method',
  140. :'disconnect_url',
  141. :'username',
  142. :'password',
  143. :'fallback_username',
  144. :'fallback_password',
  145. :'priority'
  146. ])
  147. end
  148. # Initializes the object
  149. # @param [Hash] attributes Model attributes in the form of hash
  150. 1 def initialize(attributes = {})
  151. 20 if (!attributes.is_a?(Hash))
  152. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CreateCallResponse` initialize method'
  153. end
  154. # check to see if the attribute exists and convert string to symbol for hash key
  155. 19 acceptable_attribute_map = self.class.acceptable_attribute_map
  156. 19 attributes = attributes.each_with_object({}) { |(k, v), h|
  157. 201 if (!acceptable_attribute_map.key?(k.to_sym))
  158. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CreateCallResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  159. end
  160. 200 h[k.to_sym] = v
  161. }
  162. 18 if attributes.key?(:'application_id')
  163. 18 self.application_id = attributes[:'application_id']
  164. else
  165. self.application_id = nil
  166. end
  167. 17 if attributes.key?(:'account_id')
  168. 17 self.account_id = attributes[:'account_id']
  169. else
  170. self.account_id = nil
  171. end
  172. 16 if attributes.key?(:'call_id')
  173. 16 self.call_id = attributes[:'call_id']
  174. else
  175. self.call_id = nil
  176. end
  177. 15 if attributes.key?(:'to')
  178. 15 self.to = attributes[:'to']
  179. else
  180. self.to = nil
  181. end
  182. 14 if attributes.key?(:'from')
  183. 14 self.from = attributes[:'from']
  184. else
  185. self.from = nil
  186. end
  187. 13 if attributes.key?(:'enqueued_time')
  188. 5 self.enqueued_time = attributes[:'enqueued_time']
  189. end
  190. 13 if attributes.key?(:'call_url')
  191. 13 self.call_url = attributes[:'call_url']
  192. else
  193. self.call_url = nil
  194. end
  195. 12 if attributes.key?(:'call_timeout')
  196. 5 self.call_timeout = attributes[:'call_timeout']
  197. end
  198. 12 if attributes.key?(:'callback_timeout')
  199. 5 self.callback_timeout = attributes[:'callback_timeout']
  200. end
  201. 12 if attributes.key?(:'tag')
  202. 5 self.tag = attributes[:'tag']
  203. end
  204. 12 if attributes.key?(:'answer_method')
  205. 5 self.answer_method = attributes[:'answer_method']
  206. else
  207. 7 self.answer_method = 'POST'
  208. end
  209. 12 if attributes.key?(:'answer_url')
  210. 12 self.answer_url = attributes[:'answer_url']
  211. else
  212. self.answer_url = nil
  213. end
  214. 11 if attributes.key?(:'answer_fallback_method')
  215. 5 self.answer_fallback_method = attributes[:'answer_fallback_method']
  216. else
  217. 6 self.answer_fallback_method = 'POST'
  218. end
  219. 11 if attributes.key?(:'answer_fallback_url')
  220. 5 self.answer_fallback_url = attributes[:'answer_fallback_url']
  221. end
  222. 11 if attributes.key?(:'disconnect_method')
  223. 5 self.disconnect_method = attributes[:'disconnect_method']
  224. else
  225. 6 self.disconnect_method = 'POST'
  226. end
  227. 11 if attributes.key?(:'disconnect_url')
  228. 5 self.disconnect_url = attributes[:'disconnect_url']
  229. end
  230. 11 if attributes.key?(:'username')
  231. 6 self.username = attributes[:'username']
  232. end
  233. 10 if attributes.key?(:'password')
  234. 6 self.password = attributes[:'password']
  235. end
  236. 9 if attributes.key?(:'fallback_username')
  237. 6 self.fallback_username = attributes[:'fallback_username']
  238. end
  239. 8 if attributes.key?(:'fallback_password')
  240. 6 self.fallback_password = attributes[:'fallback_password']
  241. end
  242. 7 if attributes.key?(:'priority')
  243. 5 self.priority = attributes[:'priority']
  244. end
  245. end
  246. # Show invalid properties with the reasons. Usually used together with valid?
  247. # @return Array for valid properties with the reasons
  248. 1 def list_invalid_properties
  249. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  250. invalid_properties = Array.new
  251. if @application_id.nil?
  252. invalid_properties.push('invalid value for "application_id", application_id cannot be nil.')
  253. end
  254. if @account_id.nil?
  255. invalid_properties.push('invalid value for "account_id", account_id cannot be nil.')
  256. end
  257. if @call_id.nil?
  258. invalid_properties.push('invalid value for "call_id", call_id cannot be nil.')
  259. end
  260. if @to.nil?
  261. invalid_properties.push('invalid value for "to", to cannot be nil.')
  262. end
  263. if @from.nil?
  264. invalid_properties.push('invalid value for "from", from cannot be nil.')
  265. end
  266. if @call_url.nil?
  267. invalid_properties.push('invalid value for "call_url", call_url cannot be nil.')
  268. end
  269. if @answer_url.nil?
  270. invalid_properties.push('invalid value for "answer_url", answer_url cannot be nil.')
  271. end
  272. if !@username.nil? && @username.to_s.length > 1024
  273. invalid_properties.push('invalid value for "username", the character length must be smaller than or equal to 1024.')
  274. end
  275. if !@password.nil? && @password.to_s.length > 1024
  276. invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 1024.')
  277. end
  278. if !@fallback_username.nil? && @fallback_username.to_s.length > 1024
  279. invalid_properties.push('invalid value for "fallback_username", the character length must be smaller than or equal to 1024.')
  280. end
  281. if !@fallback_password.nil? && @fallback_password.to_s.length > 1024
  282. invalid_properties.push('invalid value for "fallback_password", the character length must be smaller than or equal to 1024.')
  283. end
  284. invalid_properties
  285. end
  286. # Check to see if the all the properties in the model are valid
  287. # @return true if the model is valid
  288. 1 def valid?
  289. warn '[DEPRECATED] the `valid?` method is obsolete'
  290. return false if @application_id.nil?
  291. return false if @account_id.nil?
  292. return false if @call_id.nil?
  293. return false if @to.nil?
  294. return false if @from.nil?
  295. return false if @call_url.nil?
  296. return false if @answer_url.nil?
  297. return false if !@username.nil? && @username.to_s.length > 1024
  298. return false if !@password.nil? && @password.to_s.length > 1024
  299. return false if !@fallback_username.nil? && @fallback_username.to_s.length > 1024
  300. return false if !@fallback_password.nil? && @fallback_password.to_s.length > 1024
  301. true
  302. end
  303. # Custom attribute writer method with validation
  304. # @param [Object] application_id Value to be assigned
  305. 1 def application_id=(application_id)
  306. 18 if application_id.nil?
  307. 1 fail ArgumentError, 'application_id cannot be nil'
  308. end
  309. 17 @application_id = application_id
  310. end
  311. # Custom attribute writer method with validation
  312. # @param [Object] account_id Value to be assigned
  313. 1 def account_id=(account_id)
  314. 17 if account_id.nil?
  315. 1 fail ArgumentError, 'account_id cannot be nil'
  316. end
  317. 16 @account_id = account_id
  318. end
  319. # Custom attribute writer method with validation
  320. # @param [Object] call_id Value to be assigned
  321. 1 def call_id=(call_id)
  322. 16 if call_id.nil?
  323. 1 fail ArgumentError, 'call_id cannot be nil'
  324. end
  325. 15 @call_id = call_id
  326. end
  327. # Custom attribute writer method with validation
  328. # @param [Object] to Value to be assigned
  329. 1 def to=(to)
  330. 15 if to.nil?
  331. 1 fail ArgumentError, 'to cannot be nil'
  332. end
  333. 14 @to = to
  334. end
  335. # Custom attribute writer method with validation
  336. # @param [Object] from Value to be assigned
  337. 1 def from=(from)
  338. 14 if from.nil?
  339. 1 fail ArgumentError, 'from cannot be nil'
  340. end
  341. 13 @from = from
  342. end
  343. # Custom attribute writer method with validation
  344. # @param [Object] call_url Value to be assigned
  345. 1 def call_url=(call_url)
  346. 13 if call_url.nil?
  347. 1 fail ArgumentError, 'call_url cannot be nil'
  348. end
  349. 12 @call_url = call_url
  350. end
  351. # Custom attribute writer method with validation
  352. # @param [Object] answer_url Value to be assigned
  353. 1 def answer_url=(answer_url)
  354. 12 if answer_url.nil?
  355. 1 fail ArgumentError, 'answer_url cannot be nil'
  356. end
  357. 11 @answer_url = answer_url
  358. end
  359. # Custom attribute writer method with validation
  360. # @param [Object] username Value to be assigned
  361. 1 def username=(username)
  362. 6 if !username.nil? && username.to_s.length > 1024
  363. 1 fail ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 1024.'
  364. end
  365. 5 @username = username
  366. end
  367. # Custom attribute writer method with validation
  368. # @param [Object] password Value to be assigned
  369. 1 def password=(password)
  370. 6 if !password.nil? && password.to_s.length > 1024
  371. 1 fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 1024.'
  372. end
  373. 5 @password = password
  374. end
  375. # Custom attribute writer method with validation
  376. # @param [Object] fallback_username Value to be assigned
  377. 1 def fallback_username=(fallback_username)
  378. 6 if !fallback_username.nil? && fallback_username.to_s.length > 1024
  379. 1 fail ArgumentError, 'invalid value for "fallback_username", the character length must be smaller than or equal to 1024.'
  380. end
  381. 5 @fallback_username = fallback_username
  382. end
  383. # Custom attribute writer method with validation
  384. # @param [Object] fallback_password Value to be assigned
  385. 1 def fallback_password=(fallback_password)
  386. 6 if !fallback_password.nil? && fallback_password.to_s.length > 1024
  387. 1 fail ArgumentError, 'invalid value for "fallback_password", the character length must be smaller than or equal to 1024.'
  388. end
  389. 5 @fallback_password = fallback_password
  390. end
  391. # Checks equality by comparing each attribute.
  392. # @param [Object] Object to be compared
  393. 1 def ==(o)
  394. 2 return true if self.equal?(o)
  395. 2 self.class == o.class &&
  396. application_id == o.application_id &&
  397. account_id == o.account_id &&
  398. call_id == o.call_id &&
  399. to == o.to &&
  400. from == o.from &&
  401. enqueued_time == o.enqueued_time &&
  402. call_url == o.call_url &&
  403. call_timeout == o.call_timeout &&
  404. callback_timeout == o.callback_timeout &&
  405. tag == o.tag &&
  406. answer_method == o.answer_method &&
  407. answer_url == o.answer_url &&
  408. answer_fallback_method == o.answer_fallback_method &&
  409. answer_fallback_url == o.answer_fallback_url &&
  410. disconnect_method == o.disconnect_method &&
  411. disconnect_url == o.disconnect_url &&
  412. username == o.username &&
  413. password == o.password &&
  414. fallback_username == o.fallback_username &&
  415. fallback_password == o.fallback_password &&
  416. priority == o.priority
  417. end
  418. # @see the `==` method
  419. # @param [Object] Object to be compared
  420. 1 def eql?(o)
  421. 2 self == o
  422. end
  423. # Calculates hash code according to all attributes.
  424. # @return [Integer] Hash code
  425. 1 def hash
  426. [application_id, account_id, call_id, to, from, enqueued_time, call_url, call_timeout, callback_timeout, tag, answer_method, answer_url, answer_fallback_method, answer_fallback_url, disconnect_method, disconnect_url, username, password, fallback_username, fallback_password, priority].hash
  427. end
  428. # Builds the object from hash
  429. # @param [Hash] attributes Model attributes in the form of hash
  430. # @return [Object] Returns the model itself
  431. 1 def self.build_from_hash(attributes)
  432. 2 return nil unless attributes.is_a?(Hash)
  433. 2 attributes = attributes.transform_keys(&:to_sym)
  434. 2 transformed_hash = {}
  435. 2 openapi_types.each_pair do |key, type|
  436. 42 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  437. transformed_hash["#{key}"] = nil
  438. 42 elsif type =~ /\AArray<(.*)>/i
  439. # check to ensure the input is an array given that the attribute
  440. # is documented as an array but the input is not
  441. if attributes[attribute_map[key]].is_a?(Array)
  442. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  443. end
  444. 42 elsif !attributes[attribute_map[key]].nil?
  445. 42 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  446. end
  447. end
  448. 2 new(transformed_hash)
  449. end
  450. # Returns the object in the form of hash
  451. # @return [Hash] Returns the object in the form of hash
  452. 1 def to_hash
  453. 2 hash = {}
  454. 2 self.class.attribute_map.each_pair do |attr, param|
  455. 42 value = self.send(attr)
  456. 42 if value.nil?
  457. is_nullable = self.class.openapi_nullable.include?(attr)
  458. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  459. end
  460. 42 hash[param] = _to_hash(value)
  461. end
  462. 2 hash
  463. end
  464. end
  465. end

lib/bandwidth-sdk/models/create_endpoint_request_base.rb

75.96% lines covered

104 relevant lines. 79 lines covered and 25 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CreateEndpointRequestBase < ApiModelBase
  13. 1 attr_accessor :type
  14. 1 attr_accessor :direction
  15. # The URL to send event callbacks to.
  16. 1 attr_accessor :event_callback_url
  17. # The URL to send event fallbacks to.
  18. 1 attr_accessor :event_fallback_url
  19. # A tag for the endpoint.
  20. 1 attr_accessor :tag
  21. 1 class EnumAttributeValidator
  22. 1 attr_reader :datatype
  23. 1 attr_reader :allowable_values
  24. 1 def initialize(datatype, allowable_values)
  25. @allowable_values = allowable_values.map do |value|
  26. case datatype.to_s
  27. when /Integer/i
  28. value.to_i
  29. when /Float/i
  30. value.to_f
  31. else
  32. value
  33. end
  34. end
  35. end
  36. 1 def valid?(value)
  37. !value || allowable_values.include?(value)
  38. end
  39. end
  40. # Attribute mapping from ruby-style variable name to JSON key.
  41. 1 def self.attribute_map
  42. 34 {
  43. :'type' => :'type',
  44. :'direction' => :'direction',
  45. :'event_callback_url' => :'eventCallbackUrl',
  46. :'event_fallback_url' => :'eventFallbackUrl',
  47. :'tag' => :'tag'
  48. }
  49. end
  50. # Returns attribute mapping this model knows about
  51. 1 def self.acceptable_attribute_map
  52. 11 attribute_map
  53. end
  54. # Returns all the JSON keys this model knows about
  55. 1 def self.acceptable_attributes
  56. 1 acceptable_attribute_map.values
  57. end
  58. # Attribute type mapping.
  59. 1 def self.openapi_types
  60. 1 {
  61. :'type' => :'EndpointTypeEnum',
  62. :'direction' => :'EndpointDirectionEnum',
  63. :'event_callback_url' => :'String',
  64. :'event_fallback_url' => :'String',
  65. :'tag' => :'String'
  66. }
  67. end
  68. # List of attributes with nullable: true
  69. 1 def self.openapi_nullable
  70. 1 Set.new([
  71. ])
  72. end
  73. # Initializes the object
  74. # @param [Hash] attributes Model attributes in the form of hash
  75. 1 def initialize(attributes = {})
  76. 11 if (!attributes.is_a?(Hash))
  77. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CreateEndpointRequestBase` initialize method'
  78. end
  79. # check to see if the attribute exists and convert string to symbol for hash key
  80. 10 acceptable_attribute_map = self.class.acceptable_attribute_map
  81. 10 attributes = attributes.each_with_object({}) { |(k, v), h|
  82. 32 if (!acceptable_attribute_map.key?(k.to_sym))
  83. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CreateEndpointRequestBase`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  84. end
  85. 31 h[k.to_sym] = v
  86. }
  87. 9 if attributes.key?(:'type')
  88. 9 self.type = attributes[:'type']
  89. else
  90. self.type = nil
  91. end
  92. 8 if attributes.key?(:'direction')
  93. 8 self.direction = attributes[:'direction']
  94. else
  95. self.direction = nil
  96. end
  97. 7 if attributes.key?(:'event_callback_url')
  98. 4 self.event_callback_url = attributes[:'event_callback_url']
  99. end
  100. 7 if attributes.key?(:'event_fallback_url')
  101. 4 self.event_fallback_url = attributes[:'event_fallback_url']
  102. end
  103. 7 if attributes.key?(:'tag')
  104. 5 self.tag = attributes[:'tag']
  105. end
  106. end
  107. # Show invalid properties with the reasons. Usually used together with valid?
  108. # @return Array for valid properties with the reasons
  109. 1 def list_invalid_properties
  110. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  111. invalid_properties = Array.new
  112. if @type.nil?
  113. invalid_properties.push('invalid value for "type", type cannot be nil.')
  114. end
  115. if @direction.nil?
  116. invalid_properties.push('invalid value for "direction", direction cannot be nil.')
  117. end
  118. invalid_properties
  119. end
  120. # Check to see if the all the properties in the model are valid
  121. # @return true if the model is valid
  122. 1 def valid?
  123. warn '[DEPRECATED] the `valid?` method is obsolete'
  124. return false if @type.nil?
  125. return false if @direction.nil?
  126. true
  127. end
  128. # Custom attribute writer method with validation
  129. # @param [Object] type Value to be assigned
  130. 1 def type=(type)
  131. 9 if type.nil?
  132. 1 fail ArgumentError, 'type cannot be nil'
  133. end
  134. 8 @type = type
  135. end
  136. # Custom attribute writer method with validation
  137. # @param [Object] direction Value to be assigned
  138. 1 def direction=(direction)
  139. 8 if direction.nil?
  140. 1 fail ArgumentError, 'direction cannot be nil'
  141. end
  142. 7 @direction = direction
  143. end
  144. # Custom attribute writer method with validation
  145. # @param [Object] tag Value to be assigned
  146. 1 def tag=(tag)
  147. 5 if tag.nil?
  148. 1 fail ArgumentError, 'tag cannot be nil'
  149. end
  150. 4 @tag = tag
  151. end
  152. # Checks equality by comparing each attribute.
  153. # @param [Object] Object to be compared
  154. 1 def ==(o)
  155. 2 return true if self.equal?(o)
  156. 2 self.class == o.class &&
  157. type == o.type &&
  158. direction == o.direction &&
  159. event_callback_url == o.event_callback_url &&
  160. event_fallback_url == o.event_fallback_url &&
  161. tag == o.tag
  162. end
  163. # @see the `==` method
  164. # @param [Object] Object to be compared
  165. 1 def eql?(o)
  166. 2 self == o
  167. end
  168. # Calculates hash code according to all attributes.
  169. # @return [Integer] Hash code
  170. 1 def hash
  171. [type, direction, event_callback_url, event_fallback_url, tag].hash
  172. end
  173. # Builds the object from hash
  174. # @param [Hash] attributes Model attributes in the form of hash
  175. # @return [Object] Returns the model itself
  176. 1 def self.build_from_hash(attributes)
  177. 1 return nil unless attributes.is_a?(Hash)
  178. 1 attributes = attributes.transform_keys(&:to_sym)
  179. 1 transformed_hash = {}
  180. 1 openapi_types.each_pair do |key, type|
  181. 5 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  182. transformed_hash["#{key}"] = nil
  183. 5 elsif type =~ /\AArray<(.*)>/i
  184. # check to ensure the input is an array given that the attribute
  185. # is documented as an array but the input is not
  186. if attributes[attribute_map[key]].is_a?(Array)
  187. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  188. end
  189. 5 elsif !attributes[attribute_map[key]].nil?
  190. 5 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  191. end
  192. end
  193. 1 new(transformed_hash)
  194. end
  195. # Returns the object in the form of hash
  196. # @return [Hash] Returns the object in the form of hash
  197. 1 def to_hash
  198. 2 hash = {}
  199. 2 self.class.attribute_map.each_pair do |attr, param|
  200. 10 value = self.send(attr)
  201. 10 if value.nil?
  202. is_nullable = self.class.openapi_nullable.include?(attr)
  203. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  204. end
  205. 10 hash[param] = _to_hash(value)
  206. end
  207. 2 hash
  208. end
  209. end
  210. end

lib/bandwidth-sdk/models/create_endpoint_response.rb

77.42% lines covered

93 relevant lines. 72 lines covered and 21 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CreateEndpointResponse < ApiModelBase
  13. 1 attr_accessor :links
  14. 1 attr_accessor :data
  15. 1 attr_accessor :errors
  16. # Attribute mapping from ruby-style variable name to JSON key.
  17. 1 def self.attribute_map
  18. 39 {
  19. :'links' => :'links',
  20. :'data' => :'data',
  21. :'errors' => :'errors'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 12 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 1 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 2 {
  35. :'links' => :'Array<BrtcLink>',
  36. :'data' => :'CreateEndpointResponseData',
  37. :'errors' => :'Array<BrtcError>'
  38. }
  39. end
  40. # List of attributes with nullable: true
  41. 1 def self.openapi_nullable
  42. 1 Set.new([
  43. ])
  44. end
  45. # Initializes the object
  46. # @param [Hash] attributes Model attributes in the form of hash
  47. 1 def initialize(attributes = {})
  48. 12 if (!attributes.is_a?(Hash))
  49. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CreateEndpointResponse` initialize method'
  50. end
  51. # check to see if the attribute exists and convert string to symbol for hash key
  52. 11 acceptable_attribute_map = self.class.acceptable_attribute_map
  53. 11 attributes = attributes.each_with_object({}) { |(k, v), h|
  54. 31 if (!acceptable_attribute_map.key?(k.to_sym))
  55. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CreateEndpointResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  56. end
  57. 30 h[k.to_sym] = v
  58. }
  59. 10 if attributes.key?(:'links')
  60. 10 if (value = attributes[:'links']).is_a?(Array)
  61. 10 self.links = value
  62. end
  63. else
  64. self.links = nil
  65. end
  66. 10 if attributes.key?(:'data')
  67. 10 self.data = attributes[:'data']
  68. else
  69. self.data = nil
  70. end
  71. 10 if attributes.key?(:'errors')
  72. 10 if (value = attributes[:'errors']).is_a?(Array)
  73. 10 self.errors = value
  74. end
  75. else
  76. self.errors = nil
  77. end
  78. end
  79. # Show invalid properties with the reasons. Usually used together with valid?
  80. # @return Array for valid properties with the reasons
  81. 1 def list_invalid_properties
  82. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  83. invalid_properties = Array.new
  84. if @links.nil?
  85. invalid_properties.push('invalid value for "links", links cannot be nil.')
  86. end
  87. if @data.nil?
  88. invalid_properties.push('invalid value for "data", data cannot be nil.')
  89. end
  90. if @errors.nil?
  91. invalid_properties.push('invalid value for "errors", errors cannot be nil.')
  92. end
  93. invalid_properties
  94. end
  95. # Check to see if the all the properties in the model are valid
  96. # @return true if the model is valid
  97. 1 def valid?
  98. warn '[DEPRECATED] the `valid?` method is obsolete'
  99. return false if @links.nil?
  100. return false if @data.nil?
  101. return false if @errors.nil?
  102. true
  103. end
  104. # Custom attribute writer method with validation
  105. # @param [Object] links Value to be assigned
  106. 1 def links=(links)
  107. 11 if links.nil?
  108. 1 fail ArgumentError, 'links cannot be nil'
  109. end
  110. 10 @links = links
  111. end
  112. # Custom attribute writer method with validation
  113. # @param [Object] data Value to be assigned
  114. 1 def data=(data)
  115. 11 if data.nil?
  116. 1 fail ArgumentError, 'data cannot be nil'
  117. end
  118. 10 @data = data
  119. end
  120. # Custom attribute writer method with validation
  121. # @param [Object] errors Value to be assigned
  122. 1 def errors=(errors)
  123. 11 if errors.nil?
  124. 1 fail ArgumentError, 'errors cannot be nil'
  125. end
  126. 10 @errors = errors
  127. end
  128. # Checks equality by comparing each attribute.
  129. # @param [Object] Object to be compared
  130. 1 def ==(o)
  131. 2 return true if self.equal?(o)
  132. 2 self.class == o.class &&
  133. links == o.links &&
  134. data == o.data &&
  135. errors == o.errors
  136. end
  137. # @see the `==` method
  138. # @param [Object] Object to be compared
  139. 1 def eql?(o)
  140. 2 self == o
  141. end
  142. # Calculates hash code according to all attributes.
  143. # @return [Integer] Hash code
  144. 1 def hash
  145. [links, data, errors].hash
  146. end
  147. # Builds the object from hash
  148. # @param [Hash] attributes Model attributes in the form of hash
  149. # @return [Object] Returns the model itself
  150. 1 def self.build_from_hash(attributes)
  151. 2 return nil unless attributes.is_a?(Hash)
  152. 2 attributes = attributes.transform_keys(&:to_sym)
  153. 2 transformed_hash = {}
  154. 2 openapi_types.each_pair do |key, type|
  155. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  156. transformed_hash["#{key}"] = nil
  157. 6 elsif type =~ /\AArray<(.*)>/i
  158. # check to ensure the input is an array given that the attribute
  159. # is documented as an array but the input is not
  160. 4 if attributes[attribute_map[key]].is_a?(Array)
  161. 7 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  162. end
  163. 2 elsif !attributes[attribute_map[key]].nil?
  164. 2 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  165. end
  166. end
  167. 2 new(transformed_hash)
  168. end
  169. # Returns the object in the form of hash
  170. # @return [Hash] Returns the object in the form of hash
  171. 1 def to_hash
  172. 2 hash = {}
  173. 2 self.class.attribute_map.each_pair do |attr, param|
  174. 6 value = self.send(attr)
  175. 6 if value.nil?
  176. is_nullable = self.class.openapi_nullable.include?(attr)
  177. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  178. end
  179. 6 hash[param] = _to_hash(value)
  180. end
  181. 2 hash
  182. end
  183. end
  184. end

lib/bandwidth-sdk/models/create_endpoint_response_data.rb

74.32% lines covered

148 relevant lines. 110 lines covered and 38 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CreateEndpointResponseData < ApiModelBase
  13. # The unique ID of the endpoint.
  14. 1 attr_accessor :endpoint_id
  15. 1 attr_accessor :type
  16. 1 attr_accessor :status
  17. # The time the endpoint was created. In ISO-8601 format.
  18. 1 attr_accessor :creation_timestamp
  19. # The time the endpoint token will expire. In ISO-8601 format. Tokens last 24 hours.
  20. 1 attr_accessor :expiration_timestamp
  21. # A tag for the endpoint.
  22. 1 attr_accessor :tag
  23. 1 attr_accessor :devices
  24. # The json web token specific to the endpoint. Used to authenticate the client with the media gateway.
  25. 1 attr_accessor :token
  26. 1 class EnumAttributeValidator
  27. 1 attr_reader :datatype
  28. 1 attr_reader :allowable_values
  29. 1 def initialize(datatype, allowable_values)
  30. @allowable_values = allowable_values.map do |value|
  31. case datatype.to_s
  32. when /Integer/i
  33. value.to_i
  34. when /Float/i
  35. value.to_f
  36. else
  37. value
  38. end
  39. end
  40. end
  41. 1 def valid?(value)
  42. !value || allowable_values.include?(value)
  43. end
  44. end
  45. # Attribute mapping from ruby-style variable name to JSON key.
  46. 1 def self.attribute_map
  47. 120 {
  48. :'endpoint_id' => :'endpointId',
  49. :'type' => :'type',
  50. :'status' => :'status',
  51. :'creation_timestamp' => :'creationTimestamp',
  52. :'expiration_timestamp' => :'expirationTimestamp',
  53. :'tag' => :'tag',
  54. :'devices' => :'devices',
  55. :'token' => :'token'
  56. }
  57. end
  58. # Returns attribute mapping this model knows about
  59. 1 def self.acceptable_attribute_map
  60. 23 attribute_map
  61. end
  62. # Returns all the JSON keys this model knows about
  63. 1 def self.acceptable_attributes
  64. 1 acceptable_attribute_map.values
  65. end
  66. # Attribute type mapping.
  67. 1 def self.openapi_types
  68. 3 {
  69. :'endpoint_id' => :'String',
  70. :'type' => :'EndpointTypeEnum',
  71. :'status' => :'EndpointStatusEnum',
  72. :'creation_timestamp' => :'Time',
  73. :'expiration_timestamp' => :'Time',
  74. :'tag' => :'String',
  75. :'devices' => :'Array<Device>',
  76. :'token' => :'String'
  77. }
  78. end
  79. # List of attributes with nullable: true
  80. 1 def self.openapi_nullable
  81. 5 Set.new([
  82. ])
  83. end
  84. # List of class defined in allOf (OpenAPI v3)
  85. 1 def self.openapi_all_of
  86. [
  87. :'Endpoint'
  88. ]
  89. end
  90. # Initializes the object
  91. # @param [Hash] attributes Model attributes in the form of hash
  92. 1 def initialize(attributes = {})
  93. 23 if (!attributes.is_a?(Hash))
  94. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CreateEndpointResponseData` initialize method'
  95. end
  96. # check to see if the attribute exists and convert string to symbol for hash key
  97. 22 acceptable_attribute_map = self.class.acceptable_attribute_map
  98. 22 attributes = attributes.each_with_object({}) { |(k, v), h|
  99. 138 if (!acceptable_attribute_map.key?(k.to_sym))
  100. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CreateEndpointResponseData`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  101. end
  102. 137 h[k.to_sym] = v
  103. }
  104. 21 if attributes.key?(:'endpoint_id')
  105. 21 self.endpoint_id = attributes[:'endpoint_id']
  106. else
  107. self.endpoint_id = nil
  108. end
  109. 20 if attributes.key?(:'type')
  110. 20 self.type = attributes[:'type']
  111. else
  112. self.type = nil
  113. end
  114. 19 if attributes.key?(:'status')
  115. 19 self.status = attributes[:'status']
  116. else
  117. self.status = nil
  118. end
  119. 18 if attributes.key?(:'creation_timestamp')
  120. 18 self.creation_timestamp = attributes[:'creation_timestamp']
  121. else
  122. self.creation_timestamp = nil
  123. end
  124. 17 if attributes.key?(:'expiration_timestamp')
  125. 17 self.expiration_timestamp = attributes[:'expiration_timestamp']
  126. else
  127. self.expiration_timestamp = nil
  128. end
  129. 16 if attributes.key?(:'tag')
  130. 6 self.tag = attributes[:'tag']
  131. end
  132. 15 if attributes.key?(:'devices')
  133. 5 if (value = attributes[:'devices']).is_a?(Array)
  134. 5 self.devices = value
  135. end
  136. end
  137. 15 if attributes.key?(:'token')
  138. 15 self.token = attributes[:'token']
  139. else
  140. self.token = nil
  141. end
  142. end
  143. # Show invalid properties with the reasons. Usually used together with valid?
  144. # @return Array for valid properties with the reasons
  145. 1 def list_invalid_properties
  146. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  147. invalid_properties = Array.new
  148. if @endpoint_id.nil?
  149. invalid_properties.push('invalid value for "endpoint_id", endpoint_id cannot be nil.')
  150. end
  151. if @type.nil?
  152. invalid_properties.push('invalid value for "type", type cannot be nil.')
  153. end
  154. if @status.nil?
  155. invalid_properties.push('invalid value for "status", status cannot be nil.')
  156. end
  157. if @creation_timestamp.nil?
  158. invalid_properties.push('invalid value for "creation_timestamp", creation_timestamp cannot be nil.')
  159. end
  160. if @expiration_timestamp.nil?
  161. invalid_properties.push('invalid value for "expiration_timestamp", expiration_timestamp cannot be nil.')
  162. end
  163. if @token.nil?
  164. invalid_properties.push('invalid value for "token", token cannot be nil.')
  165. end
  166. invalid_properties
  167. end
  168. # Check to see if the all the properties in the model are valid
  169. # @return true if the model is valid
  170. 1 def valid?
  171. warn '[DEPRECATED] the `valid?` method is obsolete'
  172. return false if @endpoint_id.nil?
  173. return false if @type.nil?
  174. return false if @status.nil?
  175. return false if @creation_timestamp.nil?
  176. return false if @expiration_timestamp.nil?
  177. return false if @token.nil?
  178. true
  179. end
  180. # Custom attribute writer method with validation
  181. # @param [Object] endpoint_id Value to be assigned
  182. 1 def endpoint_id=(endpoint_id)
  183. 21 if endpoint_id.nil?
  184. 1 fail ArgumentError, 'endpoint_id cannot be nil'
  185. end
  186. 20 @endpoint_id = endpoint_id
  187. end
  188. # Custom attribute writer method with validation
  189. # @param [Object] type Value to be assigned
  190. 1 def type=(type)
  191. 20 if type.nil?
  192. 1 fail ArgumentError, 'type cannot be nil'
  193. end
  194. 19 @type = type
  195. end
  196. # Custom attribute writer method with validation
  197. # @param [Object] status Value to be assigned
  198. 1 def status=(status)
  199. 19 if status.nil?
  200. 1 fail ArgumentError, 'status cannot be nil'
  201. end
  202. 18 @status = status
  203. end
  204. # Custom attribute writer method with validation
  205. # @param [Object] creation_timestamp Value to be assigned
  206. 1 def creation_timestamp=(creation_timestamp)
  207. 18 if creation_timestamp.nil?
  208. 1 fail ArgumentError, 'creation_timestamp cannot be nil'
  209. end
  210. 17 @creation_timestamp = creation_timestamp
  211. end
  212. # Custom attribute writer method with validation
  213. # @param [Object] expiration_timestamp Value to be assigned
  214. 1 def expiration_timestamp=(expiration_timestamp)
  215. 17 if expiration_timestamp.nil?
  216. 1 fail ArgumentError, 'expiration_timestamp cannot be nil'
  217. end
  218. 16 @expiration_timestamp = expiration_timestamp
  219. end
  220. # Custom attribute writer method with validation
  221. # @param [Object] tag Value to be assigned
  222. 1 def tag=(tag)
  223. 6 if tag.nil?
  224. 1 fail ArgumentError, 'tag cannot be nil'
  225. end
  226. 5 @tag = tag
  227. end
  228. # Custom attribute writer method with validation
  229. # @param [Object] token Value to be assigned
  230. 1 def token=(token)
  231. 15 if token.nil?
  232. 1 fail ArgumentError, 'token cannot be nil'
  233. end
  234. 14 @token = token
  235. end
  236. # Checks equality by comparing each attribute.
  237. # @param [Object] Object to be compared
  238. 1 def ==(o)
  239. 2 return true if self.equal?(o)
  240. 2 self.class == o.class &&
  241. endpoint_id == o.endpoint_id &&
  242. type == o.type &&
  243. status == o.status &&
  244. creation_timestamp == o.creation_timestamp &&
  245. expiration_timestamp == o.expiration_timestamp &&
  246. tag == o.tag &&
  247. devices == o.devices &&
  248. token == o.token
  249. end
  250. # @see the `==` method
  251. # @param [Object] Object to be compared
  252. 1 def eql?(o)
  253. 2 self == o
  254. end
  255. # Calculates hash code according to all attributes.
  256. # @return [Integer] Hash code
  257. 1 def hash
  258. [endpoint_id, type, status, creation_timestamp, expiration_timestamp, tag, devices, token].hash
  259. end
  260. # Builds the object from hash
  261. # @param [Hash] attributes Model attributes in the form of hash
  262. # @return [Object] Returns the model itself
  263. 1 def self.build_from_hash(attributes)
  264. 3 return nil unless attributes.is_a?(Hash)
  265. 3 attributes = attributes.transform_keys(&:to_sym)
  266. 3 transformed_hash = {}
  267. 3 openapi_types.each_pair do |key, type|
  268. 24 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  269. transformed_hash["#{key}"] = nil
  270. 24 elsif type =~ /\AArray<(.*)>/i
  271. # check to ensure the input is an array given that the attribute
  272. # is documented as an array but the input is not
  273. 3 if attributes[attribute_map[key]].is_a?(Array)
  274. 3 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  275. end
  276. 21 elsif !attributes[attribute_map[key]].nil?
  277. 20 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  278. end
  279. end
  280. 3 new(transformed_hash)
  281. end
  282. # Returns the object in the form of hash
  283. # @return [Hash] Returns the object in the form of hash
  284. 1 def to_hash
  285. 4 hash = {}
  286. 4 self.class.attribute_map.each_pair do |attr, param|
  287. 32 value = self.send(attr)
  288. 32 if value.nil?
  289. 4 is_nullable = self.class.openapi_nullable.include?(attr)
  290. 4 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  291. end
  292. 28 hash[param] = _to_hash(value)
  293. end
  294. 4 hash
  295. end
  296. end
  297. end

lib/bandwidth-sdk/models/create_message_request_error.rb

79.76% lines covered

84 relevant lines. 67 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CreateMessageRequestError < ApiModelBase
  13. 1 attr_accessor :type
  14. 1 attr_accessor :description
  15. 1 attr_accessor :field_errors
  16. # Attribute mapping from ruby-style variable name to JSON key.
  17. 1 def self.attribute_map
  18. 25 {
  19. :'type' => :'type',
  20. :'description' => :'description',
  21. :'field_errors' => :'fieldErrors'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 10 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 1 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 1 {
  35. :'type' => :'String',
  36. :'description' => :'String',
  37. :'field_errors' => :'Array<FieldError>'
  38. }
  39. end
  40. # List of attributes with nullable: true
  41. 1 def self.openapi_nullable
  42. 1 Set.new([
  43. ])
  44. end
  45. # Initializes the object
  46. # @param [Hash] attributes Model attributes in the form of hash
  47. 1 def initialize(attributes = {})
  48. 10 if (!attributes.is_a?(Hash))
  49. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CreateMessageRequestError` initialize method'
  50. end
  51. # check to see if the attribute exists and convert string to symbol for hash key
  52. 9 acceptable_attribute_map = self.class.acceptable_attribute_map
  53. 9 attributes = attributes.each_with_object({}) { |(k, v), h|
  54. 21 if (!acceptable_attribute_map.key?(k.to_sym))
  55. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CreateMessageRequestError`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  56. end
  57. 20 h[k.to_sym] = v
  58. }
  59. 8 if attributes.key?(:'type')
  60. 8 self.type = attributes[:'type']
  61. else
  62. self.type = nil
  63. end
  64. 7 if attributes.key?(:'description')
  65. 7 self.description = attributes[:'description']
  66. else
  67. self.description = nil
  68. end
  69. 6 if attributes.key?(:'field_errors')
  70. 4 if (value = attributes[:'field_errors']).is_a?(Array)
  71. 4 self.field_errors = value
  72. end
  73. end
  74. end
  75. # Show invalid properties with the reasons. Usually used together with valid?
  76. # @return Array for valid properties with the reasons
  77. 1 def list_invalid_properties
  78. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  79. invalid_properties = Array.new
  80. if @type.nil?
  81. invalid_properties.push('invalid value for "type", type cannot be nil.')
  82. end
  83. if @description.nil?
  84. invalid_properties.push('invalid value for "description", description cannot be nil.')
  85. end
  86. invalid_properties
  87. end
  88. # Check to see if the all the properties in the model are valid
  89. # @return true if the model is valid
  90. 1 def valid?
  91. warn '[DEPRECATED] the `valid?` method is obsolete'
  92. return false if @type.nil?
  93. return false if @description.nil?
  94. true
  95. end
  96. # Custom attribute writer method with validation
  97. # @param [Object] type Value to be assigned
  98. 1 def type=(type)
  99. 8 if type.nil?
  100. 1 fail ArgumentError, 'type cannot be nil'
  101. end
  102. 7 @type = type
  103. end
  104. # Custom attribute writer method with validation
  105. # @param [Object] description Value to be assigned
  106. 1 def description=(description)
  107. 7 if description.nil?
  108. 1 fail ArgumentError, 'description cannot be nil'
  109. end
  110. 6 @description = description
  111. end
  112. # Checks equality by comparing each attribute.
  113. # @param [Object] Object to be compared
  114. 1 def ==(o)
  115. 2 return true if self.equal?(o)
  116. 2 self.class == o.class &&
  117. type == o.type &&
  118. description == o.description &&
  119. field_errors == o.field_errors
  120. end
  121. # @see the `==` method
  122. # @param [Object] Object to be compared
  123. 1 def eql?(o)
  124. 2 self == o
  125. end
  126. # Calculates hash code according to all attributes.
  127. # @return [Integer] Hash code
  128. 1 def hash
  129. [type, description, field_errors].hash
  130. end
  131. # Builds the object from hash
  132. # @param [Hash] attributes Model attributes in the form of hash
  133. # @return [Object] Returns the model itself
  134. 1 def self.build_from_hash(attributes)
  135. 1 return nil unless attributes.is_a?(Hash)
  136. 1 attributes = attributes.transform_keys(&:to_sym)
  137. 1 transformed_hash = {}
  138. 1 openapi_types.each_pair do |key, type|
  139. 3 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  140. transformed_hash["#{key}"] = nil
  141. 3 elsif type =~ /\AArray<(.*)>/i
  142. # check to ensure the input is an array given that the attribute
  143. # is documented as an array but the input is not
  144. 1 if attributes[attribute_map[key]].is_a?(Array)
  145. 2 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  146. end
  147. 2 elsif !attributes[attribute_map[key]].nil?
  148. 2 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  149. end
  150. end
  151. 1 new(transformed_hash)
  152. end
  153. # Returns the object in the form of hash
  154. # @return [Hash] Returns the object in the form of hash
  155. 1 def to_hash
  156. 2 hash = {}
  157. 2 self.class.attribute_map.each_pair do |attr, param|
  158. 6 value = self.send(attr)
  159. 6 if value.nil?
  160. is_nullable = self.class.openapi_nullable.include?(attr)
  161. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  162. end
  163. 6 hash[param] = _to_hash(value)
  164. end
  165. 2 hash
  166. end
  167. end
  168. end

lib/bandwidth-sdk/models/create_multi_channel_message_response.rb

89.86% lines covered

69 relevant lines. 62 lines covered and 7 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CreateMultiChannelMessageResponse < ApiModelBase
  13. 1 attr_accessor :links
  14. 1 attr_accessor :data
  15. 1 attr_accessor :errors
  16. # Attribute mapping from ruby-style variable name to JSON key.
  17. 1 def self.attribute_map
  18. 34 {
  19. :'links' => :'links',
  20. :'data' => :'data',
  21. :'errors' => :'errors'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 9 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 1 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 2 {
  35. :'links' => :'Array<Link>',
  36. :'data' => :'MultiChannelMessageResponseData',
  37. :'errors' => :'Array<ErrorObject>'
  38. }
  39. end
  40. # List of attributes with nullable: true
  41. 1 def self.openapi_nullable
  42. 3 Set.new([
  43. ])
  44. end
  45. # Initializes the object
  46. # @param [Hash] attributes Model attributes in the form of hash
  47. 1 def initialize(attributes = {})
  48. 9 if (!attributes.is_a?(Hash))
  49. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CreateMultiChannelMessageResponse` initialize method'
  50. end
  51. # check to see if the attribute exists and convert string to symbol for hash key
  52. 8 acceptable_attribute_map = self.class.acceptable_attribute_map
  53. 8 attributes = attributes.each_with_object({}) { |(k, v), h|
  54. 12 if (!acceptable_attribute_map.key?(k.to_sym))
  55. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CreateMultiChannelMessageResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  56. end
  57. 11 h[k.to_sym] = v
  58. }
  59. 7 if attributes.key?(:'links')
  60. 5 if (value = attributes[:'links']).is_a?(Array)
  61. 5 self.links = value
  62. end
  63. end
  64. 7 if attributes.key?(:'data')
  65. 1 self.data = attributes[:'data']
  66. end
  67. 7 if attributes.key?(:'errors')
  68. 5 if (value = attributes[:'errors']).is_a?(Array)
  69. 5 self.errors = value
  70. end
  71. end
  72. end
  73. # Show invalid properties with the reasons. Usually used together with valid?
  74. # @return Array for valid properties with the reasons
  75. 1 def list_invalid_properties
  76. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  77. invalid_properties = Array.new
  78. invalid_properties
  79. end
  80. # Check to see if the all the properties in the model are valid
  81. # @return true if the model is valid
  82. 1 def valid?
  83. warn '[DEPRECATED] the `valid?` method is obsolete'
  84. true
  85. end
  86. # Checks equality by comparing each attribute.
  87. # @param [Object] Object to be compared
  88. 1 def ==(o)
  89. 2 return true if self.equal?(o)
  90. 2 self.class == o.class &&
  91. links == o.links &&
  92. data == o.data &&
  93. errors == o.errors
  94. end
  95. # @see the `==` method
  96. # @param [Object] Object to be compared
  97. 1 def eql?(o)
  98. 2 self == o
  99. end
  100. # Calculates hash code according to all attributes.
  101. # @return [Integer] Hash code
  102. 1 def hash
  103. [links, data, errors].hash
  104. end
  105. # Builds the object from hash
  106. # @param [Hash] attributes Model attributes in the form of hash
  107. # @return [Object] Returns the model itself
  108. 1 def self.build_from_hash(attributes)
  109. 2 return nil unless attributes.is_a?(Hash)
  110. 2 attributes = attributes.transform_keys(&:to_sym)
  111. 2 transformed_hash = {}
  112. 2 openapi_types.each_pair do |key, type|
  113. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  114. transformed_hash["#{key}"] = nil
  115. 6 elsif type =~ /\AArray<(.*)>/i
  116. # check to ensure the input is an array given that the attribute
  117. # is documented as an array but the input is not
  118. 4 if attributes[attribute_map[key]].is_a?(Array)
  119. 6 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  120. end
  121. 2 elsif !attributes[attribute_map[key]].nil?
  122. 1 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  123. end
  124. end
  125. 2 new(transformed_hash)
  126. end
  127. # Returns the object in the form of hash
  128. # @return [Hash] Returns the object in the form of hash
  129. 1 def to_hash
  130. 2 hash = {}
  131. 2 self.class.attribute_map.each_pair do |attr, param|
  132. 6 value = self.send(attr)
  133. 6 if value.nil?
  134. 2 is_nullable = self.class.openapi_nullable.include?(attr)
  135. 2 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  136. end
  137. 4 hash[param] = _to_hash(value)
  138. end
  139. 2 hash
  140. end
  141. end
  142. end

lib/bandwidth-sdk/models/create_sync_lookup_response.rb

86.96% lines covered

69 relevant lines. 60 lines covered and 9 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CreateSyncLookupResponse < ApiModelBase
  13. 1 attr_accessor :links
  14. 1 attr_accessor :data
  15. 1 attr_accessor :errors
  16. # Attribute mapping from ruby-style variable name to JSON key.
  17. 1 def self.attribute_map
  18. 36 {
  19. :'links' => :'links',
  20. :'data' => :'data',
  21. :'errors' => :'errors'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 9 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 1 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 2 {
  35. :'links' => :'Array<LinkSchema>',
  36. :'data' => :'CreateSyncLookupResponseData',
  37. :'errors' => :'Array<LookupErrorSchema>'
  38. }
  39. end
  40. # List of attributes with nullable: true
  41. 1 def self.openapi_nullable
  42. 1 Set.new([
  43. ])
  44. end
  45. # Initializes the object
  46. # @param [Hash] attributes Model attributes in the form of hash
  47. 1 def initialize(attributes = {})
  48. 9 if (!attributes.is_a?(Hash))
  49. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CreateSyncLookupResponse` initialize method'
  50. end
  51. # check to see if the attribute exists and convert string to symbol for hash key
  52. 8 acceptable_attribute_map = self.class.acceptable_attribute_map
  53. 8 attributes = attributes.each_with_object({}) { |(k, v), h|
  54. 16 if (!acceptable_attribute_map.key?(k.to_sym))
  55. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CreateSyncLookupResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  56. end
  57. 15 h[k.to_sym] = v
  58. }
  59. 7 if attributes.key?(:'links')
  60. 5 if (value = attributes[:'links']).is_a?(Array)
  61. 5 self.links = value
  62. end
  63. end
  64. 7 if attributes.key?(:'data')
  65. 5 self.data = attributes[:'data']
  66. end
  67. 7 if attributes.key?(:'errors')
  68. 5 if (value = attributes[:'errors']).is_a?(Array)
  69. 5 self.errors = value
  70. end
  71. end
  72. end
  73. # Show invalid properties with the reasons. Usually used together with valid?
  74. # @return Array for valid properties with the reasons
  75. 1 def list_invalid_properties
  76. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  77. invalid_properties = Array.new
  78. invalid_properties
  79. end
  80. # Check to see if the all the properties in the model are valid
  81. # @return true if the model is valid
  82. 1 def valid?
  83. warn '[DEPRECATED] the `valid?` method is obsolete'
  84. true
  85. end
  86. # Checks equality by comparing each attribute.
  87. # @param [Object] Object to be compared
  88. 1 def ==(o)
  89. 2 return true if self.equal?(o)
  90. 2 self.class == o.class &&
  91. links == o.links &&
  92. data == o.data &&
  93. errors == o.errors
  94. end
  95. # @see the `==` method
  96. # @param [Object] Object to be compared
  97. 1 def eql?(o)
  98. 2 self == o
  99. end
  100. # Calculates hash code according to all attributes.
  101. # @return [Integer] Hash code
  102. 1 def hash
  103. [links, data, errors].hash
  104. end
  105. # Builds the object from hash
  106. # @param [Hash] attributes Model attributes in the form of hash
  107. # @return [Object] Returns the model itself
  108. 1 def self.build_from_hash(attributes)
  109. 2 return nil unless attributes.is_a?(Hash)
  110. 2 attributes = attributes.transform_keys(&:to_sym)
  111. 2 transformed_hash = {}
  112. 2 openapi_types.each_pair do |key, type|
  113. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  114. transformed_hash["#{key}"] = nil
  115. 6 elsif type =~ /\AArray<(.*)>/i
  116. # check to ensure the input is an array given that the attribute
  117. # is documented as an array but the input is not
  118. 4 if attributes[attribute_map[key]].is_a?(Array)
  119. 6 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  120. end
  121. 2 elsif !attributes[attribute_map[key]].nil?
  122. 2 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  123. end
  124. end
  125. 2 new(transformed_hash)
  126. end
  127. # Returns the object in the form of hash
  128. # @return [Hash] Returns the object in the form of hash
  129. 1 def to_hash
  130. 2 hash = {}
  131. 2 self.class.attribute_map.each_pair do |attr, param|
  132. 6 value = self.send(attr)
  133. 6 if value.nil?
  134. is_nullable = self.class.openapi_nullable.include?(attr)
  135. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  136. end
  137. 6 hash[param] = _to_hash(value)
  138. end
  139. 2 hash
  140. end
  141. end
  142. end

lib/bandwidth-sdk/models/create_sync_lookup_response_data.rb

83.54% lines covered

79 relevant lines. 66 lines covered and 13 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The phone number lookup response data
  13. 1 class CreateSyncLookupResponseData < ApiModelBase
  14. # The phone number lookup request ID from Bandwidth.
  15. 1 attr_accessor :request_id
  16. 1 attr_accessor :status
  17. # The carrier information results for the specified telephone numbers.
  18. 1 attr_accessor :results
  19. 1 class EnumAttributeValidator
  20. 1 attr_reader :datatype
  21. 1 attr_reader :allowable_values
  22. 1 def initialize(datatype, allowable_values)
  23. @allowable_values = allowable_values.map do |value|
  24. case datatype.to_s
  25. when /Integer/i
  26. value.to_i
  27. when /Float/i
  28. value.to_f
  29. else
  30. value
  31. end
  32. end
  33. end
  34. 1 def valid?(value)
  35. !value || allowable_values.include?(value)
  36. end
  37. end
  38. # Attribute mapping from ruby-style variable name to JSON key.
  39. 1 def self.attribute_map
  40. 52 {
  41. :'request_id' => :'requestId',
  42. :'status' => :'status',
  43. :'results' => :'results'
  44. }
  45. end
  46. # Returns attribute mapping this model knows about
  47. 1 def self.acceptable_attribute_map
  48. 13 attribute_map
  49. end
  50. # Returns all the JSON keys this model knows about
  51. 1 def self.acceptable_attributes
  52. 1 acceptable_attribute_map.values
  53. end
  54. # Attribute type mapping.
  55. 1 def self.openapi_types
  56. 3 {
  57. :'request_id' => :'String',
  58. :'status' => :'CompletedLookupStatusEnum',
  59. :'results' => :'Array<LookupResult>'
  60. }
  61. end
  62. # List of attributes with nullable: true
  63. 1 def self.openapi_nullable
  64. 3 Set.new([
  65. ])
  66. end
  67. # Initializes the object
  68. # @param [Hash] attributes Model attributes in the form of hash
  69. 1 def initialize(attributes = {})
  70. 13 if (!attributes.is_a?(Hash))
  71. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CreateSyncLookupResponseData` initialize method'
  72. end
  73. # check to see if the attribute exists and convert string to symbol for hash key
  74. 12 acceptable_attribute_map = self.class.acceptable_attribute_map
  75. 12 attributes = attributes.each_with_object({}) { |(k, v), h|
  76. 24 if (!acceptable_attribute_map.key?(k.to_sym))
  77. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CreateSyncLookupResponseData`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  78. end
  79. 23 h[k.to_sym] = v
  80. }
  81. 11 if attributes.key?(:'request_id')
  82. 9 self.request_id = attributes[:'request_id']
  83. end
  84. 11 if attributes.key?(:'status')
  85. 9 self.status = attributes[:'status']
  86. end
  87. 11 if attributes.key?(:'results')
  88. 5 if (value = attributes[:'results']).is_a?(Array)
  89. 5 self.results = value
  90. end
  91. end
  92. end
  93. # Show invalid properties with the reasons. Usually used together with valid?
  94. # @return Array for valid properties with the reasons
  95. 1 def list_invalid_properties
  96. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  97. invalid_properties = Array.new
  98. invalid_properties
  99. end
  100. # Check to see if the all the properties in the model are valid
  101. # @return true if the model is valid
  102. 1 def valid?
  103. warn '[DEPRECATED] the `valid?` method is obsolete'
  104. true
  105. end
  106. # Checks equality by comparing each attribute.
  107. # @param [Object] Object to be compared
  108. 1 def ==(o)
  109. 2 return true if self.equal?(o)
  110. 2 self.class == o.class &&
  111. request_id == o.request_id &&
  112. status == o.status &&
  113. results == o.results
  114. end
  115. # @see the `==` method
  116. # @param [Object] Object to be compared
  117. 1 def eql?(o)
  118. 2 self == o
  119. end
  120. # Calculates hash code according to all attributes.
  121. # @return [Integer] Hash code
  122. 1 def hash
  123. [request_id, status, results].hash
  124. end
  125. # Builds the object from hash
  126. # @param [Hash] attributes Model attributes in the form of hash
  127. # @return [Object] Returns the model itself
  128. 1 def self.build_from_hash(attributes)
  129. 3 return nil unless attributes.is_a?(Hash)
  130. 3 attributes = attributes.transform_keys(&:to_sym)
  131. 3 transformed_hash = {}
  132. 3 openapi_types.each_pair do |key, type|
  133. 9 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  134. transformed_hash["#{key}"] = nil
  135. 9 elsif type =~ /\AArray<(.*)>/i
  136. # check to ensure the input is an array given that the attribute
  137. # is documented as an array but the input is not
  138. 3 if attributes[attribute_map[key]].is_a?(Array)
  139. 7 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  140. end
  141. 6 elsif !attributes[attribute_map[key]].nil?
  142. 6 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  143. end
  144. end
  145. 3 new(transformed_hash)
  146. end
  147. # Returns the object in the form of hash
  148. # @return [Hash] Returns the object in the form of hash
  149. 1 def to_hash
  150. 4 hash = {}
  151. 4 self.class.attribute_map.each_pair do |attr, param|
  152. 12 value = self.send(attr)
  153. 12 if value.nil?
  154. 2 is_nullable = self.class.openapi_nullable.include?(attr)
  155. 2 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  156. end
  157. 10 hash[param] = _to_hash(value)
  158. end
  159. 4 hash
  160. end
  161. end
  162. end

lib/bandwidth-sdk/models/create_web_rtc_connection_request.rb

76.15% lines covered

109 relevant lines. 83 lines covered and 26 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class CreateWebRtcConnectionRequest < ApiModelBase
  13. 1 attr_accessor :type
  14. 1 attr_accessor :direction
  15. # The URL to send event callbacks to.
  16. 1 attr_accessor :event_callback_url
  17. # The URL to send event fallbacks to.
  18. 1 attr_accessor :event_fallback_url
  19. # A tag for the endpoint.
  20. 1 attr_accessor :tag
  21. 1 attr_accessor :connection_metadata
  22. 1 class EnumAttributeValidator
  23. 1 attr_reader :datatype
  24. 1 attr_reader :allowable_values
  25. 1 def initialize(datatype, allowable_values)
  26. @allowable_values = allowable_values.map do |value|
  27. case datatype.to_s
  28. when /Integer/i
  29. value.to_i
  30. when /Float/i
  31. value.to_f
  32. else
  33. value
  34. end
  35. end
  36. end
  37. 1 def valid?(value)
  38. !value || allowable_values.include?(value)
  39. end
  40. end
  41. # Attribute mapping from ruby-style variable name to JSON key.
  42. 1 def self.attribute_map
  43. 40 {
  44. :'type' => :'type',
  45. :'direction' => :'direction',
  46. :'event_callback_url' => :'eventCallbackUrl',
  47. :'event_fallback_url' => :'eventFallbackUrl',
  48. :'tag' => :'tag',
  49. :'connection_metadata' => :'connectionMetadata'
  50. }
  51. end
  52. # Returns attribute mapping this model knows about
  53. 1 def self.acceptable_attribute_map
  54. 12 attribute_map
  55. end
  56. # Returns all the JSON keys this model knows about
  57. 1 def self.acceptable_attributes
  58. 1 acceptable_attribute_map.values
  59. end
  60. # Attribute type mapping.
  61. 1 def self.openapi_types
  62. 1 {
  63. :'type' => :'EndpointTypeEnum',
  64. :'direction' => :'EndpointDirectionEnum',
  65. :'event_callback_url' => :'String',
  66. :'event_fallback_url' => :'String',
  67. :'tag' => :'String',
  68. :'connection_metadata' => :'Object'
  69. }
  70. end
  71. # List of attributes with nullable: true
  72. 1 def self.openapi_nullable
  73. 1 Set.new([
  74. ])
  75. end
  76. # List of class defined in allOf (OpenAPI v3)
  77. 1 def self.openapi_all_of
  78. [
  79. :'CreateEndpointRequestBase'
  80. ]
  81. end
  82. # Initializes the object
  83. # @param [Hash] attributes Model attributes in the form of hash
  84. 1 def initialize(attributes = {})
  85. 12 if (!attributes.is_a?(Hash))
  86. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CreateWebRtcConnectionRequest` initialize method'
  87. end
  88. # check to see if the attribute exists and convert string to symbol for hash key
  89. 11 acceptable_attribute_map = self.class.acceptable_attribute_map
  90. 11 attributes = attributes.each_with_object({}) { |(k, v), h|
  91. 42 if (!acceptable_attribute_map.key?(k.to_sym))
  92. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CreateWebRtcConnectionRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  93. end
  94. 41 h[k.to_sym] = v
  95. }
  96. 10 if attributes.key?(:'type')
  97. 10 self.type = attributes[:'type']
  98. else
  99. self.type = nil
  100. end
  101. 9 if attributes.key?(:'direction')
  102. 9 self.direction = attributes[:'direction']
  103. else
  104. self.direction = nil
  105. end
  106. 8 if attributes.key?(:'event_callback_url')
  107. 5 self.event_callback_url = attributes[:'event_callback_url']
  108. end
  109. 8 if attributes.key?(:'event_fallback_url')
  110. 5 self.event_fallback_url = attributes[:'event_fallback_url']
  111. end
  112. 8 if attributes.key?(:'tag')
  113. 6 self.tag = attributes[:'tag']
  114. end
  115. 7 if attributes.key?(:'connection_metadata')
  116. 5 self.connection_metadata = attributes[:'connection_metadata']
  117. end
  118. end
  119. # Show invalid properties with the reasons. Usually used together with valid?
  120. # @return Array for valid properties with the reasons
  121. 1 def list_invalid_properties
  122. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  123. invalid_properties = Array.new
  124. if @type.nil?
  125. invalid_properties.push('invalid value for "type", type cannot be nil.')
  126. end
  127. if @direction.nil?
  128. invalid_properties.push('invalid value for "direction", direction cannot be nil.')
  129. end
  130. invalid_properties
  131. end
  132. # Check to see if the all the properties in the model are valid
  133. # @return true if the model is valid
  134. 1 def valid?
  135. warn '[DEPRECATED] the `valid?` method is obsolete'
  136. return false if @type.nil?
  137. return false if @direction.nil?
  138. true
  139. end
  140. # Custom attribute writer method with validation
  141. # @param [Object] type Value to be assigned
  142. 1 def type=(type)
  143. 10 if type.nil?
  144. 1 fail ArgumentError, 'type cannot be nil'
  145. end
  146. 9 @type = type
  147. end
  148. # Custom attribute writer method with validation
  149. # @param [Object] direction Value to be assigned
  150. 1 def direction=(direction)
  151. 9 if direction.nil?
  152. 1 fail ArgumentError, 'direction cannot be nil'
  153. end
  154. 8 @direction = direction
  155. end
  156. # Custom attribute writer method with validation
  157. # @param [Object] tag Value to be assigned
  158. 1 def tag=(tag)
  159. 6 if tag.nil?
  160. 1 fail ArgumentError, 'tag cannot be nil'
  161. end
  162. 5 @tag = tag
  163. end
  164. # Checks equality by comparing each attribute.
  165. # @param [Object] Object to be compared
  166. 1 def ==(o)
  167. 2 return true if self.equal?(o)
  168. 2 self.class == o.class &&
  169. type == o.type &&
  170. direction == o.direction &&
  171. event_callback_url == o.event_callback_url &&
  172. event_fallback_url == o.event_fallback_url &&
  173. tag == o.tag &&
  174. connection_metadata == o.connection_metadata
  175. end
  176. # @see the `==` method
  177. # @param [Object] Object to be compared
  178. 1 def eql?(o)
  179. 2 self == o
  180. end
  181. # Calculates hash code according to all attributes.
  182. # @return [Integer] Hash code
  183. 1 def hash
  184. [type, direction, event_callback_url, event_fallback_url, tag, connection_metadata].hash
  185. end
  186. # Builds the object from hash
  187. # @param [Hash] attributes Model attributes in the form of hash
  188. # @return [Object] Returns the model itself
  189. 1 def self.build_from_hash(attributes)
  190. 1 return nil unless attributes.is_a?(Hash)
  191. 1 attributes = attributes.transform_keys(&:to_sym)
  192. 1 transformed_hash = {}
  193. 1 openapi_types.each_pair do |key, type|
  194. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  195. transformed_hash["#{key}"] = nil
  196. 6 elsif type =~ /\AArray<(.*)>/i
  197. # check to ensure the input is an array given that the attribute
  198. # is documented as an array but the input is not
  199. if attributes[attribute_map[key]].is_a?(Array)
  200. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  201. end
  202. 6 elsif !attributes[attribute_map[key]].nil?
  203. 6 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  204. end
  205. end
  206. 1 new(transformed_hash)
  207. end
  208. # Returns the object in the form of hash
  209. # @return [Hash] Returns the object in the form of hash
  210. 1 def to_hash
  211. 3 hash = {}
  212. 3 self.class.attribute_map.each_pair do |attr, param|
  213. 18 value = self.send(attr)
  214. 18 if value.nil?
  215. is_nullable = self.class.openapi_nullable.include?(attr)
  216. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  217. end
  218. 18 hash[param] = _to_hash(value)
  219. end
  220. 3 hash
  221. end
  222. end
  223. end

lib/bandwidth-sdk/models/deactivation_event_enum.rb

100.0% lines covered

12 relevant lines. 12 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class DeactivationEventEnum
  13. 1 DEACTIVATED = 'DEACTIVATED'.freeze
  14. 1 def self.all_vars
  15. 8 @all_vars ||= [DEACTIVATED].freeze
  16. end
  17. # Builds the enum from string
  18. # @param [String] The enum value in the form of the string
  19. # @return [String] The enum value
  20. 1 def self.build_from_hash(value)
  21. 7 new.build_from_hash(value)
  22. end
  23. # Builds the enum from string
  24. # @param [String] The enum value in the form of the string
  25. # @return [String] The enum value
  26. 1 def build_from_hash(value)
  27. 7 return value if DeactivationEventEnum.all_vars.include?(value)
  28. 1 raise "Invalid ENUM value #{value} for class #DeactivationEventEnum"
  29. end
  30. end
  31. end

lib/bandwidth-sdk/models/device.rb

75.23% lines covered

109 relevant lines. 82 lines covered and 27 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class Device < ApiModelBase
  13. # The unique ID of the device.
  14. 1 attr_accessor :device_id
  15. # The name of the device.
  16. 1 attr_accessor :device_name
  17. 1 attr_accessor :status
  18. # The time the device was created. In ISO-8601 format.
  19. 1 attr_accessor :creation_timestamp
  20. 1 class EnumAttributeValidator
  21. 1 attr_reader :datatype
  22. 1 attr_reader :allowable_values
  23. 1 def initialize(datatype, allowable_values)
  24. @allowable_values = allowable_values.map do |value|
  25. case datatype.to_s
  26. when /Integer/i
  27. value.to_i
  28. when /Float/i
  29. value.to_f
  30. else
  31. value
  32. end
  33. end
  34. end
  35. 1 def valid?(value)
  36. !value || allowable_values.include?(value)
  37. end
  38. end
  39. # Attribute mapping from ruby-style variable name to JSON key.
  40. 1 def self.attribute_map
  41. 88 {
  42. :'device_id' => :'deviceId',
  43. :'device_name' => :'deviceName',
  44. :'status' => :'status',
  45. :'creation_timestamp' => :'creationTimestamp'
  46. }
  47. end
  48. # Returns attribute mapping this model knows about
  49. 1 def self.acceptable_attribute_map
  50. 21 attribute_map
  51. end
  52. # Returns all the JSON keys this model knows about
  53. 1 def self.acceptable_attributes
  54. 1 acceptable_attribute_map.values
  55. end
  56. # Attribute type mapping.
  57. 1 def self.openapi_types
  58. 4 {
  59. :'device_id' => :'String',
  60. :'device_name' => :'String',
  61. :'status' => :'DeviceStatusEnum',
  62. :'creation_timestamp' => :'Time'
  63. }
  64. end
  65. # List of attributes with nullable: true
  66. 1 def self.openapi_nullable
  67. 5 Set.new([
  68. ])
  69. end
  70. # Initializes the object
  71. # @param [Hash] attributes Model attributes in the form of hash
  72. 1 def initialize(attributes = {})
  73. 21 if (!attributes.is_a?(Hash))
  74. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::Device` initialize method'
  75. end
  76. # check to see if the attribute exists and convert string to symbol for hash key
  77. 20 acceptable_attribute_map = self.class.acceptable_attribute_map
  78. 20 attributes = attributes.each_with_object({}) { |(k, v), h|
  79. 64 if (!acceptable_attribute_map.key?(k.to_sym))
  80. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::Device`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  81. end
  82. 63 h[k.to_sym] = v
  83. }
  84. 19 if attributes.key?(:'device_id')
  85. 19 self.device_id = attributes[:'device_id']
  86. else
  87. self.device_id = nil
  88. end
  89. 18 if attributes.key?(:'device_name')
  90. 6 self.device_name = attributes[:'device_name']
  91. end
  92. 17 if attributes.key?(:'status')
  93. 17 self.status = attributes[:'status']
  94. else
  95. self.status = nil
  96. end
  97. 16 if attributes.key?(:'creation_timestamp')
  98. 16 self.creation_timestamp = attributes[:'creation_timestamp']
  99. else
  100. self.creation_timestamp = nil
  101. end
  102. end
  103. # Show invalid properties with the reasons. Usually used together with valid?
  104. # @return Array for valid properties with the reasons
  105. 1 def list_invalid_properties
  106. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  107. invalid_properties = Array.new
  108. if @device_id.nil?
  109. invalid_properties.push('invalid value for "device_id", device_id cannot be nil.')
  110. end
  111. if @status.nil?
  112. invalid_properties.push('invalid value for "status", status cannot be nil.')
  113. end
  114. if @creation_timestamp.nil?
  115. invalid_properties.push('invalid value for "creation_timestamp", creation_timestamp cannot be nil.')
  116. end
  117. invalid_properties
  118. end
  119. # Check to see if the all the properties in the model are valid
  120. # @return true if the model is valid
  121. 1 def valid?
  122. warn '[DEPRECATED] the `valid?` method is obsolete'
  123. return false if @device_id.nil?
  124. return false if @status.nil?
  125. return false if @creation_timestamp.nil?
  126. true
  127. end
  128. # Custom attribute writer method with validation
  129. # @param [Object] device_id Value to be assigned
  130. 1 def device_id=(device_id)
  131. 19 if device_id.nil?
  132. 1 fail ArgumentError, 'device_id cannot be nil'
  133. end
  134. 18 @device_id = device_id
  135. end
  136. # Custom attribute writer method with validation
  137. # @param [Object] device_name Value to be assigned
  138. 1 def device_name=(device_name)
  139. 6 if device_name.nil?
  140. 1 fail ArgumentError, 'device_name cannot be nil'
  141. end
  142. 5 @device_name = device_name
  143. end
  144. # Custom attribute writer method with validation
  145. # @param [Object] status Value to be assigned
  146. 1 def status=(status)
  147. 17 if status.nil?
  148. 1 fail ArgumentError, 'status cannot be nil'
  149. end
  150. 16 @status = status
  151. end
  152. # Custom attribute writer method with validation
  153. # @param [Object] creation_timestamp Value to be assigned
  154. 1 def creation_timestamp=(creation_timestamp)
  155. 16 if creation_timestamp.nil?
  156. 1 fail ArgumentError, 'creation_timestamp cannot be nil'
  157. end
  158. 15 @creation_timestamp = creation_timestamp
  159. end
  160. # Checks equality by comparing each attribute.
  161. # @param [Object] Object to be compared
  162. 1 def ==(o)
  163. 2 return true if self.equal?(o)
  164. 2 self.class == o.class &&
  165. device_id == o.device_id &&
  166. device_name == o.device_name &&
  167. status == o.status &&
  168. creation_timestamp == o.creation_timestamp
  169. end
  170. # @see the `==` method
  171. # @param [Object] Object to be compared
  172. 1 def eql?(o)
  173. 2 self == o
  174. end
  175. # Calculates hash code according to all attributes.
  176. # @return [Integer] Hash code
  177. 1 def hash
  178. [device_id, device_name, status, creation_timestamp].hash
  179. end
  180. # Builds the object from hash
  181. # @param [Hash] attributes Model attributes in the form of hash
  182. # @return [Object] Returns the model itself
  183. 1 def self.build_from_hash(attributes)
  184. 4 return nil unless attributes.is_a?(Hash)
  185. 4 attributes = attributes.transform_keys(&:to_sym)
  186. 4 transformed_hash = {}
  187. 4 openapi_types.each_pair do |key, type|
  188. 16 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  189. transformed_hash["#{key}"] = nil
  190. 16 elsif type =~ /\AArray<(.*)>/i
  191. # check to ensure the input is an array given that the attribute
  192. # is documented as an array but the input is not
  193. if attributes[attribute_map[key]].is_a?(Array)
  194. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  195. end
  196. 16 elsif !attributes[attribute_map[key]].nil?
  197. 14 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  198. end
  199. end
  200. 4 new(transformed_hash)
  201. end
  202. # Returns the object in the form of hash
  203. # @return [Hash] Returns the object in the form of hash
  204. 1 def to_hash
  205. 6 hash = {}
  206. 6 self.class.attribute_map.each_pair do |attr, param|
  207. 24 value = self.send(attr)
  208. 24 if value.nil?
  209. 4 is_nullable = self.class.openapi_nullable.include?(attr)
  210. 4 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  211. end
  212. 20 hash[param] = _to_hash(value)
  213. end
  214. 6 hash
  215. end
  216. end
  217. end

lib/bandwidth-sdk/models/device_status_enum.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class DeviceStatusEnum
  13. 1 CONNECTED = 'CONNECTED'.freeze
  14. 1 DISCONNECTED = 'DISCONNECTED'.freeze
  15. 1 def self.all_vars
  16. 8 @all_vars ||= [CONNECTED, DISCONNECTED].freeze
  17. end
  18. # Builds the enum from string
  19. # @param [String] The enum value in the form of the string
  20. # @return [String] The enum value
  21. 1 def self.build_from_hash(value)
  22. 7 new.build_from_hash(value)
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def build_from_hash(value)
  28. 7 return value if DeviceStatusEnum.all_vars.include?(value)
  29. 1 raise "Invalid ENUM value #{value} for class #DeviceStatusEnum"
  30. end
  31. end
  32. end

lib/bandwidth-sdk/models/disconnect_callback.rb

85.83% lines covered

120 relevant lines. 103 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The Disconnect event is fired when a call ends, for any reason.
  13. 1 class DisconnectCallback < ApiModelBase
  14. # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect.
  15. 1 attr_accessor :event_type
  16. # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.
  17. 1 attr_accessor :event_time
  18. # The user account associated with the call.
  19. 1 attr_accessor :account_id
  20. # The id of the application associated with the call.
  21. 1 attr_accessor :application_id
  22. # The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555).
  23. 1 attr_accessor :from
  24. # The phone number that received the call, in E.164 format (e.g. +15555555555).
  25. 1 attr_accessor :to
  26. # The call id associated with the event.
  27. 1 attr_accessor :call_id
  28. 1 attr_accessor :direction
  29. # The URL of the call associated with the event.
  30. 1 attr_accessor :call_url
  31. # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format.
  32. 1 attr_accessor :enqueued_time
  33. # Time the call was started, in ISO 8601 format.
  34. 1 attr_accessor :start_time
  35. # Time the call was answered, in ISO 8601 format.
  36. 1 attr_accessor :answer_time
  37. # The time that the recording ended in ISO-8601 format
  38. 1 attr_accessor :end_time
  39. # Reason the call failed - hangup, busy, timeout, cancel, rejected, callback-error, invalid-bxml, application-error, account-limit, node-capacity-exceeded, error, or unknown.
  40. 1 attr_accessor :cause
  41. # Text explaining the reason that caused the call to fail in case of errors.
  42. 1 attr_accessor :error_message
  43. # Bandwidth's internal id that references the error event.
  44. 1 attr_accessor :error_id
  45. # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.
  46. 1 attr_accessor :tag
  47. 1 class EnumAttributeValidator
  48. 1 attr_reader :datatype
  49. 1 attr_reader :allowable_values
  50. 1 def initialize(datatype, allowable_values)
  51. @allowable_values = allowable_values.map do |value|
  52. case datatype.to_s
  53. when /Integer/i
  54. value.to_i
  55. when /Float/i
  56. value.to_f
  57. else
  58. value
  59. end
  60. end
  61. end
  62. 1 def valid?(value)
  63. !value || allowable_values.include?(value)
  64. end
  65. end
  66. # Attribute mapping from ruby-style variable name to JSON key.
  67. 1 def self.attribute_map
  68. 79 {
  69. :'event_type' => :'eventType',
  70. :'event_time' => :'eventTime',
  71. :'account_id' => :'accountId',
  72. :'application_id' => :'applicationId',
  73. :'from' => :'from',
  74. :'to' => :'to',
  75. :'call_id' => :'callId',
  76. :'direction' => :'direction',
  77. :'call_url' => :'callUrl',
  78. :'enqueued_time' => :'enqueuedTime',
  79. :'start_time' => :'startTime',
  80. :'answer_time' => :'answerTime',
  81. :'end_time' => :'endTime',
  82. :'cause' => :'cause',
  83. :'error_message' => :'errorMessage',
  84. :'error_id' => :'errorId',
  85. :'tag' => :'tag'
  86. }
  87. end
  88. # Returns attribute mapping this model knows about
  89. 1 def self.acceptable_attribute_map
  90. 8 attribute_map
  91. end
  92. # Returns all the JSON keys this model knows about
  93. 1 def self.acceptable_attributes
  94. 1 acceptable_attribute_map.values
  95. end
  96. # Attribute type mapping.
  97. 1 def self.openapi_types
  98. 1 {
  99. :'event_type' => :'String',
  100. :'event_time' => :'Time',
  101. :'account_id' => :'String',
  102. :'application_id' => :'String',
  103. :'from' => :'String',
  104. :'to' => :'String',
  105. :'call_id' => :'String',
  106. :'direction' => :'CallDirectionEnum',
  107. :'call_url' => :'String',
  108. :'enqueued_time' => :'Time',
  109. :'start_time' => :'Time',
  110. :'answer_time' => :'Time',
  111. :'end_time' => :'Time',
  112. :'cause' => :'String',
  113. :'error_message' => :'String',
  114. :'error_id' => :'String',
  115. :'tag' => :'String'
  116. }
  117. end
  118. # List of attributes with nullable: true
  119. 1 def self.openapi_nullable
  120. 1 Set.new([
  121. :'enqueued_time',
  122. :'answer_time',
  123. :'error_message',
  124. :'error_id',
  125. :'tag'
  126. ])
  127. end
  128. # Initializes the object
  129. # @param [Hash] attributes Model attributes in the form of hash
  130. 1 def initialize(attributes = {})
  131. 8 if (!attributes.is_a?(Hash))
  132. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::DisconnectCallback` initialize method'
  133. end
  134. # check to see if the attribute exists and convert string to symbol for hash key
  135. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  136. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  137. 69 if (!acceptable_attribute_map.key?(k.to_sym))
  138. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::DisconnectCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  139. end
  140. 68 h[k.to_sym] = v
  141. }
  142. 6 if attributes.key?(:'event_type')
  143. 4 self.event_type = attributes[:'event_type']
  144. end
  145. 6 if attributes.key?(:'event_time')
  146. 4 self.event_time = attributes[:'event_time']
  147. end
  148. 6 if attributes.key?(:'account_id')
  149. 4 self.account_id = attributes[:'account_id']
  150. end
  151. 6 if attributes.key?(:'application_id')
  152. 4 self.application_id = attributes[:'application_id']
  153. end
  154. 6 if attributes.key?(:'from')
  155. 4 self.from = attributes[:'from']
  156. end
  157. 6 if attributes.key?(:'to')
  158. 4 self.to = attributes[:'to']
  159. end
  160. 6 if attributes.key?(:'call_id')
  161. 4 self.call_id = attributes[:'call_id']
  162. end
  163. 6 if attributes.key?(:'direction')
  164. 4 self.direction = attributes[:'direction']
  165. end
  166. 6 if attributes.key?(:'call_url')
  167. 4 self.call_url = attributes[:'call_url']
  168. end
  169. 6 if attributes.key?(:'enqueued_time')
  170. 4 self.enqueued_time = attributes[:'enqueued_time']
  171. end
  172. 6 if attributes.key?(:'start_time')
  173. 4 self.start_time = attributes[:'start_time']
  174. end
  175. 6 if attributes.key?(:'answer_time')
  176. 4 self.answer_time = attributes[:'answer_time']
  177. end
  178. 6 if attributes.key?(:'end_time')
  179. 4 self.end_time = attributes[:'end_time']
  180. end
  181. 6 if attributes.key?(:'cause')
  182. 4 self.cause = attributes[:'cause']
  183. end
  184. 6 if attributes.key?(:'error_message')
  185. 4 self.error_message = attributes[:'error_message']
  186. end
  187. 6 if attributes.key?(:'error_id')
  188. 4 self.error_id = attributes[:'error_id']
  189. end
  190. 6 if attributes.key?(:'tag')
  191. 4 self.tag = attributes[:'tag']
  192. end
  193. end
  194. # Show invalid properties with the reasons. Usually used together with valid?
  195. # @return Array for valid properties with the reasons
  196. 1 def list_invalid_properties
  197. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  198. invalid_properties = Array.new
  199. invalid_properties
  200. end
  201. # Check to see if the all the properties in the model are valid
  202. # @return true if the model is valid
  203. 1 def valid?
  204. warn '[DEPRECATED] the `valid?` method is obsolete'
  205. true
  206. end
  207. # Checks equality by comparing each attribute.
  208. # @param [Object] Object to be compared
  209. 1 def ==(o)
  210. 2 return true if self.equal?(o)
  211. 2 self.class == o.class &&
  212. event_type == o.event_type &&
  213. event_time == o.event_time &&
  214. account_id == o.account_id &&
  215. application_id == o.application_id &&
  216. from == o.from &&
  217. to == o.to &&
  218. call_id == o.call_id &&
  219. direction == o.direction &&
  220. call_url == o.call_url &&
  221. enqueued_time == o.enqueued_time &&
  222. start_time == o.start_time &&
  223. answer_time == o.answer_time &&
  224. end_time == o.end_time &&
  225. cause == o.cause &&
  226. error_message == o.error_message &&
  227. error_id == o.error_id &&
  228. tag == o.tag
  229. end
  230. # @see the `==` method
  231. # @param [Object] Object to be compared
  232. 1 def eql?(o)
  233. 2 self == o
  234. end
  235. # Calculates hash code according to all attributes.
  236. # @return [Integer] Hash code
  237. 1 def hash
  238. [event_type, event_time, account_id, application_id, from, to, call_id, direction, call_url, enqueued_time, start_time, answer_time, end_time, cause, error_message, error_id, tag].hash
  239. end
  240. # Builds the object from hash
  241. # @param [Hash] attributes Model attributes in the form of hash
  242. # @return [Object] Returns the model itself
  243. 1 def self.build_from_hash(attributes)
  244. 1 return nil unless attributes.is_a?(Hash)
  245. 1 attributes = attributes.transform_keys(&:to_sym)
  246. 1 transformed_hash = {}
  247. 1 openapi_types.each_pair do |key, type|
  248. 17 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  249. transformed_hash["#{key}"] = nil
  250. 17 elsif type =~ /\AArray<(.*)>/i
  251. # check to ensure the input is an array given that the attribute
  252. # is documented as an array but the input is not
  253. if attributes[attribute_map[key]].is_a?(Array)
  254. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  255. end
  256. 17 elsif !attributes[attribute_map[key]].nil?
  257. 17 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  258. end
  259. end
  260. 1 new(transformed_hash)
  261. end
  262. # Returns the object in the form of hash
  263. # @return [Hash] Returns the object in the form of hash
  264. 1 def to_hash
  265. 2 hash = {}
  266. 2 self.class.attribute_map.each_pair do |attr, param|
  267. 34 value = self.send(attr)
  268. 34 if value.nil?
  269. is_nullable = self.class.openapi_nullable.include?(attr)
  270. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  271. end
  272. 34 hash[param] = _to_hash(value)
  273. end
  274. 2 hash
  275. end
  276. end
  277. end

lib/bandwidth-sdk/models/diversion.rb

86.08% lines covered

79 relevant lines. 68 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class Diversion < ApiModelBase
  13. # The reason for the diversion. Common values: unknown, user-busy, no-answer, unavailable, unconditional, time-of-day, do-not-disturb, deflection, follow-me, out-of-service, away.
  14. 1 attr_accessor :reason
  15. # off or full
  16. 1 attr_accessor :privacy
  17. # No if the number was provided by the user, yes if the number was provided by the network
  18. 1 attr_accessor :screen
  19. # The number of diversions that have occurred
  20. 1 attr_accessor :counter
  21. # The maximum number of diversions allowed for this session
  22. 1 attr_accessor :limit
  23. # The normal list of values is not exhaustive. Your application must be tolerant of unlisted keys and unlisted values of those keys.
  24. 1 attr_accessor :unknown
  25. # Always present. Indicates the last telephone number that the call was diverted from.
  26. 1 attr_accessor :orig_to
  27. # Attribute mapping from ruby-style variable name to JSON key.
  28. 1 def self.attribute_map
  29. 58 {
  30. :'reason' => :'reason',
  31. :'privacy' => :'privacy',
  32. :'screen' => :'screen',
  33. :'counter' => :'counter',
  34. :'limit' => :'limit',
  35. :'unknown' => :'unknown',
  36. :'orig_to' => :'origTo'
  37. }
  38. end
  39. # Returns attribute mapping this model knows about
  40. 1 def self.acceptable_attribute_map
  41. 9 attribute_map
  42. end
  43. # Returns all the JSON keys this model knows about
  44. 1 def self.acceptable_attributes
  45. 1 acceptable_attribute_map.values
  46. end
  47. # Attribute type mapping.
  48. 1 def self.openapi_types
  49. 2 {
  50. :'reason' => :'String',
  51. :'privacy' => :'String',
  52. :'screen' => :'String',
  53. :'counter' => :'String',
  54. :'limit' => :'String',
  55. :'unknown' => :'String',
  56. :'orig_to' => :'String'
  57. }
  58. end
  59. # List of attributes with nullable: true
  60. 1 def self.openapi_nullable
  61. 1 Set.new([
  62. ])
  63. end
  64. # Initializes the object
  65. # @param [Hash] attributes Model attributes in the form of hash
  66. 1 def initialize(attributes = {})
  67. 9 if (!attributes.is_a?(Hash))
  68. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::Diversion` initialize method'
  69. end
  70. # check to see if the attribute exists and convert string to symbol for hash key
  71. 8 acceptable_attribute_map = self.class.acceptable_attribute_map
  72. 8 attributes = attributes.each_with_object({}) { |(k, v), h|
  73. 31 if (!acceptable_attribute_map.key?(k.to_sym))
  74. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::Diversion`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  75. end
  76. 30 h[k.to_sym] = v
  77. }
  78. 7 if attributes.key?(:'reason')
  79. 5 self.reason = attributes[:'reason']
  80. end
  81. 7 if attributes.key?(:'privacy')
  82. 5 self.privacy = attributes[:'privacy']
  83. end
  84. 7 if attributes.key?(:'screen')
  85. 4 self.screen = attributes[:'screen']
  86. end
  87. 7 if attributes.key?(:'counter')
  88. 4 self.counter = attributes[:'counter']
  89. end
  90. 7 if attributes.key?(:'limit')
  91. 4 self.limit = attributes[:'limit']
  92. end
  93. 7 if attributes.key?(:'unknown')
  94. 4 self.unknown = attributes[:'unknown']
  95. end
  96. 7 if attributes.key?(:'orig_to')
  97. 4 self.orig_to = attributes[:'orig_to']
  98. end
  99. end
  100. # Show invalid properties with the reasons. Usually used together with valid?
  101. # @return Array for valid properties with the reasons
  102. 1 def list_invalid_properties
  103. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  104. invalid_properties = Array.new
  105. invalid_properties
  106. end
  107. # Check to see if the all the properties in the model are valid
  108. # @return true if the model is valid
  109. 1 def valid?
  110. warn '[DEPRECATED] the `valid?` method is obsolete'
  111. true
  112. end
  113. # Checks equality by comparing each attribute.
  114. # @param [Object] Object to be compared
  115. 1 def ==(o)
  116. 2 return true if self.equal?(o)
  117. 2 self.class == o.class &&
  118. reason == o.reason &&
  119. privacy == o.privacy &&
  120. screen == o.screen &&
  121. counter == o.counter &&
  122. limit == o.limit &&
  123. unknown == o.unknown &&
  124. orig_to == o.orig_to
  125. end
  126. # @see the `==` method
  127. # @param [Object] Object to be compared
  128. 1 def eql?(o)
  129. 2 self == o
  130. end
  131. # Calculates hash code according to all attributes.
  132. # @return [Integer] Hash code
  133. 1 def hash
  134. [reason, privacy, screen, counter, limit, unknown, orig_to].hash
  135. end
  136. # Builds the object from hash
  137. # @param [Hash] attributes Model attributes in the form of hash
  138. # @return [Object] Returns the model itself
  139. 1 def self.build_from_hash(attributes)
  140. 2 return nil unless attributes.is_a?(Hash)
  141. 2 attributes = attributes.transform_keys(&:to_sym)
  142. 2 transformed_hash = {}
  143. 2 openapi_types.each_pair do |key, type|
  144. 14 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  145. transformed_hash["#{key}"] = nil
  146. 14 elsif type =~ /\AArray<(.*)>/i
  147. # check to ensure the input is an array given that the attribute
  148. # is documented as an array but the input is not
  149. if attributes[attribute_map[key]].is_a?(Array)
  150. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  151. end
  152. 14 elsif !attributes[attribute_map[key]].nil?
  153. 9 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  154. end
  155. end
  156. 2 new(transformed_hash)
  157. end
  158. # Returns the object in the form of hash
  159. # @return [Hash] Returns the object in the form of hash
  160. 1 def to_hash
  161. 2 hash = {}
  162. 2 self.class.attribute_map.each_pair do |attr, param|
  163. 14 value = self.send(attr)
  164. 14 if value.nil?
  165. is_nullable = self.class.openapi_nullable.include?(attr)
  166. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  167. end
  168. 14 hash[param] = _to_hash(value)
  169. end
  170. 2 hash
  171. end
  172. end
  173. end

lib/bandwidth-sdk/models/dtmf_callback.rb

85.83% lines covered

120 relevant lines. 103 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The DTMF event is sent for every digit detected after a <StartGather> verb is executed. You may not respond to this event with BXML.
  13. 1 class DtmfCallback < ApiModelBase
  14. # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect.
  15. 1 attr_accessor :event_type
  16. # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.
  17. 1 attr_accessor :event_time
  18. # The user account associated with the call.
  19. 1 attr_accessor :account_id
  20. # The id of the application associated with the call.
  21. 1 attr_accessor :application_id
  22. # The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555).
  23. 1 attr_accessor :from
  24. # The phone number that received the call, in E.164 format (e.g. +15555555555).
  25. 1 attr_accessor :to
  26. # The call id associated with the event.
  27. 1 attr_accessor :call_id
  28. 1 attr_accessor :direction
  29. # The digit collected in the call.
  30. 1 attr_accessor :digit
  31. # The URL of the call associated with the event.
  32. 1 attr_accessor :call_url
  33. # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format.
  34. 1 attr_accessor :enqueued_time
  35. # Time the call was started, in ISO 8601 format.
  36. 1 attr_accessor :start_time
  37. # Time the call was answered, in ISO 8601 format.
  38. 1 attr_accessor :answer_time
  39. # (optional) If the event is related to the B leg of a <Transfer>, the call id of the original call leg that executed the <Transfer>. Otherwise, this field will not be present.
  40. 1 attr_accessor :parent_call_id
  41. # The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555).
  42. 1 attr_accessor :transfer_caller_id
  43. # The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555).
  44. 1 attr_accessor :transfer_to
  45. # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.
  46. 1 attr_accessor :tag
  47. 1 class EnumAttributeValidator
  48. 1 attr_reader :datatype
  49. 1 attr_reader :allowable_values
  50. 1 def initialize(datatype, allowable_values)
  51. @allowable_values = allowable_values.map do |value|
  52. case datatype.to_s
  53. when /Integer/i
  54. value.to_i
  55. when /Float/i
  56. value.to_f
  57. else
  58. value
  59. end
  60. end
  61. end
  62. 1 def valid?(value)
  63. !value || allowable_values.include?(value)
  64. end
  65. end
  66. # Attribute mapping from ruby-style variable name to JSON key.
  67. 1 def self.attribute_map
  68. 79 {
  69. :'event_type' => :'eventType',
  70. :'event_time' => :'eventTime',
  71. :'account_id' => :'accountId',
  72. :'application_id' => :'applicationId',
  73. :'from' => :'from',
  74. :'to' => :'to',
  75. :'call_id' => :'callId',
  76. :'direction' => :'direction',
  77. :'digit' => :'digit',
  78. :'call_url' => :'callUrl',
  79. :'enqueued_time' => :'enqueuedTime',
  80. :'start_time' => :'startTime',
  81. :'answer_time' => :'answerTime',
  82. :'parent_call_id' => :'parentCallId',
  83. :'transfer_caller_id' => :'transferCallerId',
  84. :'transfer_to' => :'transferTo',
  85. :'tag' => :'tag'
  86. }
  87. end
  88. # Returns attribute mapping this model knows about
  89. 1 def self.acceptable_attribute_map
  90. 8 attribute_map
  91. end
  92. # Returns all the JSON keys this model knows about
  93. 1 def self.acceptable_attributes
  94. 1 acceptable_attribute_map.values
  95. end
  96. # Attribute type mapping.
  97. 1 def self.openapi_types
  98. 1 {
  99. :'event_type' => :'String',
  100. :'event_time' => :'Time',
  101. :'account_id' => :'String',
  102. :'application_id' => :'String',
  103. :'from' => :'String',
  104. :'to' => :'String',
  105. :'call_id' => :'String',
  106. :'direction' => :'CallDirectionEnum',
  107. :'digit' => :'String',
  108. :'call_url' => :'String',
  109. :'enqueued_time' => :'Time',
  110. :'start_time' => :'Time',
  111. :'answer_time' => :'Time',
  112. :'parent_call_id' => :'String',
  113. :'transfer_caller_id' => :'String',
  114. :'transfer_to' => :'String',
  115. :'tag' => :'String'
  116. }
  117. end
  118. # List of attributes with nullable: true
  119. 1 def self.openapi_nullable
  120. 1 Set.new([
  121. :'enqueued_time',
  122. :'answer_time',
  123. :'tag'
  124. ])
  125. end
  126. # Initializes the object
  127. # @param [Hash] attributes Model attributes in the form of hash
  128. 1 def initialize(attributes = {})
  129. 8 if (!attributes.is_a?(Hash))
  130. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::DtmfCallback` initialize method'
  131. end
  132. # check to see if the attribute exists and convert string to symbol for hash key
  133. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  134. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  135. 69 if (!acceptable_attribute_map.key?(k.to_sym))
  136. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::DtmfCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  137. end
  138. 68 h[k.to_sym] = v
  139. }
  140. 6 if attributes.key?(:'event_type')
  141. 4 self.event_type = attributes[:'event_type']
  142. end
  143. 6 if attributes.key?(:'event_time')
  144. 4 self.event_time = attributes[:'event_time']
  145. end
  146. 6 if attributes.key?(:'account_id')
  147. 4 self.account_id = attributes[:'account_id']
  148. end
  149. 6 if attributes.key?(:'application_id')
  150. 4 self.application_id = attributes[:'application_id']
  151. end
  152. 6 if attributes.key?(:'from')
  153. 4 self.from = attributes[:'from']
  154. end
  155. 6 if attributes.key?(:'to')
  156. 4 self.to = attributes[:'to']
  157. end
  158. 6 if attributes.key?(:'call_id')
  159. 4 self.call_id = attributes[:'call_id']
  160. end
  161. 6 if attributes.key?(:'direction')
  162. 4 self.direction = attributes[:'direction']
  163. end
  164. 6 if attributes.key?(:'digit')
  165. 4 self.digit = attributes[:'digit']
  166. end
  167. 6 if attributes.key?(:'call_url')
  168. 4 self.call_url = attributes[:'call_url']
  169. end
  170. 6 if attributes.key?(:'enqueued_time')
  171. 4 self.enqueued_time = attributes[:'enqueued_time']
  172. end
  173. 6 if attributes.key?(:'start_time')
  174. 4 self.start_time = attributes[:'start_time']
  175. end
  176. 6 if attributes.key?(:'answer_time')
  177. 4 self.answer_time = attributes[:'answer_time']
  178. end
  179. 6 if attributes.key?(:'parent_call_id')
  180. 4 self.parent_call_id = attributes[:'parent_call_id']
  181. end
  182. 6 if attributes.key?(:'transfer_caller_id')
  183. 4 self.transfer_caller_id = attributes[:'transfer_caller_id']
  184. end
  185. 6 if attributes.key?(:'transfer_to')
  186. 4 self.transfer_to = attributes[:'transfer_to']
  187. end
  188. 6 if attributes.key?(:'tag')
  189. 4 self.tag = attributes[:'tag']
  190. end
  191. end
  192. # Show invalid properties with the reasons. Usually used together with valid?
  193. # @return Array for valid properties with the reasons
  194. 1 def list_invalid_properties
  195. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  196. invalid_properties = Array.new
  197. invalid_properties
  198. end
  199. # Check to see if the all the properties in the model are valid
  200. # @return true if the model is valid
  201. 1 def valid?
  202. warn '[DEPRECATED] the `valid?` method is obsolete'
  203. true
  204. end
  205. # Checks equality by comparing each attribute.
  206. # @param [Object] Object to be compared
  207. 1 def ==(o)
  208. 2 return true if self.equal?(o)
  209. 2 self.class == o.class &&
  210. event_type == o.event_type &&
  211. event_time == o.event_time &&
  212. account_id == o.account_id &&
  213. application_id == o.application_id &&
  214. from == o.from &&
  215. to == o.to &&
  216. call_id == o.call_id &&
  217. direction == o.direction &&
  218. digit == o.digit &&
  219. call_url == o.call_url &&
  220. enqueued_time == o.enqueued_time &&
  221. start_time == o.start_time &&
  222. answer_time == o.answer_time &&
  223. parent_call_id == o.parent_call_id &&
  224. transfer_caller_id == o.transfer_caller_id &&
  225. transfer_to == o.transfer_to &&
  226. tag == o.tag
  227. end
  228. # @see the `==` method
  229. # @param [Object] Object to be compared
  230. 1 def eql?(o)
  231. 2 self == o
  232. end
  233. # Calculates hash code according to all attributes.
  234. # @return [Integer] Hash code
  235. 1 def hash
  236. [event_type, event_time, account_id, application_id, from, to, call_id, direction, digit, call_url, enqueued_time, start_time, answer_time, parent_call_id, transfer_caller_id, transfer_to, tag].hash
  237. end
  238. # Builds the object from hash
  239. # @param [Hash] attributes Model attributes in the form of hash
  240. # @return [Object] Returns the model itself
  241. 1 def self.build_from_hash(attributes)
  242. 1 return nil unless attributes.is_a?(Hash)
  243. 1 attributes = attributes.transform_keys(&:to_sym)
  244. 1 transformed_hash = {}
  245. 1 openapi_types.each_pair do |key, type|
  246. 17 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  247. transformed_hash["#{key}"] = nil
  248. 17 elsif type =~ /\AArray<(.*)>/i
  249. # check to ensure the input is an array given that the attribute
  250. # is documented as an array but the input is not
  251. if attributes[attribute_map[key]].is_a?(Array)
  252. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  253. end
  254. 17 elsif !attributes[attribute_map[key]].nil?
  255. 17 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  256. end
  257. end
  258. 1 new(transformed_hash)
  259. end
  260. # Returns the object in the form of hash
  261. # @return [Hash] Returns the object in the form of hash
  262. 1 def to_hash
  263. 2 hash = {}
  264. 2 self.class.attribute_map.each_pair do |attr, param|
  265. 34 value = self.send(attr)
  266. 34 if value.nil?
  267. is_nullable = self.class.openapi_nullable.include?(attr)
  268. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  269. end
  270. 34 hash[param] = _to_hash(value)
  271. end
  272. 2 hash
  273. end
  274. end
  275. end

lib/bandwidth-sdk/models/endpoint.rb

75.18% lines covered

137 relevant lines. 103 lines covered and 34 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class Endpoint < ApiModelBase
  13. # The unique ID of the endpoint.
  14. 1 attr_accessor :endpoint_id
  15. 1 attr_accessor :type
  16. 1 attr_accessor :status
  17. # The time the endpoint was created. In ISO-8601 format.
  18. 1 attr_accessor :creation_timestamp
  19. # The time the endpoint token will expire. In ISO-8601 format. Tokens last 24 hours.
  20. 1 attr_accessor :expiration_timestamp
  21. # A tag for the endpoint.
  22. 1 attr_accessor :tag
  23. 1 attr_accessor :devices
  24. 1 class EnumAttributeValidator
  25. 1 attr_reader :datatype
  26. 1 attr_reader :allowable_values
  27. 1 def initialize(datatype, allowable_values)
  28. @allowable_values = allowable_values.map do |value|
  29. case datatype.to_s
  30. when /Integer/i
  31. value.to_i
  32. when /Float/i
  33. value.to_f
  34. else
  35. value
  36. end
  37. end
  38. end
  39. 1 def valid?(value)
  40. !value || allowable_values.include?(value)
  41. end
  42. end
  43. # Attribute mapping from ruby-style variable name to JSON key.
  44. 1 def self.attribute_map
  45. 107 {
  46. :'endpoint_id' => :'endpointId',
  47. :'type' => :'type',
  48. :'status' => :'status',
  49. :'creation_timestamp' => :'creationTimestamp',
  50. :'expiration_timestamp' => :'expirationTimestamp',
  51. :'tag' => :'tag',
  52. :'devices' => :'devices'
  53. }
  54. end
  55. # Returns attribute mapping this model knows about
  56. 1 def self.acceptable_attribute_map
  57. 22 attribute_map
  58. end
  59. # Returns all the JSON keys this model knows about
  60. 1 def self.acceptable_attributes
  61. 1 acceptable_attribute_map.values
  62. end
  63. # Attribute type mapping.
  64. 1 def self.openapi_types
  65. 3 {
  66. :'endpoint_id' => :'String',
  67. :'type' => :'EndpointTypeEnum',
  68. :'status' => :'EndpointStatusEnum',
  69. :'creation_timestamp' => :'Time',
  70. :'expiration_timestamp' => :'Time',
  71. :'tag' => :'String',
  72. :'devices' => :'Array<Device>'
  73. }
  74. end
  75. # List of attributes with nullable: true
  76. 1 def self.openapi_nullable
  77. 5 Set.new([
  78. ])
  79. end
  80. # List of class defined in allOf (OpenAPI v3)
  81. 1 def self.openapi_all_of
  82. [
  83. :'Endpoints'
  84. ]
  85. end
  86. # Initializes the object
  87. # @param [Hash] attributes Model attributes in the form of hash
  88. 1 def initialize(attributes = {})
  89. 22 if (!attributes.is_a?(Hash))
  90. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::Endpoint` initialize method'
  91. end
  92. # check to see if the attribute exists and convert string to symbol for hash key
  93. 21 acceptable_attribute_map = self.class.acceptable_attribute_map
  94. 21 attributes = attributes.each_with_object({}) { |(k, v), h|
  95. 103 if (!acceptable_attribute_map.key?(k.to_sym))
  96. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::Endpoint`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  97. end
  98. 102 h[k.to_sym] = v
  99. }
  100. 20 if attributes.key?(:'endpoint_id')
  101. 20 self.endpoint_id = attributes[:'endpoint_id']
  102. else
  103. self.endpoint_id = nil
  104. end
  105. 19 if attributes.key?(:'type')
  106. 19 self.type = attributes[:'type']
  107. else
  108. self.type = nil
  109. end
  110. 18 if attributes.key?(:'status')
  111. 18 self.status = attributes[:'status']
  112. else
  113. self.status = nil
  114. end
  115. 17 if attributes.key?(:'creation_timestamp')
  116. 17 self.creation_timestamp = attributes[:'creation_timestamp']
  117. else
  118. self.creation_timestamp = nil
  119. end
  120. 16 if attributes.key?(:'expiration_timestamp')
  121. 16 self.expiration_timestamp = attributes[:'expiration_timestamp']
  122. else
  123. self.expiration_timestamp = nil
  124. end
  125. 15 if attributes.key?(:'tag')
  126. 6 self.tag = attributes[:'tag']
  127. end
  128. 15 if attributes.key?(:'devices')
  129. 6 if (value = attributes[:'devices']).is_a?(Array)
  130. 6 self.devices = value
  131. end
  132. end
  133. end
  134. # Show invalid properties with the reasons. Usually used together with valid?
  135. # @return Array for valid properties with the reasons
  136. 1 def list_invalid_properties
  137. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  138. invalid_properties = Array.new
  139. if @endpoint_id.nil?
  140. invalid_properties.push('invalid value for "endpoint_id", endpoint_id cannot be nil.')
  141. end
  142. if @type.nil?
  143. invalid_properties.push('invalid value for "type", type cannot be nil.')
  144. end
  145. if @status.nil?
  146. invalid_properties.push('invalid value for "status", status cannot be nil.')
  147. end
  148. if @creation_timestamp.nil?
  149. invalid_properties.push('invalid value for "creation_timestamp", creation_timestamp cannot be nil.')
  150. end
  151. if @expiration_timestamp.nil?
  152. invalid_properties.push('invalid value for "expiration_timestamp", expiration_timestamp cannot be nil.')
  153. end
  154. invalid_properties
  155. end
  156. # Check to see if the all the properties in the model are valid
  157. # @return true if the model is valid
  158. 1 def valid?
  159. warn '[DEPRECATED] the `valid?` method is obsolete'
  160. return false if @endpoint_id.nil?
  161. return false if @type.nil?
  162. return false if @status.nil?
  163. return false if @creation_timestamp.nil?
  164. return false if @expiration_timestamp.nil?
  165. true
  166. end
  167. # Custom attribute writer method with validation
  168. # @param [Object] endpoint_id Value to be assigned
  169. 1 def endpoint_id=(endpoint_id)
  170. 20 if endpoint_id.nil?
  171. 1 fail ArgumentError, 'endpoint_id cannot be nil'
  172. end
  173. 19 @endpoint_id = endpoint_id
  174. end
  175. # Custom attribute writer method with validation
  176. # @param [Object] type Value to be assigned
  177. 1 def type=(type)
  178. 19 if type.nil?
  179. 1 fail ArgumentError, 'type cannot be nil'
  180. end
  181. 18 @type = type
  182. end
  183. # Custom attribute writer method with validation
  184. # @param [Object] status Value to be assigned
  185. 1 def status=(status)
  186. 18 if status.nil?
  187. 1 fail ArgumentError, 'status cannot be nil'
  188. end
  189. 17 @status = status
  190. end
  191. # Custom attribute writer method with validation
  192. # @param [Object] creation_timestamp Value to be assigned
  193. 1 def creation_timestamp=(creation_timestamp)
  194. 17 if creation_timestamp.nil?
  195. 1 fail ArgumentError, 'creation_timestamp cannot be nil'
  196. end
  197. 16 @creation_timestamp = creation_timestamp
  198. end
  199. # Custom attribute writer method with validation
  200. # @param [Object] expiration_timestamp Value to be assigned
  201. 1 def expiration_timestamp=(expiration_timestamp)
  202. 16 if expiration_timestamp.nil?
  203. 1 fail ArgumentError, 'expiration_timestamp cannot be nil'
  204. end
  205. 15 @expiration_timestamp = expiration_timestamp
  206. end
  207. # Custom attribute writer method with validation
  208. # @param [Object] tag Value to be assigned
  209. 1 def tag=(tag)
  210. 7 if tag.nil?
  211. 1 fail ArgumentError, 'tag cannot be nil'
  212. end
  213. 6 @tag = tag
  214. end
  215. # Checks equality by comparing each attribute.
  216. # @param [Object] Object to be compared
  217. 1 def ==(o)
  218. 3 return true if self.equal?(o)
  219. 2 self.class == o.class &&
  220. endpoint_id == o.endpoint_id &&
  221. type == o.type &&
  222. status == o.status &&
  223. creation_timestamp == o.creation_timestamp &&
  224. expiration_timestamp == o.expiration_timestamp &&
  225. tag == o.tag &&
  226. devices == o.devices
  227. end
  228. # @see the `==` method
  229. # @param [Object] Object to be compared
  230. 1 def eql?(o)
  231. 2 self == o
  232. end
  233. # Calculates hash code according to all attributes.
  234. # @return [Integer] Hash code
  235. 1 def hash
  236. [endpoint_id, type, status, creation_timestamp, expiration_timestamp, tag, devices].hash
  237. end
  238. # Builds the object from hash
  239. # @param [Hash] attributes Model attributes in the form of hash
  240. # @return [Object] Returns the model itself
  241. 1 def self.build_from_hash(attributes)
  242. 3 return nil unless attributes.is_a?(Hash)
  243. 3 attributes = attributes.transform_keys(&:to_sym)
  244. 3 transformed_hash = {}
  245. 3 openapi_types.each_pair do |key, type|
  246. 21 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  247. transformed_hash["#{key}"] = nil
  248. 21 elsif type =~ /\AArray<(.*)>/i
  249. # check to ensure the input is an array given that the attribute
  250. # is documented as an array but the input is not
  251. 3 if attributes[attribute_map[key]].is_a?(Array)
  252. 3 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  253. end
  254. 18 elsif !attributes[attribute_map[key]].nil?
  255. 17 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  256. end
  257. end
  258. 3 new(transformed_hash)
  259. end
  260. # Returns the object in the form of hash
  261. # @return [Hash] Returns the object in the form of hash
  262. 1 def to_hash
  263. 4 hash = {}
  264. 4 self.class.attribute_map.each_pair do |attr, param|
  265. 28 value = self.send(attr)
  266. 28 if value.nil?
  267. 4 is_nullable = self.class.openapi_nullable.include?(attr)
  268. 4 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  269. end
  270. 24 hash[param] = _to_hash(value)
  271. end
  272. 4 hash
  273. end
  274. end
  275. end

lib/bandwidth-sdk/models/endpoint_direction_enum.rb

100.0% lines covered

14 relevant lines. 14 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class EndpointDirectionEnum
  13. 1 INBOUND = 'INBOUND'.freeze
  14. 1 OUTBOUND = 'OUTBOUND'.freeze
  15. 1 BIDIRECTIONAL = 'BIDIRECTIONAL'.freeze
  16. 1 def self.all_vars
  17. 7 @all_vars ||= [INBOUND, OUTBOUND, BIDIRECTIONAL].freeze
  18. end
  19. # Builds the enum from string
  20. # @param [String] The enum value in the form of the string
  21. # @return [String] The enum value
  22. 1 def self.build_from_hash(value)
  23. 6 new.build_from_hash(value)
  24. end
  25. # Builds the enum from string
  26. # @param [String] The enum value in the form of the string
  27. # @return [String] The enum value
  28. 1 def build_from_hash(value)
  29. 6 return value if EndpointDirectionEnum.all_vars.include?(value)
  30. 1 raise "Invalid ENUM value #{value} for class #EndpointDirectionEnum"
  31. end
  32. end
  33. end

lib/bandwidth-sdk/models/endpoint_event.rb

70.89% lines covered

158 relevant lines. 112 lines covered and 46 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # An event that occurred on an endpoint.
  13. 1 class EndpointEvent < ApiModelBase
  14. # The unique ID of the endpoint.
  15. 1 attr_accessor :endpoint_id
  16. 1 attr_accessor :type
  17. 1 attr_accessor :status
  18. # The time the endpoint was created. In ISO-8601 format.
  19. 1 attr_accessor :creation_timestamp
  20. # The time the endpoint token will expire. In ISO-8601 format. Tokens last 24 hours.
  21. 1 attr_accessor :expiration_timestamp
  22. # A tag for the endpoint.
  23. 1 attr_accessor :tag
  24. # The time the event occurred. In ISO-8601 format.
  25. 1 attr_accessor :event_time
  26. 1 attr_accessor :event_type
  27. 1 attr_accessor :device
  28. 1 class EnumAttributeValidator
  29. 1 attr_reader :datatype
  30. 1 attr_reader :allowable_values
  31. 1 def initialize(datatype, allowable_values)
  32. @allowable_values = allowable_values.map do |value|
  33. case datatype.to_s
  34. when /Integer/i
  35. value.to_i
  36. when /Float/i
  37. value.to_f
  38. else
  39. value
  40. end
  41. end
  42. end
  43. 1 def valid?(value)
  44. !value || allowable_values.include?(value)
  45. end
  46. end
  47. # Attribute mapping from ruby-style variable name to JSON key.
  48. 1 def self.attribute_map
  49. 55 {
  50. :'endpoint_id' => :'endpointId',
  51. :'type' => :'type',
  52. :'status' => :'status',
  53. :'creation_timestamp' => :'creationTimestamp',
  54. :'expiration_timestamp' => :'expirationTimestamp',
  55. :'tag' => :'tag',
  56. :'event_time' => :'eventTime',
  57. :'event_type' => :'eventType',
  58. :'device' => :'device'
  59. }
  60. end
  61. # Returns attribute mapping this model knows about
  62. 1 def self.acceptable_attribute_map
  63. 16 attribute_map
  64. end
  65. # Returns all the JSON keys this model knows about
  66. 1 def self.acceptable_attributes
  67. 1 acceptable_attribute_map.values
  68. end
  69. # Attribute type mapping.
  70. 1 def self.openapi_types
  71. 1 {
  72. :'endpoint_id' => :'String',
  73. :'type' => :'EndpointTypeEnum',
  74. :'status' => :'EndpointStatusEnum',
  75. :'creation_timestamp' => :'Time',
  76. :'expiration_timestamp' => :'Time',
  77. :'tag' => :'String',
  78. :'event_time' => :'Time',
  79. :'event_type' => :'EndpointEventTypeEnum',
  80. :'device' => :'Device'
  81. }
  82. end
  83. # List of attributes with nullable: true
  84. 1 def self.openapi_nullable
  85. 1 Set.new([
  86. ])
  87. end
  88. # List of class defined in allOf (OpenAPI v3)
  89. 1 def self.openapi_all_of
  90. [
  91. :'Endpoints'
  92. ]
  93. end
  94. # Initializes the object
  95. # @param [Hash] attributes Model attributes in the form of hash
  96. 1 def initialize(attributes = {})
  97. 16 if (!attributes.is_a?(Hash))
  98. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::EndpointEvent` initialize method'
  99. end
  100. # check to see if the attribute exists and convert string to symbol for hash key
  101. 15 acceptable_attribute_map = self.class.acceptable_attribute_map
  102. 15 attributes = attributes.each_with_object({}) { |(k, v), h|
  103. 108 if (!acceptable_attribute_map.key?(k.to_sym))
  104. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::EndpointEvent`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  105. end
  106. 107 h[k.to_sym] = v
  107. }
  108. 14 if attributes.key?(:'endpoint_id')
  109. 14 self.endpoint_id = attributes[:'endpoint_id']
  110. else
  111. self.endpoint_id = nil
  112. end
  113. 13 if attributes.key?(:'type')
  114. 13 self.type = attributes[:'type']
  115. else
  116. self.type = nil
  117. end
  118. 12 if attributes.key?(:'status')
  119. 12 self.status = attributes[:'status']
  120. else
  121. self.status = nil
  122. end
  123. 11 if attributes.key?(:'creation_timestamp')
  124. 11 self.creation_timestamp = attributes[:'creation_timestamp']
  125. else
  126. self.creation_timestamp = nil
  127. end
  128. 10 if attributes.key?(:'expiration_timestamp')
  129. 10 self.expiration_timestamp = attributes[:'expiration_timestamp']
  130. else
  131. self.expiration_timestamp = nil
  132. end
  133. 9 if attributes.key?(:'tag')
  134. 5 self.tag = attributes[:'tag']
  135. end
  136. 8 if attributes.key?(:'event_time')
  137. 8 self.event_time = attributes[:'event_time']
  138. else
  139. self.event_time = nil
  140. end
  141. 7 if attributes.key?(:'event_type')
  142. 7 self.event_type = attributes[:'event_type']
  143. else
  144. self.event_type = nil
  145. end
  146. 6 if attributes.key?(:'device')
  147. 4 self.device = attributes[:'device']
  148. end
  149. end
  150. # Show invalid properties with the reasons. Usually used together with valid?
  151. # @return Array for valid properties with the reasons
  152. 1 def list_invalid_properties
  153. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  154. invalid_properties = Array.new
  155. if @endpoint_id.nil?
  156. invalid_properties.push('invalid value for "endpoint_id", endpoint_id cannot be nil.')
  157. end
  158. if @type.nil?
  159. invalid_properties.push('invalid value for "type", type cannot be nil.')
  160. end
  161. if @status.nil?
  162. invalid_properties.push('invalid value for "status", status cannot be nil.')
  163. end
  164. if @creation_timestamp.nil?
  165. invalid_properties.push('invalid value for "creation_timestamp", creation_timestamp cannot be nil.')
  166. end
  167. if @expiration_timestamp.nil?
  168. invalid_properties.push('invalid value for "expiration_timestamp", expiration_timestamp cannot be nil.')
  169. end
  170. if @event_time.nil?
  171. invalid_properties.push('invalid value for "event_time", event_time cannot be nil.')
  172. end
  173. if @event_type.nil?
  174. invalid_properties.push('invalid value for "event_type", event_type cannot be nil.')
  175. end
  176. invalid_properties
  177. end
  178. # Check to see if the all the properties in the model are valid
  179. # @return true if the model is valid
  180. 1 def valid?
  181. warn '[DEPRECATED] the `valid?` method is obsolete'
  182. return false if @endpoint_id.nil?
  183. return false if @type.nil?
  184. return false if @status.nil?
  185. return false if @creation_timestamp.nil?
  186. return false if @expiration_timestamp.nil?
  187. return false if @event_time.nil?
  188. return false if @event_type.nil?
  189. true
  190. end
  191. # Custom attribute writer method with validation
  192. # @param [Object] endpoint_id Value to be assigned
  193. 1 def endpoint_id=(endpoint_id)
  194. 14 if endpoint_id.nil?
  195. 1 fail ArgumentError, 'endpoint_id cannot be nil'
  196. end
  197. 13 @endpoint_id = endpoint_id
  198. end
  199. # Custom attribute writer method with validation
  200. # @param [Object] type Value to be assigned
  201. 1 def type=(type)
  202. 13 if type.nil?
  203. 1 fail ArgumentError, 'type cannot be nil'
  204. end
  205. 12 @type = type
  206. end
  207. # Custom attribute writer method with validation
  208. # @param [Object] status Value to be assigned
  209. 1 def status=(status)
  210. 12 if status.nil?
  211. 1 fail ArgumentError, 'status cannot be nil'
  212. end
  213. 11 @status = status
  214. end
  215. # Custom attribute writer method with validation
  216. # @param [Object] creation_timestamp Value to be assigned
  217. 1 def creation_timestamp=(creation_timestamp)
  218. 11 if creation_timestamp.nil?
  219. 1 fail ArgumentError, 'creation_timestamp cannot be nil'
  220. end
  221. 10 @creation_timestamp = creation_timestamp
  222. end
  223. # Custom attribute writer method with validation
  224. # @param [Object] expiration_timestamp Value to be assigned
  225. 1 def expiration_timestamp=(expiration_timestamp)
  226. 10 if expiration_timestamp.nil?
  227. 1 fail ArgumentError, 'expiration_timestamp cannot be nil'
  228. end
  229. 9 @expiration_timestamp = expiration_timestamp
  230. end
  231. # Custom attribute writer method with validation
  232. # @param [Object] tag Value to be assigned
  233. 1 def tag=(tag)
  234. 5 if tag.nil?
  235. 1 fail ArgumentError, 'tag cannot be nil'
  236. end
  237. 4 @tag = tag
  238. end
  239. # Custom attribute writer method with validation
  240. # @param [Object] event_time Value to be assigned
  241. 1 def event_time=(event_time)
  242. 8 if event_time.nil?
  243. 1 fail ArgumentError, 'event_time cannot be nil'
  244. end
  245. 7 @event_time = event_time
  246. end
  247. # Custom attribute writer method with validation
  248. # @param [Object] event_type Value to be assigned
  249. 1 def event_type=(event_type)
  250. 7 if event_type.nil?
  251. 1 fail ArgumentError, 'event_type cannot be nil'
  252. end
  253. 6 @event_type = event_type
  254. end
  255. # Checks equality by comparing each attribute.
  256. # @param [Object] Object to be compared
  257. 1 def ==(o)
  258. 2 return true if self.equal?(o)
  259. 2 self.class == o.class &&
  260. endpoint_id == o.endpoint_id &&
  261. type == o.type &&
  262. status == o.status &&
  263. creation_timestamp == o.creation_timestamp &&
  264. expiration_timestamp == o.expiration_timestamp &&
  265. tag == o.tag &&
  266. event_time == o.event_time &&
  267. event_type == o.event_type &&
  268. device == o.device
  269. end
  270. # @see the `==` method
  271. # @param [Object] Object to be compared
  272. 1 def eql?(o)
  273. 2 self == o
  274. end
  275. # Calculates hash code according to all attributes.
  276. # @return [Integer] Hash code
  277. 1 def hash
  278. [endpoint_id, type, status, creation_timestamp, expiration_timestamp, tag, event_time, event_type, device].hash
  279. end
  280. # Builds the object from hash
  281. # @param [Hash] attributes Model attributes in the form of hash
  282. # @return [Object] Returns the model itself
  283. 1 def self.build_from_hash(attributes)
  284. 1 return nil unless attributes.is_a?(Hash)
  285. 1 attributes = attributes.transform_keys(&:to_sym)
  286. 1 transformed_hash = {}
  287. 1 openapi_types.each_pair do |key, type|
  288. 9 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  289. transformed_hash["#{key}"] = nil
  290. 9 elsif type =~ /\AArray<(.*)>/i
  291. # check to ensure the input is an array given that the attribute
  292. # is documented as an array but the input is not
  293. if attributes[attribute_map[key]].is_a?(Array)
  294. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  295. end
  296. 9 elsif !attributes[attribute_map[key]].nil?
  297. 9 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  298. end
  299. end
  300. 1 new(transformed_hash)
  301. end
  302. # Returns the object in the form of hash
  303. # @return [Hash] Returns the object in the form of hash
  304. 1 def to_hash
  305. 2 hash = {}
  306. 2 self.class.attribute_map.each_pair do |attr, param|
  307. 18 value = self.send(attr)
  308. 18 if value.nil?
  309. is_nullable = self.class.openapi_nullable.include?(attr)
  310. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  311. end
  312. 18 hash[param] = _to_hash(value)
  313. end
  314. 2 hash
  315. end
  316. end
  317. end

lib/bandwidth-sdk/models/endpoint_event_type_enum.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class EndpointEventTypeEnum
  13. 1 DEVICE_CONNECTED = 'DEVICE_CONNECTED'.freeze
  14. 1 DEVICE_DISCONNECTED = 'DEVICE_DISCONNECTED'.freeze
  15. 1 def self.all_vars
  16. 5 @all_vars ||= [DEVICE_CONNECTED, DEVICE_DISCONNECTED].freeze
  17. end
  18. # Builds the enum from string
  19. # @param [String] The enum value in the form of the string
  20. # @return [String] The enum value
  21. 1 def self.build_from_hash(value)
  22. 4 new.build_from_hash(value)
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def build_from_hash(value)
  28. 4 return value if EndpointEventTypeEnum.all_vars.include?(value)
  29. 1 raise "Invalid ENUM value #{value} for class #EndpointEventTypeEnum"
  30. end
  31. end
  32. end

lib/bandwidth-sdk/models/endpoint_response.rb

77.42% lines covered

93 relevant lines. 72 lines covered and 21 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class EndpointResponse < ApiModelBase
  13. 1 attr_accessor :links
  14. 1 attr_accessor :data
  15. 1 attr_accessor :errors
  16. # Attribute mapping from ruby-style variable name to JSON key.
  17. 1 def self.attribute_map
  18. 39 {
  19. :'links' => :'links',
  20. :'data' => :'data',
  21. :'errors' => :'errors'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 12 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 1 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 2 {
  35. :'links' => :'Array<BrtcLink>',
  36. :'data' => :'Endpoint',
  37. :'errors' => :'Array<BrtcError>'
  38. }
  39. end
  40. # List of attributes with nullable: true
  41. 1 def self.openapi_nullable
  42. 1 Set.new([
  43. ])
  44. end
  45. # Initializes the object
  46. # @param [Hash] attributes Model attributes in the form of hash
  47. 1 def initialize(attributes = {})
  48. 12 if (!attributes.is_a?(Hash))
  49. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::EndpointResponse` initialize method'
  50. end
  51. # check to see if the attribute exists and convert string to symbol for hash key
  52. 11 acceptable_attribute_map = self.class.acceptable_attribute_map
  53. 11 attributes = attributes.each_with_object({}) { |(k, v), h|
  54. 31 if (!acceptable_attribute_map.key?(k.to_sym))
  55. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::EndpointResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  56. end
  57. 30 h[k.to_sym] = v
  58. }
  59. 10 if attributes.key?(:'links')
  60. 10 if (value = attributes[:'links']).is_a?(Array)
  61. 10 self.links = value
  62. end
  63. else
  64. self.links = nil
  65. end
  66. 10 if attributes.key?(:'data')
  67. 10 self.data = attributes[:'data']
  68. else
  69. self.data = nil
  70. end
  71. 10 if attributes.key?(:'errors')
  72. 10 if (value = attributes[:'errors']).is_a?(Array)
  73. 10 self.errors = value
  74. end
  75. else
  76. self.errors = nil
  77. end
  78. end
  79. # Show invalid properties with the reasons. Usually used together with valid?
  80. # @return Array for valid properties with the reasons
  81. 1 def list_invalid_properties
  82. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  83. invalid_properties = Array.new
  84. if @links.nil?
  85. invalid_properties.push('invalid value for "links", links cannot be nil.')
  86. end
  87. if @data.nil?
  88. invalid_properties.push('invalid value for "data", data cannot be nil.')
  89. end
  90. if @errors.nil?
  91. invalid_properties.push('invalid value for "errors", errors cannot be nil.')
  92. end
  93. invalid_properties
  94. end
  95. # Check to see if the all the properties in the model are valid
  96. # @return true if the model is valid
  97. 1 def valid?
  98. warn '[DEPRECATED] the `valid?` method is obsolete'
  99. return false if @links.nil?
  100. return false if @data.nil?
  101. return false if @errors.nil?
  102. true
  103. end
  104. # Custom attribute writer method with validation
  105. # @param [Object] links Value to be assigned
  106. 1 def links=(links)
  107. 11 if links.nil?
  108. 1 fail ArgumentError, 'links cannot be nil'
  109. end
  110. 10 @links = links
  111. end
  112. # Custom attribute writer method with validation
  113. # @param [Object] data Value to be assigned
  114. 1 def data=(data)
  115. 11 if data.nil?
  116. 1 fail ArgumentError, 'data cannot be nil'
  117. end
  118. 10 @data = data
  119. end
  120. # Custom attribute writer method with validation
  121. # @param [Object] errors Value to be assigned
  122. 1 def errors=(errors)
  123. 11 if errors.nil?
  124. 1 fail ArgumentError, 'errors cannot be nil'
  125. end
  126. 10 @errors = errors
  127. end
  128. # Checks equality by comparing each attribute.
  129. # @param [Object] Object to be compared
  130. 1 def ==(o)
  131. 2 return true if self.equal?(o)
  132. 2 self.class == o.class &&
  133. links == o.links &&
  134. data == o.data &&
  135. errors == o.errors
  136. end
  137. # @see the `==` method
  138. # @param [Object] Object to be compared
  139. 1 def eql?(o)
  140. 2 self == o
  141. end
  142. # Calculates hash code according to all attributes.
  143. # @return [Integer] Hash code
  144. 1 def hash
  145. [links, data, errors].hash
  146. end
  147. # Builds the object from hash
  148. # @param [Hash] attributes Model attributes in the form of hash
  149. # @return [Object] Returns the model itself
  150. 1 def self.build_from_hash(attributes)
  151. 2 return nil unless attributes.is_a?(Hash)
  152. 2 attributes = attributes.transform_keys(&:to_sym)
  153. 2 transformed_hash = {}
  154. 2 openapi_types.each_pair do |key, type|
  155. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  156. transformed_hash["#{key}"] = nil
  157. 6 elsif type =~ /\AArray<(.*)>/i
  158. # check to ensure the input is an array given that the attribute
  159. # is documented as an array but the input is not
  160. 4 if attributes[attribute_map[key]].is_a?(Array)
  161. 7 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  162. end
  163. 2 elsif !attributes[attribute_map[key]].nil?
  164. 2 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  165. end
  166. end
  167. 2 new(transformed_hash)
  168. end
  169. # Returns the object in the form of hash
  170. # @return [Hash] Returns the object in the form of hash
  171. 1 def to_hash
  172. 2 hash = {}
  173. 2 self.class.attribute_map.each_pair do |attr, param|
  174. 6 value = self.send(attr)
  175. 6 if value.nil?
  176. is_nullable = self.class.openapi_nullable.include?(attr)
  177. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  178. end
  179. 6 hash[param] = _to_hash(value)
  180. end
  181. 2 hash
  182. end
  183. end
  184. end

lib/bandwidth-sdk/models/endpoint_status_enum.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class EndpointStatusEnum
  13. 1 CONNECTED = 'CONNECTED'.freeze
  14. 1 DISCONNECTED = 'DISCONNECTED'.freeze
  15. 1 def self.all_vars
  16. 18 @all_vars ||= [CONNECTED, DISCONNECTED].freeze
  17. end
  18. # Builds the enum from string
  19. # @param [String] The enum value in the form of the string
  20. # @return [String] The enum value
  21. 1 def self.build_from_hash(value)
  22. 14 new.build_from_hash(value)
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def build_from_hash(value)
  28. 14 return value if EndpointStatusEnum.all_vars.include?(value)
  29. 1 raise "Invalid ENUM value #{value} for class #EndpointStatusEnum"
  30. end
  31. end
  32. end

lib/bandwidth-sdk/models/endpoint_type_enum.rb

100.0% lines covered

12 relevant lines. 12 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class EndpointTypeEnum
  13. 1 WEBRTC = 'WEBRTC'.freeze
  14. 1 def self.all_vars
  15. 19 @all_vars ||= [WEBRTC].freeze
  16. end
  17. # Builds the enum from string
  18. # @param [String] The enum value in the form of the string
  19. # @return [String] The enum value
  20. 1 def self.build_from_hash(value)
  21. 15 new.build_from_hash(value)
  22. end
  23. # Builds the enum from string
  24. # @param [String] The enum value in the form of the string
  25. # @return [String] The enum value
  26. 1 def build_from_hash(value)
  27. 15 return value if EndpointTypeEnum.all_vars.include?(value)
  28. 1 raise "Invalid ENUM value #{value} for class #EndpointTypeEnum"
  29. end
  30. end
  31. end

lib/bandwidth-sdk/models/endpoints.rb

73.28% lines covered

131 relevant lines. 96 lines covered and 35 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class Endpoints < ApiModelBase
  13. # The unique ID of the endpoint.
  14. 1 attr_accessor :endpoint_id
  15. 1 attr_accessor :type
  16. 1 attr_accessor :status
  17. # The time the endpoint was created. In ISO-8601 format.
  18. 1 attr_accessor :creation_timestamp
  19. # The time the endpoint token will expire. In ISO-8601 format. Tokens last 24 hours.
  20. 1 attr_accessor :expiration_timestamp
  21. # A tag for the endpoint.
  22. 1 attr_accessor :tag
  23. 1 class EnumAttributeValidator
  24. 1 attr_reader :datatype
  25. 1 attr_reader :allowable_values
  26. 1 def initialize(datatype, allowable_values)
  27. @allowable_values = allowable_values.map do |value|
  28. case datatype.to_s
  29. when /Integer/i
  30. value.to_i
  31. when /Float/i
  32. value.to_f
  33. else
  34. value
  35. end
  36. end
  37. end
  38. 1 def valid?(value)
  39. !value || allowable_values.include?(value)
  40. end
  41. end
  42. # Attribute mapping from ruby-style variable name to JSON key.
  43. 1 def self.attribute_map
  44. 122 {
  45. :'endpoint_id' => :'endpointId',
  46. :'type' => :'type',
  47. :'status' => :'status',
  48. :'creation_timestamp' => :'creationTimestamp',
  49. :'expiration_timestamp' => :'expirationTimestamp',
  50. :'tag' => :'tag'
  51. }
  52. end
  53. # Returns attribute mapping this model knows about
  54. 1 def self.acceptable_attribute_map
  55. 23 attribute_map
  56. end
  57. # Returns all the JSON keys this model knows about
  58. 1 def self.acceptable_attributes
  59. 1 acceptable_attribute_map.values
  60. end
  61. # Attribute type mapping.
  62. 1 def self.openapi_types
  63. 4 {
  64. :'endpoint_id' => :'String',
  65. :'type' => :'EndpointTypeEnum',
  66. :'status' => :'EndpointStatusEnum',
  67. :'creation_timestamp' => :'Time',
  68. :'expiration_timestamp' => :'Time',
  69. :'tag' => :'String'
  70. }
  71. end
  72. # List of attributes with nullable: true
  73. 1 def self.openapi_nullable
  74. 3 Set.new([
  75. ])
  76. end
  77. # Initializes the object
  78. # @param [Hash] attributes Model attributes in the form of hash
  79. 1 def initialize(attributes = {})
  80. 23 if (!attributes.is_a?(Hash))
  81. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::Endpoints` initialize method'
  82. end
  83. # check to see if the attribute exists and convert string to symbol for hash key
  84. 22 acceptable_attribute_map = self.class.acceptable_attribute_map
  85. 22 attributes = attributes.each_with_object({}) { |(k, v), h|
  86. 103 if (!acceptable_attribute_map.key?(k.to_sym))
  87. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::Endpoints`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  88. end
  89. 102 h[k.to_sym] = v
  90. }
  91. 21 if attributes.key?(:'endpoint_id')
  92. 21 self.endpoint_id = attributes[:'endpoint_id']
  93. else
  94. self.endpoint_id = nil
  95. end
  96. 20 if attributes.key?(:'type')
  97. 20 self.type = attributes[:'type']
  98. else
  99. self.type = nil
  100. end
  101. 19 if attributes.key?(:'status')
  102. 19 self.status = attributes[:'status']
  103. else
  104. self.status = nil
  105. end
  106. 18 if attributes.key?(:'creation_timestamp')
  107. 18 self.creation_timestamp = attributes[:'creation_timestamp']
  108. else
  109. self.creation_timestamp = nil
  110. end
  111. 17 if attributes.key?(:'expiration_timestamp')
  112. 17 self.expiration_timestamp = attributes[:'expiration_timestamp']
  113. else
  114. self.expiration_timestamp = nil
  115. end
  116. 16 if attributes.key?(:'tag')
  117. 7 self.tag = attributes[:'tag']
  118. end
  119. end
  120. # Show invalid properties with the reasons. Usually used together with valid?
  121. # @return Array for valid properties with the reasons
  122. 1 def list_invalid_properties
  123. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  124. invalid_properties = Array.new
  125. if @endpoint_id.nil?
  126. invalid_properties.push('invalid value for "endpoint_id", endpoint_id cannot be nil.')
  127. end
  128. if @type.nil?
  129. invalid_properties.push('invalid value for "type", type cannot be nil.')
  130. end
  131. if @status.nil?
  132. invalid_properties.push('invalid value for "status", status cannot be nil.')
  133. end
  134. if @creation_timestamp.nil?
  135. invalid_properties.push('invalid value for "creation_timestamp", creation_timestamp cannot be nil.')
  136. end
  137. if @expiration_timestamp.nil?
  138. invalid_properties.push('invalid value for "expiration_timestamp", expiration_timestamp cannot be nil.')
  139. end
  140. invalid_properties
  141. end
  142. # Check to see if the all the properties in the model are valid
  143. # @return true if the model is valid
  144. 1 def valid?
  145. warn '[DEPRECATED] the `valid?` method is obsolete'
  146. return false if @endpoint_id.nil?
  147. return false if @type.nil?
  148. return false if @status.nil?
  149. return false if @creation_timestamp.nil?
  150. return false if @expiration_timestamp.nil?
  151. true
  152. end
  153. # Custom attribute writer method with validation
  154. # @param [Object] endpoint_id Value to be assigned
  155. 1 def endpoint_id=(endpoint_id)
  156. 21 if endpoint_id.nil?
  157. 1 fail ArgumentError, 'endpoint_id cannot be nil'
  158. end
  159. 20 @endpoint_id = endpoint_id
  160. end
  161. # Custom attribute writer method with validation
  162. # @param [Object] type Value to be assigned
  163. 1 def type=(type)
  164. 20 if type.nil?
  165. 1 fail ArgumentError, 'type cannot be nil'
  166. end
  167. 19 @type = type
  168. end
  169. # Custom attribute writer method with validation
  170. # @param [Object] status Value to be assigned
  171. 1 def status=(status)
  172. 19 if status.nil?
  173. 1 fail ArgumentError, 'status cannot be nil'
  174. end
  175. 18 @status = status
  176. end
  177. # Custom attribute writer method with validation
  178. # @param [Object] creation_timestamp Value to be assigned
  179. 1 def creation_timestamp=(creation_timestamp)
  180. 18 if creation_timestamp.nil?
  181. 1 fail ArgumentError, 'creation_timestamp cannot be nil'
  182. end
  183. 17 @creation_timestamp = creation_timestamp
  184. end
  185. # Custom attribute writer method with validation
  186. # @param [Object] expiration_timestamp Value to be assigned
  187. 1 def expiration_timestamp=(expiration_timestamp)
  188. 17 if expiration_timestamp.nil?
  189. 1 fail ArgumentError, 'expiration_timestamp cannot be nil'
  190. end
  191. 16 @expiration_timestamp = expiration_timestamp
  192. end
  193. # Custom attribute writer method with validation
  194. # @param [Object] tag Value to be assigned
  195. 1 def tag=(tag)
  196. 8 if tag.nil?
  197. 1 fail ArgumentError, 'tag cannot be nil'
  198. end
  199. 7 @tag = tag
  200. end
  201. # Checks equality by comparing each attribute.
  202. # @param [Object] Object to be compared
  203. 1 def ==(o)
  204. 2 return true if self.equal?(o)
  205. 2 self.class == o.class &&
  206. endpoint_id == o.endpoint_id &&
  207. type == o.type &&
  208. status == o.status &&
  209. creation_timestamp == o.creation_timestamp &&
  210. expiration_timestamp == o.expiration_timestamp &&
  211. tag == o.tag
  212. end
  213. # @see the `==` method
  214. # @param [Object] Object to be compared
  215. 1 def eql?(o)
  216. 2 self == o
  217. end
  218. # Calculates hash code according to all attributes.
  219. # @return [Integer] Hash code
  220. 1 def hash
  221. [endpoint_id, type, status, creation_timestamp, expiration_timestamp, tag].hash
  222. end
  223. # Builds the object from hash
  224. # @param [Hash] attributes Model attributes in the form of hash
  225. # @return [Object] Returns the model itself
  226. 1 def self.build_from_hash(attributes)
  227. 4 return nil unless attributes.is_a?(Hash)
  228. 4 attributes = attributes.transform_keys(&:to_sym)
  229. 4 transformed_hash = {}
  230. 4 openapi_types.each_pair do |key, type|
  231. 24 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  232. transformed_hash["#{key}"] = nil
  233. 24 elsif type =~ /\AArray<(.*)>/i
  234. # check to ensure the input is an array given that the attribute
  235. # is documented as an array but the input is not
  236. if attributes[attribute_map[key]].is_a?(Array)
  237. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  238. end
  239. 24 elsif !attributes[attribute_map[key]].nil?
  240. 23 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  241. end
  242. end
  243. 4 new(transformed_hash)
  244. end
  245. # Returns the object in the form of hash
  246. # @return [Hash] Returns the object in the form of hash
  247. 1 def to_hash
  248. 4 hash = {}
  249. 4 self.class.attribute_map.each_pair do |attr, param|
  250. 24 value = self.send(attr)
  251. 24 if value.nil?
  252. 2 is_nullable = self.class.openapi_nullable.include?(attr)
  253. 2 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  254. end
  255. 22 hash[param] = _to_hash(value)
  256. end
  257. 4 hash
  258. end
  259. end
  260. end

lib/bandwidth-sdk/models/error_object.rb

74.73% lines covered

91 relevant lines. 68 lines covered and 23 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class ErrorObject < ApiModelBase
  13. # A concise summary of the error used for categorization.
  14. 1 attr_accessor :type
  15. # A detailed explanation of the error.
  16. 1 attr_accessor :description
  17. 1 attr_accessor :source
  18. # Attribute mapping from ruby-style variable name to JSON key.
  19. 1 def self.attribute_map
  20. 62 {
  21. :'type' => :'type',
  22. :'description' => :'description',
  23. :'source' => :'source'
  24. }
  25. end
  26. # Returns attribute mapping this model knows about
  27. 1 def self.acceptable_attribute_map
  28. 19 attribute_map
  29. end
  30. # Returns all the JSON keys this model knows about
  31. 1 def self.acceptable_attributes
  32. 1 acceptable_attribute_map.values
  33. end
  34. # Attribute type mapping.
  35. 1 def self.openapi_types
  36. 3 {
  37. :'type' => :'String',
  38. :'description' => :'String',
  39. :'source' => :'ErrorSource'
  40. }
  41. end
  42. # List of attributes with nullable: true
  43. 1 def self.openapi_nullable
  44. 1 Set.new([
  45. ])
  46. end
  47. # Initializes the object
  48. # @param [Hash] attributes Model attributes in the form of hash
  49. 1 def initialize(attributes = {})
  50. 19 if (!attributes.is_a?(Hash))
  51. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::ErrorObject` initialize method'
  52. end
  53. # check to see if the attribute exists and convert string to symbol for hash key
  54. 18 acceptable_attribute_map = self.class.acceptable_attribute_map
  55. 18 attributes = attributes.each_with_object({}) { |(k, v), h|
  56. 49 if (!acceptable_attribute_map.key?(k.to_sym))
  57. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ErrorObject`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  58. end
  59. 48 h[k.to_sym] = v
  60. }
  61. 17 if attributes.key?(:'type')
  62. 17 self.type = attributes[:'type']
  63. else
  64. self.type = nil
  65. end
  66. 16 if attributes.key?(:'description')
  67. 16 self.description = attributes[:'description']
  68. else
  69. self.description = nil
  70. end
  71. 15 if attributes.key?(:'source')
  72. 15 self.source = attributes[:'source']
  73. else
  74. self.source = nil
  75. end
  76. end
  77. # Show invalid properties with the reasons. Usually used together with valid?
  78. # @return Array for valid properties with the reasons
  79. 1 def list_invalid_properties
  80. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  81. invalid_properties = Array.new
  82. if @type.nil?
  83. invalid_properties.push('invalid value for "type", type cannot be nil.')
  84. end
  85. if @description.nil?
  86. invalid_properties.push('invalid value for "description", description cannot be nil.')
  87. end
  88. if @source.nil?
  89. invalid_properties.push('invalid value for "source", source cannot be nil.')
  90. end
  91. invalid_properties
  92. end
  93. # Check to see if the all the properties in the model are valid
  94. # @return true if the model is valid
  95. 1 def valid?
  96. warn '[DEPRECATED] the `valid?` method is obsolete'
  97. return false if @type.nil?
  98. return false if @description.nil?
  99. return false if @source.nil?
  100. true
  101. end
  102. # Custom attribute writer method with validation
  103. # @param [Object] type Value to be assigned
  104. 1 def type=(type)
  105. 17 if type.nil?
  106. 1 fail ArgumentError, 'type cannot be nil'
  107. end
  108. 16 @type = type
  109. end
  110. # Custom attribute writer method with validation
  111. # @param [Object] description Value to be assigned
  112. 1 def description=(description)
  113. 16 if description.nil?
  114. 1 fail ArgumentError, 'description cannot be nil'
  115. end
  116. 15 @description = description
  117. end
  118. # Custom attribute writer method with validation
  119. # @param [Object] source Value to be assigned
  120. 1 def source=(source)
  121. 15 if source.nil?
  122. 1 fail ArgumentError, 'source cannot be nil'
  123. end
  124. 14 @source = source
  125. end
  126. # Checks equality by comparing each attribute.
  127. # @param [Object] Object to be compared
  128. 1 def ==(o)
  129. 2 return true if self.equal?(o)
  130. 2 self.class == o.class &&
  131. type == o.type &&
  132. description == o.description &&
  133. source == o.source
  134. end
  135. # @see the `==` method
  136. # @param [Object] Object to be compared
  137. 1 def eql?(o)
  138. 2 self == o
  139. end
  140. # Calculates hash code according to all attributes.
  141. # @return [Integer] Hash code
  142. 1 def hash
  143. [type, description, source].hash
  144. end
  145. # Builds the object from hash
  146. # @param [Hash] attributes Model attributes in the form of hash
  147. # @return [Object] Returns the model itself
  148. 1 def self.build_from_hash(attributes)
  149. 3 return nil unless attributes.is_a?(Hash)
  150. 3 attributes = attributes.transform_keys(&:to_sym)
  151. 3 transformed_hash = {}
  152. 3 openapi_types.each_pair do |key, type|
  153. 9 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  154. transformed_hash["#{key}"] = nil
  155. 9 elsif type =~ /\AArray<(.*)>/i
  156. # check to ensure the input is an array given that the attribute
  157. # is documented as an array but the input is not
  158. if attributes[attribute_map[key]].is_a?(Array)
  159. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  160. end
  161. 9 elsif !attributes[attribute_map[key]].nil?
  162. 9 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  163. end
  164. end
  165. 3 new(transformed_hash)
  166. end
  167. # Returns the object in the form of hash
  168. # @return [Hash] Returns the object in the form of hash
  169. 1 def to_hash
  170. 6 hash = {}
  171. 6 self.class.attribute_map.each_pair do |attr, param|
  172. 18 value = self.send(attr)
  173. 18 if value.nil?
  174. is_nullable = self.class.openapi_nullable.include?(attr)
  175. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  176. end
  177. 18 hash[param] = _to_hash(value)
  178. end
  179. 6 hash
  180. end
  181. end
  182. end

lib/bandwidth-sdk/models/error_source.rb

87.14% lines covered

70 relevant lines. 61 lines covered and 9 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # Specifies relevant sources of the error, if any.
  13. 1 class ErrorSource < ApiModelBase
  14. # The relevant URI query parameter causing the error
  15. 1 attr_accessor :parameter
  16. # The request body field that led to the error
  17. 1 attr_accessor :field
  18. # The header field that contributed to the error
  19. 1 attr_accessor :header
  20. # A resource ID or path linked to the error
  21. 1 attr_accessor :reference
  22. # Attribute mapping from ruby-style variable name to JSON key.
  23. 1 def self.attribute_map
  24. 68 {
  25. :'parameter' => :'parameter',
  26. :'field' => :'field',
  27. :'header' => :'header',
  28. :'reference' => :'reference'
  29. }
  30. end
  31. # Returns attribute mapping this model knows about
  32. 1 def self.acceptable_attribute_map
  33. 17 attribute_map
  34. end
  35. # Returns all the JSON keys this model knows about
  36. 1 def self.acceptable_attributes
  37. 1 acceptable_attribute_map.values
  38. end
  39. # Attribute type mapping.
  40. 1 def self.openapi_types
  41. 4 {
  42. :'parameter' => :'String',
  43. :'field' => :'String',
  44. :'header' => :'String',
  45. :'reference' => :'String'
  46. }
  47. end
  48. # List of attributes with nullable: true
  49. 1 def self.openapi_nullable
  50. 15 Set.new([
  51. ])
  52. end
  53. # Initializes the object
  54. # @param [Hash] attributes Model attributes in the form of hash
  55. 1 def initialize(attributes = {})
  56. 17 if (!attributes.is_a?(Hash))
  57. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::ErrorSource` initialize method'
  58. end
  59. # check to see if the attribute exists and convert string to symbol for hash key
  60. 16 acceptable_attribute_map = self.class.acceptable_attribute_map
  61. 16 attributes = attributes.each_with_object({}) { |(k, v), h|
  62. 22 if (!acceptable_attribute_map.key?(k.to_sym))
  63. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ErrorSource`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  64. end
  65. 21 h[k.to_sym] = v
  66. }
  67. 15 if attributes.key?(:'parameter')
  68. 5 self.parameter = attributes[:'parameter']
  69. end
  70. 15 if attributes.key?(:'field')
  71. 8 self.field = attributes[:'field']
  72. end
  73. 15 if attributes.key?(:'header')
  74. 4 self.header = attributes[:'header']
  75. end
  76. 15 if attributes.key?(:'reference')
  77. 4 self.reference = attributes[:'reference']
  78. end
  79. end
  80. # Show invalid properties with the reasons. Usually used together with valid?
  81. # @return Array for valid properties with the reasons
  82. 1 def list_invalid_properties
  83. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  84. invalid_properties = Array.new
  85. invalid_properties
  86. end
  87. # Check to see if the all the properties in the model are valid
  88. # @return true if the model is valid
  89. 1 def valid?
  90. warn '[DEPRECATED] the `valid?` method is obsolete'
  91. true
  92. end
  93. # Checks equality by comparing each attribute.
  94. # @param [Object] Object to be compared
  95. 1 def ==(o)
  96. 3 return true if self.equal?(o)
  97. 2 self.class == o.class &&
  98. parameter == o.parameter &&
  99. field == o.field &&
  100. header == o.header &&
  101. reference == o.reference
  102. end
  103. # @see the `==` method
  104. # @param [Object] Object to be compared
  105. 1 def eql?(o)
  106. 2 self == o
  107. end
  108. # Calculates hash code according to all attributes.
  109. # @return [Integer] Hash code
  110. 1 def hash
  111. [parameter, field, header, reference].hash
  112. end
  113. # Builds the object from hash
  114. # @param [Hash] attributes Model attributes in the form of hash
  115. # @return [Object] Returns the model itself
  116. 1 def self.build_from_hash(attributes)
  117. 4 return nil unless attributes.is_a?(Hash)
  118. 4 attributes = attributes.transform_keys(&:to_sym)
  119. 4 transformed_hash = {}
  120. 4 openapi_types.each_pair do |key, type|
  121. 16 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  122. transformed_hash["#{key}"] = nil
  123. 16 elsif type =~ /\AArray<(.*)>/i
  124. # check to ensure the input is an array given that the attribute
  125. # is documented as an array but the input is not
  126. if attributes[attribute_map[key]].is_a?(Array)
  127. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  128. end
  129. 16 elsif !attributes[attribute_map[key]].nil?
  130. 6 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  131. end
  132. end
  133. 4 new(transformed_hash)
  134. end
  135. # Returns the object in the form of hash
  136. # @return [Hash] Returns the object in the form of hash
  137. 1 def to_hash
  138. 6 hash = {}
  139. 6 self.class.attribute_map.each_pair do |attr, param|
  140. 24 value = self.send(attr)
  141. 24 if value.nil?
  142. 14 is_nullable = self.class.openapi_nullable.include?(attr)
  143. 14 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  144. end
  145. 10 hash[param] = _to_hash(value)
  146. end
  147. 6 hash
  148. end
  149. end
  150. end

lib/bandwidth-sdk/models/failure_webhook.rb

80.61% lines covered

98 relevant lines. 79 lines covered and 19 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class FailureWebhook < ApiModelBase
  13. # User's account ID.
  14. 1 attr_accessor :account_id
  15. # Toll-free telephone number in E.164 format.
  16. 1 attr_accessor :phone_number
  17. # An error code indicating what error was encountered. This code can be interpreted as an HTTP status code in regards to the error that was encountered.
  18. 1 attr_accessor :error_code
  19. # A description of the error that was encountered.
  20. 1 attr_accessor :error_message
  21. # Details of the errors that were encountered when processing the request.
  22. 1 attr_accessor :errors
  23. # Unique identifier (UUID) generated by Bandwidth to assist in tracking the verification status of a toll-free number.
  24. 1 attr_accessor :internal_ticket_number
  25. # Attribute mapping from ruby-style variable name to JSON key.
  26. 1 def self.attribute_map
  27. 39 {
  28. :'account_id' => :'accountId',
  29. :'phone_number' => :'phoneNumber',
  30. :'error_code' => :'errorCode',
  31. :'error_message' => :'errorMessage',
  32. :'errors' => :'errors',
  33. :'internal_ticket_number' => :'internalTicketNumber'
  34. }
  35. end
  36. # Returns attribute mapping this model knows about
  37. 1 def self.acceptable_attribute_map
  38. 12 attribute_map
  39. end
  40. # Returns all the JSON keys this model knows about
  41. 1 def self.acceptable_attributes
  42. 1 acceptable_attribute_map.values
  43. end
  44. # Attribute type mapping.
  45. 1 def self.openapi_types
  46. 1 {
  47. :'account_id' => :'String',
  48. :'phone_number' => :'String',
  49. :'error_code' => :'String',
  50. :'error_message' => :'String',
  51. :'errors' => :'Array<String>',
  52. :'internal_ticket_number' => :'String'
  53. }
  54. end
  55. # List of attributes with nullable: true
  56. 1 def self.openapi_nullable
  57. 1 Set.new([
  58. ])
  59. end
  60. # Initializes the object
  61. # @param [Hash] attributes Model attributes in the form of hash
  62. 1 def initialize(attributes = {})
  63. 12 if (!attributes.is_a?(Hash))
  64. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::FailureWebhook` initialize method'
  65. end
  66. # check to see if the attribute exists and convert string to symbol for hash key
  67. 11 acceptable_attribute_map = self.class.acceptable_attribute_map
  68. 11 attributes = attributes.each_with_object({}) { |(k, v), h|
  69. 29 if (!acceptable_attribute_map.key?(k.to_sym))
  70. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::FailureWebhook`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  71. end
  72. 28 h[k.to_sym] = v
  73. }
  74. 10 if attributes.key?(:'account_id')
  75. 4 self.account_id = attributes[:'account_id']
  76. end
  77. 10 if attributes.key?(:'phone_number')
  78. 8 self.phone_number = attributes[:'phone_number']
  79. end
  80. 6 if attributes.key?(:'error_code')
  81. 4 self.error_code = attributes[:'error_code']
  82. end
  83. 6 if attributes.key?(:'error_message')
  84. 4 self.error_message = attributes[:'error_message']
  85. end
  86. 6 if attributes.key?(:'errors')
  87. 4 if (value = attributes[:'errors']).is_a?(Array)
  88. 4 self.errors = value
  89. end
  90. end
  91. 6 if attributes.key?(:'internal_ticket_number')
  92. 4 self.internal_ticket_number = attributes[:'internal_ticket_number']
  93. end
  94. end
  95. # Show invalid properties with the reasons. Usually used together with valid?
  96. # @return Array for valid properties with the reasons
  97. 1 def list_invalid_properties
  98. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  99. invalid_properties = Array.new
  100. if !@phone_number.nil? && @phone_number.to_s.length > 12
  101. invalid_properties.push('invalid value for "phone_number", the character length must be smaller than or equal to 12.')
  102. end
  103. if !@phone_number.nil? && @phone_number.to_s.length < 12
  104. invalid_properties.push('invalid value for "phone_number", the character length must be greater than or equal to 12.')
  105. end
  106. pattern = Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
  107. if !@phone_number.nil? && @phone_number !~ pattern
  108. invalid_properties.push("invalid value for \"phone_number\", must conform to the pattern #{pattern}.")
  109. end
  110. invalid_properties
  111. end
  112. # Check to see if the all the properties in the model are valid
  113. # @return true if the model is valid
  114. 1 def valid?
  115. warn '[DEPRECATED] the `valid?` method is obsolete'
  116. return false if !@phone_number.nil? && @phone_number.to_s.length > 12
  117. return false if !@phone_number.nil? && @phone_number.to_s.length < 12
  118. return false if !@phone_number.nil? && @phone_number !~ Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
  119. true
  120. end
  121. # Custom attribute writer method with validation
  122. # @param [Object] phone_number Value to be assigned
  123. 1 def phone_number=(phone_number)
  124. 8 if phone_number.nil?
  125. 1 fail ArgumentError, 'phone_number cannot be nil'
  126. end
  127. 7 if phone_number.to_s.length > 12
  128. 1 fail ArgumentError, 'invalid value for "phone_number", the character length must be smaller than or equal to 12.'
  129. end
  130. 6 if phone_number.to_s.length < 12
  131. 1 fail ArgumentError, 'invalid value for "phone_number", the character length must be greater than or equal to 12.'
  132. end
  133. 5 pattern = Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
  134. 5 if phone_number !~ pattern
  135. 1 fail ArgumentError, "invalid value for \"phone_number\", must conform to the pattern #{pattern}."
  136. end
  137. 4 @phone_number = phone_number
  138. end
  139. # Checks equality by comparing each attribute.
  140. # @param [Object] Object to be compared
  141. 1 def ==(o)
  142. 2 return true if self.equal?(o)
  143. 2 self.class == o.class &&
  144. account_id == o.account_id &&
  145. phone_number == o.phone_number &&
  146. error_code == o.error_code &&
  147. error_message == o.error_message &&
  148. errors == o.errors &&
  149. internal_ticket_number == o.internal_ticket_number
  150. end
  151. # @see the `==` method
  152. # @param [Object] Object to be compared
  153. 1 def eql?(o)
  154. 2 self == o
  155. end
  156. # Calculates hash code according to all attributes.
  157. # @return [Integer] Hash code
  158. 1 def hash
  159. [account_id, phone_number, error_code, error_message, errors, internal_ticket_number].hash
  160. end
  161. # Builds the object from hash
  162. # @param [Hash] attributes Model attributes in the form of hash
  163. # @return [Object] Returns the model itself
  164. 1 def self.build_from_hash(attributes)
  165. 1 return nil unless attributes.is_a?(Hash)
  166. 1 attributes = attributes.transform_keys(&:to_sym)
  167. 1 transformed_hash = {}
  168. 1 openapi_types.each_pair do |key, type|
  169. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  170. transformed_hash["#{key}"] = nil
  171. 6 elsif type =~ /\AArray<(.*)>/i
  172. # check to ensure the input is an array given that the attribute
  173. # is documented as an array but the input is not
  174. 1 if attributes[attribute_map[key]].is_a?(Array)
  175. 2 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  176. end
  177. 5 elsif !attributes[attribute_map[key]].nil?
  178. 5 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  179. end
  180. end
  181. 1 new(transformed_hash)
  182. end
  183. # Returns the object in the form of hash
  184. # @return [Hash] Returns the object in the form of hash
  185. 1 def to_hash
  186. 2 hash = {}
  187. 2 self.class.attribute_map.each_pair do |attr, param|
  188. 12 value = self.send(attr)
  189. 12 if value.nil?
  190. is_nullable = self.class.openapi_nullable.include?(attr)
  191. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  192. end
  193. 12 hash[param] = _to_hash(value)
  194. end
  195. 2 hash
  196. end
  197. end
  198. end

lib/bandwidth-sdk/models/field_error.rb

82.81% lines covered

64 relevant lines. 53 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class FieldError < ApiModelBase
  13. # The name of the field that contains the error
  14. 1 attr_accessor :field_name
  15. # The error associated with the field
  16. 1 attr_accessor :description
  17. # Attribute mapping from ruby-style variable name to JSON key.
  18. 1 def self.attribute_map
  19. 33 {
  20. :'field_name' => :'fieldName',
  21. :'description' => :'description'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 12 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 1 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 2 {
  35. :'field_name' => :'String',
  36. :'description' => :'String'
  37. }
  38. end
  39. # List of attributes with nullable: true
  40. 1 def self.openapi_nullable
  41. 1 Set.new([
  42. ])
  43. end
  44. # Initializes the object
  45. # @param [Hash] attributes Model attributes in the form of hash
  46. 1 def initialize(attributes = {})
  47. 12 if (!attributes.is_a?(Hash))
  48. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::FieldError` initialize method'
  49. end
  50. # check to see if the attribute exists and convert string to symbol for hash key
  51. 11 acceptable_attribute_map = self.class.acceptable_attribute_map
  52. 11 attributes = attributes.each_with_object({}) { |(k, v), h|
  53. 17 if (!acceptable_attribute_map.key?(k.to_sym))
  54. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::FieldError`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  55. end
  56. 16 h[k.to_sym] = v
  57. }
  58. 10 if attributes.key?(:'field_name')
  59. 8 self.field_name = attributes[:'field_name']
  60. end
  61. 10 if attributes.key?(:'description')
  62. 8 self.description = attributes[:'description']
  63. end
  64. end
  65. # Show invalid properties with the reasons. Usually used together with valid?
  66. # @return Array for valid properties with the reasons
  67. 1 def list_invalid_properties
  68. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  69. invalid_properties = Array.new
  70. invalid_properties
  71. end
  72. # Check to see if the all the properties in the model are valid
  73. # @return true if the model is valid
  74. 1 def valid?
  75. warn '[DEPRECATED] the `valid?` method is obsolete'
  76. true
  77. end
  78. # Checks equality by comparing each attribute.
  79. # @param [Object] Object to be compared
  80. 1 def ==(o)
  81. 2 return true if self.equal?(o)
  82. 2 self.class == o.class &&
  83. field_name == o.field_name &&
  84. description == o.description
  85. end
  86. # @see the `==` method
  87. # @param [Object] Object to be compared
  88. 1 def eql?(o)
  89. 2 self == o
  90. end
  91. # Calculates hash code according to all attributes.
  92. # @return [Integer] Hash code
  93. 1 def hash
  94. [field_name, description].hash
  95. end
  96. # Builds the object from hash
  97. # @param [Hash] attributes Model attributes in the form of hash
  98. # @return [Object] Returns the model itself
  99. 1 def self.build_from_hash(attributes)
  100. 2 return nil unless attributes.is_a?(Hash)
  101. 2 attributes = attributes.transform_keys(&:to_sym)
  102. 2 transformed_hash = {}
  103. 2 openapi_types.each_pair do |key, type|
  104. 4 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  105. transformed_hash["#{key}"] = nil
  106. 4 elsif type =~ /\AArray<(.*)>/i
  107. # check to ensure the input is an array given that the attribute
  108. # is documented as an array but the input is not
  109. if attributes[attribute_map[key]].is_a?(Array)
  110. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  111. end
  112. 4 elsif !attributes[attribute_map[key]].nil?
  113. 4 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  114. end
  115. end
  116. 2 new(transformed_hash)
  117. end
  118. # Returns the object in the form of hash
  119. # @return [Hash] Returns the object in the form of hash
  120. 1 def to_hash
  121. 4 hash = {}
  122. 4 self.class.attribute_map.each_pair do |attr, param|
  123. 8 value = self.send(attr)
  124. 8 if value.nil?
  125. is_nullable = self.class.openapi_nullable.include?(attr)
  126. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  127. end
  128. 8 hash[param] = _to_hash(value)
  129. end
  130. 4 hash
  131. end
  132. end
  133. end

lib/bandwidth-sdk/models/file_format_enum.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class FileFormatEnum
  13. 1 MP3 = 'mp3'.freeze
  14. 1 WAV = 'wav'.freeze
  15. 1 def self.all_vars
  16. 18 @all_vars ||= [MP3, WAV].freeze
  17. end
  18. # Builds the enum from string
  19. # @param [String] The enum value in the form of the string
  20. # @return [String] The enum value
  21. 1 def self.build_from_hash(value)
  22. 13 new.build_from_hash(value)
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def build_from_hash(value)
  28. 13 return value if FileFormatEnum.all_vars.include?(value)
  29. 1 raise "Invalid ENUM value #{value} for class #FileFormatEnum"
  30. end
  31. end
  32. end

lib/bandwidth-sdk/models/gather_callback.rb

86.18% lines covered

123 relevant lines. 106 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The gather event is sent after a <Gather> verb is executed. Its purpose is to report the gathered digits to the calling application.
  13. 1 class GatherCallback < ApiModelBase
  14. # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect.
  15. 1 attr_accessor :event_type
  16. # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.
  17. 1 attr_accessor :event_time
  18. # The user account associated with the call.
  19. 1 attr_accessor :account_id
  20. # The id of the application associated with the call.
  21. 1 attr_accessor :application_id
  22. # The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555).
  23. 1 attr_accessor :from
  24. # The phone number that received the call, in E.164 format (e.g. +15555555555).
  25. 1 attr_accessor :to
  26. 1 attr_accessor :direction
  27. # The call id associated with the event.
  28. 1 attr_accessor :call_id
  29. # (optional) The digits, letters, and/or symbols entered by the user. The string is empty if a timeout occurred before any buttons were pressed.
  30. 1 attr_accessor :digits
  31. # The URL of the call associated with the event.
  32. 1 attr_accessor :call_url
  33. # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format.
  34. 1 attr_accessor :enqueued_time
  35. # Time the call was started, in ISO 8601 format.
  36. 1 attr_accessor :start_time
  37. # Time the call was answered, in ISO 8601 format.
  38. 1 attr_accessor :answer_time
  39. # (optional) If the event is related to the B leg of a <Transfer>, the call id of the original call leg that executed the <Transfer>. Otherwise, this field will not be present.
  40. 1 attr_accessor :parent_call_id
  41. # (optional) The digit the user pressed to end the gather. Empty string value if no terminating digit was pressed.
  42. 1 attr_accessor :terminating_digit
  43. # The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555).
  44. 1 attr_accessor :transfer_caller_id
  45. # The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555).
  46. 1 attr_accessor :transfer_to
  47. # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.
  48. 1 attr_accessor :tag
  49. 1 class EnumAttributeValidator
  50. 1 attr_reader :datatype
  51. 1 attr_reader :allowable_values
  52. 1 def initialize(datatype, allowable_values)
  53. @allowable_values = allowable_values.map do |value|
  54. case datatype.to_s
  55. when /Integer/i
  56. value.to_i
  57. when /Float/i
  58. value.to_f
  59. else
  60. value
  61. end
  62. end
  63. end
  64. 1 def valid?(value)
  65. !value || allowable_values.include?(value)
  66. end
  67. end
  68. # Attribute mapping from ruby-style variable name to JSON key.
  69. 1 def self.attribute_map
  70. 83 {
  71. :'event_type' => :'eventType',
  72. :'event_time' => :'eventTime',
  73. :'account_id' => :'accountId',
  74. :'application_id' => :'applicationId',
  75. :'from' => :'from',
  76. :'to' => :'to',
  77. :'direction' => :'direction',
  78. :'call_id' => :'callId',
  79. :'digits' => :'digits',
  80. :'call_url' => :'callUrl',
  81. :'enqueued_time' => :'enqueuedTime',
  82. :'start_time' => :'startTime',
  83. :'answer_time' => :'answerTime',
  84. :'parent_call_id' => :'parentCallId',
  85. :'terminating_digit' => :'terminatingDigit',
  86. :'transfer_caller_id' => :'transferCallerId',
  87. :'transfer_to' => :'transferTo',
  88. :'tag' => :'tag'
  89. }
  90. end
  91. # Returns attribute mapping this model knows about
  92. 1 def self.acceptable_attribute_map
  93. 8 attribute_map
  94. end
  95. # Returns all the JSON keys this model knows about
  96. 1 def self.acceptable_attributes
  97. 1 acceptable_attribute_map.values
  98. end
  99. # Attribute type mapping.
  100. 1 def self.openapi_types
  101. 1 {
  102. :'event_type' => :'String',
  103. :'event_time' => :'Time',
  104. :'account_id' => :'String',
  105. :'application_id' => :'String',
  106. :'from' => :'String',
  107. :'to' => :'String',
  108. :'direction' => :'CallDirectionEnum',
  109. :'call_id' => :'String',
  110. :'digits' => :'String',
  111. :'call_url' => :'String',
  112. :'enqueued_time' => :'Time',
  113. :'start_time' => :'Time',
  114. :'answer_time' => :'Time',
  115. :'parent_call_id' => :'String',
  116. :'terminating_digit' => :'String',
  117. :'transfer_caller_id' => :'String',
  118. :'transfer_to' => :'String',
  119. :'tag' => :'String'
  120. }
  121. end
  122. # List of attributes with nullable: true
  123. 1 def self.openapi_nullable
  124. 1 Set.new([
  125. :'enqueued_time',
  126. :'answer_time',
  127. :'tag'
  128. ])
  129. end
  130. # Initializes the object
  131. # @param [Hash] attributes Model attributes in the form of hash
  132. 1 def initialize(attributes = {})
  133. 8 if (!attributes.is_a?(Hash))
  134. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::GatherCallback` initialize method'
  135. end
  136. # check to see if the attribute exists and convert string to symbol for hash key
  137. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  138. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  139. 73 if (!acceptable_attribute_map.key?(k.to_sym))
  140. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::GatherCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  141. end
  142. 72 h[k.to_sym] = v
  143. }
  144. 6 if attributes.key?(:'event_type')
  145. 4 self.event_type = attributes[:'event_type']
  146. end
  147. 6 if attributes.key?(:'event_time')
  148. 4 self.event_time = attributes[:'event_time']
  149. end
  150. 6 if attributes.key?(:'account_id')
  151. 4 self.account_id = attributes[:'account_id']
  152. end
  153. 6 if attributes.key?(:'application_id')
  154. 4 self.application_id = attributes[:'application_id']
  155. end
  156. 6 if attributes.key?(:'from')
  157. 4 self.from = attributes[:'from']
  158. end
  159. 6 if attributes.key?(:'to')
  160. 4 self.to = attributes[:'to']
  161. end
  162. 6 if attributes.key?(:'direction')
  163. 4 self.direction = attributes[:'direction']
  164. end
  165. 6 if attributes.key?(:'call_id')
  166. 4 self.call_id = attributes[:'call_id']
  167. end
  168. 6 if attributes.key?(:'digits')
  169. 4 self.digits = attributes[:'digits']
  170. end
  171. 6 if attributes.key?(:'call_url')
  172. 4 self.call_url = attributes[:'call_url']
  173. end
  174. 6 if attributes.key?(:'enqueued_time')
  175. 4 self.enqueued_time = attributes[:'enqueued_time']
  176. end
  177. 6 if attributes.key?(:'start_time')
  178. 4 self.start_time = attributes[:'start_time']
  179. end
  180. 6 if attributes.key?(:'answer_time')
  181. 4 self.answer_time = attributes[:'answer_time']
  182. end
  183. 6 if attributes.key?(:'parent_call_id')
  184. 4 self.parent_call_id = attributes[:'parent_call_id']
  185. end
  186. 6 if attributes.key?(:'terminating_digit')
  187. 4 self.terminating_digit = attributes[:'terminating_digit']
  188. end
  189. 6 if attributes.key?(:'transfer_caller_id')
  190. 4 self.transfer_caller_id = attributes[:'transfer_caller_id']
  191. end
  192. 6 if attributes.key?(:'transfer_to')
  193. 4 self.transfer_to = attributes[:'transfer_to']
  194. end
  195. 6 if attributes.key?(:'tag')
  196. 4 self.tag = attributes[:'tag']
  197. end
  198. end
  199. # Show invalid properties with the reasons. Usually used together with valid?
  200. # @return Array for valid properties with the reasons
  201. 1 def list_invalid_properties
  202. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  203. invalid_properties = Array.new
  204. invalid_properties
  205. end
  206. # Check to see if the all the properties in the model are valid
  207. # @return true if the model is valid
  208. 1 def valid?
  209. warn '[DEPRECATED] the `valid?` method is obsolete'
  210. true
  211. end
  212. # Checks equality by comparing each attribute.
  213. # @param [Object] Object to be compared
  214. 1 def ==(o)
  215. 2 return true if self.equal?(o)
  216. 2 self.class == o.class &&
  217. event_type == o.event_type &&
  218. event_time == o.event_time &&
  219. account_id == o.account_id &&
  220. application_id == o.application_id &&
  221. from == o.from &&
  222. to == o.to &&
  223. direction == o.direction &&
  224. call_id == o.call_id &&
  225. digits == o.digits &&
  226. call_url == o.call_url &&
  227. enqueued_time == o.enqueued_time &&
  228. start_time == o.start_time &&
  229. answer_time == o.answer_time &&
  230. parent_call_id == o.parent_call_id &&
  231. terminating_digit == o.terminating_digit &&
  232. transfer_caller_id == o.transfer_caller_id &&
  233. transfer_to == o.transfer_to &&
  234. tag == o.tag
  235. end
  236. # @see the `==` method
  237. # @param [Object] Object to be compared
  238. 1 def eql?(o)
  239. 2 self == o
  240. end
  241. # Calculates hash code according to all attributes.
  242. # @return [Integer] Hash code
  243. 1 def hash
  244. [event_type, event_time, account_id, application_id, from, to, direction, call_id, digits, call_url, enqueued_time, start_time, answer_time, parent_call_id, terminating_digit, transfer_caller_id, transfer_to, tag].hash
  245. end
  246. # Builds the object from hash
  247. # @param [Hash] attributes Model attributes in the form of hash
  248. # @return [Object] Returns the model itself
  249. 1 def self.build_from_hash(attributes)
  250. 1 return nil unless attributes.is_a?(Hash)
  251. 1 attributes = attributes.transform_keys(&:to_sym)
  252. 1 transformed_hash = {}
  253. 1 openapi_types.each_pair do |key, type|
  254. 18 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  255. transformed_hash["#{key}"] = nil
  256. 18 elsif type =~ /\AArray<(.*)>/i
  257. # check to ensure the input is an array given that the attribute
  258. # is documented as an array but the input is not
  259. if attributes[attribute_map[key]].is_a?(Array)
  260. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  261. end
  262. 18 elsif !attributes[attribute_map[key]].nil?
  263. 18 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  264. end
  265. end
  266. 1 new(transformed_hash)
  267. end
  268. # Returns the object in the form of hash
  269. # @return [Hash] Returns the object in the form of hash
  270. 1 def to_hash
  271. 2 hash = {}
  272. 2 self.class.attribute_map.each_pair do |attr, param|
  273. 36 value = self.send(attr)
  274. 36 if value.nil?
  275. is_nullable = self.class.openapi_nullable.include?(attr)
  276. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  277. end
  278. 36 hash[param] = _to_hash(value)
  279. end
  280. 2 hash
  281. end
  282. end
  283. end

lib/bandwidth-sdk/models/get_async_bulk_lookup_response.rb

86.96% lines covered

69 relevant lines. 60 lines covered and 9 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class GetAsyncBulkLookupResponse < ApiModelBase
  13. 1 attr_accessor :links
  14. 1 attr_accessor :data
  15. 1 attr_accessor :errors
  16. # Attribute mapping from ruby-style variable name to JSON key.
  17. 1 def self.attribute_map
  18. 36 {
  19. :'links' => :'links',
  20. :'data' => :'data',
  21. :'errors' => :'errors'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 9 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 1 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 2 {
  35. :'links' => :'Array<LinkSchema>',
  36. :'data' => :'GetAsyncBulkLookupResponseData',
  37. :'errors' => :'Array<LookupErrorSchema>'
  38. }
  39. end
  40. # List of attributes with nullable: true
  41. 1 def self.openapi_nullable
  42. 1 Set.new([
  43. ])
  44. end
  45. # Initializes the object
  46. # @param [Hash] attributes Model attributes in the form of hash
  47. 1 def initialize(attributes = {})
  48. 9 if (!attributes.is_a?(Hash))
  49. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::GetAsyncBulkLookupResponse` initialize method'
  50. end
  51. # check to see if the attribute exists and convert string to symbol for hash key
  52. 8 acceptable_attribute_map = self.class.acceptable_attribute_map
  53. 8 attributes = attributes.each_with_object({}) { |(k, v), h|
  54. 16 if (!acceptable_attribute_map.key?(k.to_sym))
  55. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::GetAsyncBulkLookupResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  56. end
  57. 15 h[k.to_sym] = v
  58. }
  59. 7 if attributes.key?(:'links')
  60. 5 if (value = attributes[:'links']).is_a?(Array)
  61. 5 self.links = value
  62. end
  63. end
  64. 7 if attributes.key?(:'data')
  65. 5 self.data = attributes[:'data']
  66. end
  67. 7 if attributes.key?(:'errors')
  68. 5 if (value = attributes[:'errors']).is_a?(Array)
  69. 5 self.errors = value
  70. end
  71. end
  72. end
  73. # Show invalid properties with the reasons. Usually used together with valid?
  74. # @return Array for valid properties with the reasons
  75. 1 def list_invalid_properties
  76. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  77. invalid_properties = Array.new
  78. invalid_properties
  79. end
  80. # Check to see if the all the properties in the model are valid
  81. # @return true if the model is valid
  82. 1 def valid?
  83. warn '[DEPRECATED] the `valid?` method is obsolete'
  84. true
  85. end
  86. # Checks equality by comparing each attribute.
  87. # @param [Object] Object to be compared
  88. 1 def ==(o)
  89. 2 return true if self.equal?(o)
  90. 2 self.class == o.class &&
  91. links == o.links &&
  92. data == o.data &&
  93. errors == o.errors
  94. end
  95. # @see the `==` method
  96. # @param [Object] Object to be compared
  97. 1 def eql?(o)
  98. 2 self == o
  99. end
  100. # Calculates hash code according to all attributes.
  101. # @return [Integer] Hash code
  102. 1 def hash
  103. [links, data, errors].hash
  104. end
  105. # Builds the object from hash
  106. # @param [Hash] attributes Model attributes in the form of hash
  107. # @return [Object] Returns the model itself
  108. 1 def self.build_from_hash(attributes)
  109. 2 return nil unless attributes.is_a?(Hash)
  110. 2 attributes = attributes.transform_keys(&:to_sym)
  111. 2 transformed_hash = {}
  112. 2 openapi_types.each_pair do |key, type|
  113. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  114. transformed_hash["#{key}"] = nil
  115. 6 elsif type =~ /\AArray<(.*)>/i
  116. # check to ensure the input is an array given that the attribute
  117. # is documented as an array but the input is not
  118. 4 if attributes[attribute_map[key]].is_a?(Array)
  119. 6 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  120. end
  121. 2 elsif !attributes[attribute_map[key]].nil?
  122. 2 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  123. end
  124. end
  125. 2 new(transformed_hash)
  126. end
  127. # Returns the object in the form of hash
  128. # @return [Hash] Returns the object in the form of hash
  129. 1 def to_hash
  130. 2 hash = {}
  131. 2 self.class.attribute_map.each_pair do |attr, param|
  132. 6 value = self.send(attr)
  133. 6 if value.nil?
  134. is_nullable = self.class.openapi_nullable.include?(attr)
  135. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  136. end
  137. 6 hash[param] = _to_hash(value)
  138. end
  139. 2 hash
  140. end
  141. end
  142. end

lib/bandwidth-sdk/models/get_async_bulk_lookup_response_data.rb

83.54% lines covered

79 relevant lines. 66 lines covered and 13 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The phone number lookup response data
  13. 1 class GetAsyncBulkLookupResponseData < ApiModelBase
  14. # The phone number lookup request ID from Bandwidth.
  15. 1 attr_accessor :request_id
  16. 1 attr_accessor :status
  17. # The carrier information results for the specified telephone number.
  18. 1 attr_accessor :results
  19. 1 class EnumAttributeValidator
  20. 1 attr_reader :datatype
  21. 1 attr_reader :allowable_values
  22. 1 def initialize(datatype, allowable_values)
  23. @allowable_values = allowable_values.map do |value|
  24. case datatype.to_s
  25. when /Integer/i
  26. value.to_i
  27. when /Float/i
  28. value.to_f
  29. else
  30. value
  31. end
  32. end
  33. end
  34. 1 def valid?(value)
  35. !value || allowable_values.include?(value)
  36. end
  37. end
  38. # Attribute mapping from ruby-style variable name to JSON key.
  39. 1 def self.attribute_map
  40. 50 {
  41. :'request_id' => :'requestId',
  42. :'status' => :'status',
  43. :'results' => :'results'
  44. }
  45. end
  46. # Returns attribute mapping this model knows about
  47. 1 def self.acceptable_attribute_map
  48. 13 attribute_map
  49. end
  50. # Returns all the JSON keys this model knows about
  51. 1 def self.acceptable_attributes
  52. 1 acceptable_attribute_map.values
  53. end
  54. # Attribute type mapping.
  55. 1 def self.openapi_types
  56. 3 {
  57. :'request_id' => :'String',
  58. :'status' => :'InProgressLookupStatusEnum',
  59. :'results' => :'Array<LookupResult>'
  60. }
  61. end
  62. # List of attributes with nullable: true
  63. 1 def self.openapi_nullable
  64. 5 Set.new([
  65. ])
  66. end
  67. # Initializes the object
  68. # @param [Hash] attributes Model attributes in the form of hash
  69. 1 def initialize(attributes = {})
  70. 13 if (!attributes.is_a?(Hash))
  71. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::GetAsyncBulkLookupResponseData` initialize method'
  72. end
  73. # check to see if the attribute exists and convert string to symbol for hash key
  74. 12 acceptable_attribute_map = self.class.acceptable_attribute_map
  75. 12 attributes = attributes.each_with_object({}) { |(k, v), h|
  76. 20 if (!acceptable_attribute_map.key?(k.to_sym))
  77. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::GetAsyncBulkLookupResponseData`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  78. end
  79. 19 h[k.to_sym] = v
  80. }
  81. 11 if attributes.key?(:'request_id')
  82. 9 self.request_id = attributes[:'request_id']
  83. end
  84. 11 if attributes.key?(:'status')
  85. 5 self.status = attributes[:'status']
  86. end
  87. 11 if attributes.key?(:'results')
  88. 5 if (value = attributes[:'results']).is_a?(Array)
  89. 5 self.results = value
  90. end
  91. end
  92. end
  93. # Show invalid properties with the reasons. Usually used together with valid?
  94. # @return Array for valid properties with the reasons
  95. 1 def list_invalid_properties
  96. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  97. invalid_properties = Array.new
  98. invalid_properties
  99. end
  100. # Check to see if the all the properties in the model are valid
  101. # @return true if the model is valid
  102. 1 def valid?
  103. warn '[DEPRECATED] the `valid?` method is obsolete'
  104. true
  105. end
  106. # Checks equality by comparing each attribute.
  107. # @param [Object] Object to be compared
  108. 1 def ==(o)
  109. 2 return true if self.equal?(o)
  110. 2 self.class == o.class &&
  111. request_id == o.request_id &&
  112. status == o.status &&
  113. results == o.results
  114. end
  115. # @see the `==` method
  116. # @param [Object] Object to be compared
  117. 1 def eql?(o)
  118. 2 self == o
  119. end
  120. # Calculates hash code according to all attributes.
  121. # @return [Integer] Hash code
  122. 1 def hash
  123. [request_id, status, results].hash
  124. end
  125. # Builds the object from hash
  126. # @param [Hash] attributes Model attributes in the form of hash
  127. # @return [Object] Returns the model itself
  128. 1 def self.build_from_hash(attributes)
  129. 3 return nil unless attributes.is_a?(Hash)
  130. 3 attributes = attributes.transform_keys(&:to_sym)
  131. 3 transformed_hash = {}
  132. 3 openapi_types.each_pair do |key, type|
  133. 9 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  134. transformed_hash["#{key}"] = nil
  135. 9 elsif type =~ /\AArray<(.*)>/i
  136. # check to ensure the input is an array given that the attribute
  137. # is documented as an array but the input is not
  138. 3 if attributes[attribute_map[key]].is_a?(Array)
  139. 7 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  140. end
  141. 6 elsif !attributes[attribute_map[key]].nil?
  142. 5 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  143. end
  144. end
  145. 3 new(transformed_hash)
  146. end
  147. # Returns the object in the form of hash
  148. # @return [Hash] Returns the object in the form of hash
  149. 1 def to_hash
  150. 4 hash = {}
  151. 4 self.class.attribute_map.each_pair do |attr, param|
  152. 12 value = self.send(attr)
  153. 12 if value.nil?
  154. 4 is_nullable = self.class.openapi_nullable.include?(attr)
  155. 4 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  156. end
  157. 8 hash[param] = _to_hash(value)
  158. end
  159. 4 hash
  160. end
  161. end
  162. end

lib/bandwidth-sdk/models/in_progress_lookup_status_enum.rb

100.0% lines covered

15 relevant lines. 15 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class InProgressLookupStatusEnum
  13. 1 IN_PROGRESS = 'IN_PROGRESS'.freeze
  14. 1 COMPLETE = 'COMPLETE'.freeze
  15. 1 PARTIAL_COMPLETE = 'PARTIAL_COMPLETE'.freeze
  16. 1 FAILED = 'FAILED'.freeze
  17. 1 def self.all_vars
  18. 11 @all_vars ||= [IN_PROGRESS, COMPLETE, PARTIAL_COMPLETE, FAILED].freeze
  19. end
  20. # Builds the enum from string
  21. # @param [String] The enum value in the form of the string
  22. # @return [String] The enum value
  23. 1 def self.build_from_hash(value)
  24. 10 new.build_from_hash(value)
  25. end
  26. # Builds the enum from string
  27. # @param [String] The enum value in the form of the string
  28. # @return [String] The enum value
  29. 1 def build_from_hash(value)
  30. 10 return value if InProgressLookupStatusEnum.all_vars.include?(value)
  31. 1 raise "Invalid ENUM value #{value} for class #InProgressLookupStatusEnum"
  32. end
  33. end
  34. end

lib/bandwidth-sdk/models/inbound_callback.rb

70.87% lines covered

127 relevant lines. 90 lines covered and 37 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # Represents an inbound callback.
  13. 1 class InboundCallback < ApiModelBase
  14. 1 attr_accessor :time
  15. 1 attr_accessor :type
  16. # The destination phone number the message was sent to. For inbound callbacks, this is the Bandwidth number or alphanumeric identifier that received the message.
  17. 1 attr_accessor :to
  18. # A detailed description of the event described by the callback.
  19. 1 attr_accessor :description
  20. 1 attr_accessor :message
  21. # The name of the Authorized Message Provider (AMP) that handled this message. In the US, this is the carrier that the message was sent to. This field is present only when this account feature has been enabled.
  22. 1 attr_accessor :carrier_name
  23. 1 class EnumAttributeValidator
  24. 1 attr_reader :datatype
  25. 1 attr_reader :allowable_values
  26. 1 def initialize(datatype, allowable_values)
  27. @allowable_values = allowable_values.map do |value|
  28. case datatype.to_s
  29. when /Integer/i
  30. value.to_i
  31. when /Float/i
  32. value.to_f
  33. else
  34. value
  35. end
  36. end
  37. end
  38. 1 def valid?(value)
  39. !value || allowable_values.include?(value)
  40. end
  41. end
  42. # Attribute mapping from ruby-style variable name to JSON key.
  43. 1 def self.attribute_map
  44. 40 {
  45. :'time' => :'time',
  46. :'type' => :'type',
  47. :'to' => :'to',
  48. :'description' => :'description',
  49. :'message' => :'message',
  50. :'carrier_name' => :'carrierName'
  51. }
  52. end
  53. # Returns attribute mapping this model knows about
  54. 1 def self.acceptable_attribute_map
  55. 13 attribute_map
  56. end
  57. # Returns all the JSON keys this model knows about
  58. 1 def self.acceptable_attributes
  59. 1 acceptable_attribute_map.values
  60. end
  61. # Attribute type mapping.
  62. 1 def self.openapi_types
  63. 1 {
  64. :'time' => :'Time',
  65. :'type' => :'InboundCallbackTypeEnum',
  66. :'to' => :'String',
  67. :'description' => :'String',
  68. :'message' => :'InboundCallbackMessage',
  69. :'carrier_name' => :'String'
  70. }
  71. end
  72. # List of attributes with nullable: true
  73. 1 def self.openapi_nullable
  74. 1 Set.new([
  75. ])
  76. end
  77. # Initializes the object
  78. # @param [Hash] attributes Model attributes in the form of hash
  79. 1 def initialize(attributes = {})
  80. 13 if (!attributes.is_a?(Hash))
  81. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::InboundCallback` initialize method'
  82. end
  83. # check to see if the attribute exists and convert string to symbol for hash key
  84. 12 acceptable_attribute_map = self.class.acceptable_attribute_map
  85. 12 attributes = attributes.each_with_object({}) { |(k, v), h|
  86. 65 if (!acceptable_attribute_map.key?(k.to_sym))
  87. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::InboundCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  88. end
  89. 64 h[k.to_sym] = v
  90. }
  91. 11 if attributes.key?(:'time')
  92. 11 self.time = attributes[:'time']
  93. else
  94. self.time = nil
  95. end
  96. 11 if attributes.key?(:'type')
  97. 11 self.type = attributes[:'type']
  98. else
  99. self.type = nil
  100. end
  101. 11 if attributes.key?(:'to')
  102. 11 self.to = attributes[:'to']
  103. else
  104. self.to = nil
  105. end
  106. 11 if attributes.key?(:'description')
  107. 11 self.description = attributes[:'description']
  108. else
  109. self.description = nil
  110. end
  111. 11 if attributes.key?(:'message')
  112. 11 self.message = attributes[:'message']
  113. else
  114. self.message = nil
  115. end
  116. 11 if attributes.key?(:'carrier_name')
  117. 9 self.carrier_name = attributes[:'carrier_name']
  118. end
  119. end
  120. # Show invalid properties with the reasons. Usually used together with valid?
  121. # @return Array for valid properties with the reasons
  122. 1 def list_invalid_properties
  123. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  124. invalid_properties = Array.new
  125. if @time.nil?
  126. invalid_properties.push('invalid value for "time", time cannot be nil.')
  127. end
  128. if @type.nil?
  129. invalid_properties.push('invalid value for "type", type cannot be nil.')
  130. end
  131. if @to.nil?
  132. invalid_properties.push('invalid value for "to", to cannot be nil.')
  133. end
  134. if @description.nil?
  135. invalid_properties.push('invalid value for "description", description cannot be nil.')
  136. end
  137. if @message.nil?
  138. invalid_properties.push('invalid value for "message", message cannot be nil.')
  139. end
  140. invalid_properties
  141. end
  142. # Check to see if the all the properties in the model are valid
  143. # @return true if the model is valid
  144. 1 def valid?
  145. warn '[DEPRECATED] the `valid?` method is obsolete'
  146. return false if @time.nil?
  147. return false if @type.nil?
  148. return false if @to.nil?
  149. return false if @description.nil?
  150. return false if @message.nil?
  151. true
  152. end
  153. # Custom attribute writer method with validation
  154. # @param [Object] time Value to be assigned
  155. 1 def time=(time)
  156. 12 if time.nil?
  157. 1 fail ArgumentError, 'time cannot be nil'
  158. end
  159. 11 @time = time
  160. end
  161. # Custom attribute writer method with validation
  162. # @param [Object] type Value to be assigned
  163. 1 def type=(type)
  164. 12 if type.nil?
  165. 1 fail ArgumentError, 'type cannot be nil'
  166. end
  167. 11 @type = type
  168. end
  169. # Custom attribute writer method with validation
  170. # @param [Object] to Value to be assigned
  171. 1 def to=(to)
  172. 12 if to.nil?
  173. 1 fail ArgumentError, 'to cannot be nil'
  174. end
  175. 11 @to = to
  176. end
  177. # Custom attribute writer method with validation
  178. # @param [Object] description Value to be assigned
  179. 1 def description=(description)
  180. 12 if description.nil?
  181. 1 fail ArgumentError, 'description cannot be nil'
  182. end
  183. 11 @description = description
  184. end
  185. # Custom attribute writer method with validation
  186. # @param [Object] message Value to be assigned
  187. 1 def message=(message)
  188. 12 if message.nil?
  189. 1 fail ArgumentError, 'message cannot be nil'
  190. end
  191. 11 @message = message
  192. end
  193. # Checks equality by comparing each attribute.
  194. # @param [Object] Object to be compared
  195. 1 def ==(o)
  196. 2 return true if self.equal?(o)
  197. 2 self.class == o.class &&
  198. time == o.time &&
  199. type == o.type &&
  200. to == o.to &&
  201. description == o.description &&
  202. message == o.message &&
  203. carrier_name == o.carrier_name
  204. end
  205. # @see the `==` method
  206. # @param [Object] Object to be compared
  207. 1 def eql?(o)
  208. 2 self == o
  209. end
  210. # Calculates hash code according to all attributes.
  211. # @return [Integer] Hash code
  212. 1 def hash
  213. [time, type, to, description, message, carrier_name].hash
  214. end
  215. # Builds the object from hash
  216. # @param [Hash] attributes Model attributes in the form of hash
  217. # @return [Object] Returns the model itself
  218. 1 def self.build_from_hash(attributes)
  219. 1 return nil unless attributes.is_a?(Hash)
  220. 1 attributes = attributes.transform_keys(&:to_sym)
  221. 1 transformed_hash = {}
  222. 1 openapi_types.each_pair do |key, type|
  223. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  224. transformed_hash["#{key}"] = nil
  225. 6 elsif type =~ /\AArray<(.*)>/i
  226. # check to ensure the input is an array given that the attribute
  227. # is documented as an array but the input is not
  228. if attributes[attribute_map[key]].is_a?(Array)
  229. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  230. end
  231. 6 elsif !attributes[attribute_map[key]].nil?
  232. 6 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  233. end
  234. end
  235. 1 new(transformed_hash)
  236. end
  237. # Returns the object in the form of hash
  238. # @return [Hash] Returns the object in the form of hash
  239. 1 def to_hash
  240. 2 hash = {}
  241. 2 self.class.attribute_map.each_pair do |attr, param|
  242. 12 value = self.send(attr)
  243. 12 if value.nil?
  244. is_nullable = self.class.openapi_nullable.include?(attr)
  245. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  246. end
  247. 12 hash[param] = _to_hash(value)
  248. end
  249. 2 hash
  250. end
  251. end
  252. end

lib/bandwidth-sdk/models/inbound_callback_message.rb

73.51% lines covered

185 relevant lines. 136 lines covered and 49 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class InboundCallbackMessage < ApiModelBase
  13. # A unique identifier of the message.
  14. 1 attr_accessor :id
  15. # The Bandwidth phone number or alphanumeric identifier associated with the message.
  16. 1 attr_accessor :owner
  17. # The ID of the Application your from number or senderId is associated with in the Bandwidth App.
  18. 1 attr_accessor :application_id
  19. 1 attr_accessor :time
  20. # The number of segments the user's message is broken into before sending over carrier networks.
  21. 1 attr_accessor :segment_count
  22. 1 attr_accessor :direction
  23. # The phone number recipients of the message.
  24. 1 attr_accessor :to
  25. # The Bandwidth phone number or alphanumeric identifier the message was sent from.
  26. 1 attr_accessor :from
  27. 1 attr_accessor :text
  28. # A custom string that will be included in callback events of the message. Max 1024 characters.
  29. 1 attr_accessor :tag
  30. # Optional media, not applicable for sms
  31. 1 attr_accessor :media
  32. 1 attr_accessor :priority
  33. 1 attr_accessor :channel
  34. 1 attr_accessor :content
  35. 1 attr_accessor :suggestion_response
  36. 1 attr_accessor :location_response
  37. 1 class EnumAttributeValidator
  38. 1 attr_reader :datatype
  39. 1 attr_reader :allowable_values
  40. 1 def initialize(datatype, allowable_values)
  41. @allowable_values = allowable_values.map do |value|
  42. case datatype.to_s
  43. when /Integer/i
  44. value.to_i
  45. when /Float/i
  46. value.to_f
  47. else
  48. value
  49. end
  50. end
  51. end
  52. 1 def valid?(value)
  53. !value || allowable_values.include?(value)
  54. end
  55. end
  56. # Attribute mapping from ruby-style variable name to JSON key.
  57. 1 def self.attribute_map
  58. 128 {
  59. :'id' => :'id',
  60. :'owner' => :'owner',
  61. :'application_id' => :'applicationId',
  62. :'time' => :'time',
  63. :'segment_count' => :'segmentCount',
  64. :'direction' => :'direction',
  65. :'to' => :'to',
  66. :'from' => :'from',
  67. :'text' => :'text',
  68. :'tag' => :'tag',
  69. :'media' => :'media',
  70. :'priority' => :'priority',
  71. :'channel' => :'channel',
  72. :'content' => :'content',
  73. :'suggestion_response' => :'suggestionResponse',
  74. :'location_response' => :'locationResponse'
  75. }
  76. end
  77. # Returns attribute mapping this model knows about
  78. 1 def self.acceptable_attribute_map
  79. 17 attribute_map
  80. end
  81. # Returns all the JSON keys this model knows about
  82. 1 def self.acceptable_attributes
  83. 1 acceptable_attribute_map.values
  84. end
  85. # Attribute type mapping.
  86. 1 def self.openapi_types
  87. 2 {
  88. :'id' => :'String',
  89. :'owner' => :'String',
  90. :'application_id' => :'String',
  91. :'time' => :'Time',
  92. :'segment_count' => :'Integer',
  93. :'direction' => :'MessageDirectionEnum',
  94. :'to' => :'Array<String>',
  95. :'from' => :'String',
  96. :'text' => :'String',
  97. :'tag' => :'String',
  98. :'media' => :'Array<String>',
  99. :'priority' => :'PriorityEnum',
  100. :'channel' => :'MultiChannelMessageChannelEnum',
  101. :'content' => :'MultiChannelMessageContent',
  102. :'suggestion_response' => :'RbmSuggestionResponse',
  103. :'location_response' => :'RbmLocationResponse'
  104. }
  105. end
  106. # List of attributes with nullable: true
  107. 1 def self.openapi_nullable
  108. 7 Set.new([
  109. ])
  110. end
  111. # List of class defined in allOf (OpenAPI v3)
  112. 1 def self.openapi_all_of
  113. [
  114. :'StatusCallbackMessage'
  115. ]
  116. end
  117. # Initializes the object
  118. # @param [Hash] attributes Model attributes in the form of hash
  119. 1 def initialize(attributes = {})
  120. 17 if (!attributes.is_a?(Hash))
  121. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::InboundCallbackMessage` initialize method'
  122. end
  123. # check to see if the attribute exists and convert string to symbol for hash key
  124. 16 acceptable_attribute_map = self.class.acceptable_attribute_map
  125. 16 attributes = attributes.each_with_object({}) { |(k, v), h|
  126. 182 if (!acceptable_attribute_map.key?(k.to_sym))
  127. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::InboundCallbackMessage`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  128. end
  129. 181 h[k.to_sym] = v
  130. }
  131. 15 if attributes.key?(:'id')
  132. 15 self.id = attributes[:'id']
  133. else
  134. self.id = nil
  135. end
  136. 15 if attributes.key?(:'owner')
  137. 15 self.owner = attributes[:'owner']
  138. else
  139. self.owner = nil
  140. end
  141. 15 if attributes.key?(:'application_id')
  142. 15 self.application_id = attributes[:'application_id']
  143. else
  144. self.application_id = nil
  145. end
  146. 15 if attributes.key?(:'time')
  147. 15 self.time = attributes[:'time']
  148. else
  149. self.time = nil
  150. end
  151. 15 if attributes.key?(:'segment_count')
  152. 15 self.segment_count = attributes[:'segment_count']
  153. else
  154. self.segment_count = nil
  155. end
  156. 15 if attributes.key?(:'direction')
  157. 15 self.direction = attributes[:'direction']
  158. else
  159. self.direction = nil
  160. end
  161. 15 if attributes.key?(:'to')
  162. 15 if (value = attributes[:'to']).is_a?(Array)
  163. 15 self.to = value
  164. end
  165. else
  166. self.to = nil
  167. end
  168. 15 if attributes.key?(:'from')
  169. 15 self.from = attributes[:'from']
  170. else
  171. self.from = nil
  172. end
  173. 15 if attributes.key?(:'text')
  174. 13 self.text = attributes[:'text']
  175. end
  176. 15 if attributes.key?(:'tag')
  177. 12 self.tag = attributes[:'tag']
  178. end
  179. 15 if attributes.key?(:'media')
  180. 12 if (value = attributes[:'media']).is_a?(Array)
  181. 12 self.media = value
  182. end
  183. end
  184. 15 if attributes.key?(:'priority')
  185. 12 self.priority = attributes[:'priority']
  186. end
  187. 15 if attributes.key?(:'channel')
  188. 12 self.channel = attributes[:'channel']
  189. end
  190. 15 if attributes.key?(:'content')
  191. self.content = attributes[:'content']
  192. end
  193. 15 if attributes.key?(:'suggestion_response')
  194. self.suggestion_response = attributes[:'suggestion_response']
  195. end
  196. 15 if attributes.key?(:'location_response')
  197. self.location_response = attributes[:'location_response']
  198. end
  199. end
  200. # Show invalid properties with the reasons. Usually used together with valid?
  201. # @return Array for valid properties with the reasons
  202. 1 def list_invalid_properties
  203. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  204. invalid_properties = Array.new
  205. if @id.nil?
  206. invalid_properties.push('invalid value for "id", id cannot be nil.')
  207. end
  208. if @owner.nil?
  209. invalid_properties.push('invalid value for "owner", owner cannot be nil.')
  210. end
  211. if @application_id.nil?
  212. invalid_properties.push('invalid value for "application_id", application_id cannot be nil.')
  213. end
  214. if @time.nil?
  215. invalid_properties.push('invalid value for "time", time cannot be nil.')
  216. end
  217. if @segment_count.nil?
  218. invalid_properties.push('invalid value for "segment_count", segment_count cannot be nil.')
  219. end
  220. if @direction.nil?
  221. invalid_properties.push('invalid value for "direction", direction cannot be nil.')
  222. end
  223. if @to.nil?
  224. invalid_properties.push('invalid value for "to", to cannot be nil.')
  225. end
  226. if @from.nil?
  227. invalid_properties.push('invalid value for "from", from cannot be nil.')
  228. end
  229. invalid_properties
  230. end
  231. # Check to see if the all the properties in the model are valid
  232. # @return true if the model is valid
  233. 1 def valid?
  234. warn '[DEPRECATED] the `valid?` method is obsolete'
  235. return false if @id.nil?
  236. return false if @owner.nil?
  237. return false if @application_id.nil?
  238. return false if @time.nil?
  239. return false if @segment_count.nil?
  240. return false if @direction.nil?
  241. return false if @to.nil?
  242. return false if @from.nil?
  243. true
  244. end
  245. # Custom attribute writer method with validation
  246. # @param [Object] id Value to be assigned
  247. 1 def id=(id)
  248. 16 if id.nil?
  249. 1 fail ArgumentError, 'id cannot be nil'
  250. end
  251. 15 @id = id
  252. end
  253. # Custom attribute writer method with validation
  254. # @param [Object] owner Value to be assigned
  255. 1 def owner=(owner)
  256. 16 if owner.nil?
  257. 1 fail ArgumentError, 'owner cannot be nil'
  258. end
  259. 15 @owner = owner
  260. end
  261. # Custom attribute writer method with validation
  262. # @param [Object] application_id Value to be assigned
  263. 1 def application_id=(application_id)
  264. 16 if application_id.nil?
  265. 1 fail ArgumentError, 'application_id cannot be nil'
  266. end
  267. 15 @application_id = application_id
  268. end
  269. # Custom attribute writer method with validation
  270. # @param [Object] time Value to be assigned
  271. 1 def time=(time)
  272. 16 if time.nil?
  273. 1 fail ArgumentError, 'time cannot be nil'
  274. end
  275. 15 @time = time
  276. end
  277. # Custom attribute writer method with validation
  278. # @param [Object] segment_count Value to be assigned
  279. 1 def segment_count=(segment_count)
  280. 16 if segment_count.nil?
  281. 1 fail ArgumentError, 'segment_count cannot be nil'
  282. end
  283. 15 @segment_count = segment_count
  284. end
  285. # Custom attribute writer method with validation
  286. # @param [Object] direction Value to be assigned
  287. 1 def direction=(direction)
  288. 16 if direction.nil?
  289. 1 fail ArgumentError, 'direction cannot be nil'
  290. end
  291. 15 @direction = direction
  292. end
  293. # Custom attribute writer method with validation
  294. # @param [Object] to Value to be assigned
  295. 1 def to=(to)
  296. 16 if to.nil?
  297. 1 fail ArgumentError, 'to cannot be nil'
  298. end
  299. 15 @to = to
  300. end
  301. # Custom attribute writer method with validation
  302. # @param [Object] from Value to be assigned
  303. 1 def from=(from)
  304. 16 if from.nil?
  305. 1 fail ArgumentError, 'from cannot be nil'
  306. end
  307. 15 @from = from
  308. end
  309. # Checks equality by comparing each attribute.
  310. # @param [Object] Object to be compared
  311. 1 def ==(o)
  312. 2 return true if self.equal?(o)
  313. 2 self.class == o.class &&
  314. id == o.id &&
  315. owner == o.owner &&
  316. application_id == o.application_id &&
  317. time == o.time &&
  318. segment_count == o.segment_count &&
  319. direction == o.direction &&
  320. to == o.to &&
  321. from == o.from &&
  322. text == o.text &&
  323. tag == o.tag &&
  324. media == o.media &&
  325. priority == o.priority &&
  326. channel == o.channel &&
  327. content == o.content &&
  328. suggestion_response == o.suggestion_response &&
  329. location_response == o.location_response
  330. end
  331. # @see the `==` method
  332. # @param [Object] Object to be compared
  333. 1 def eql?(o)
  334. 2 self == o
  335. end
  336. # Calculates hash code according to all attributes.
  337. # @return [Integer] Hash code
  338. 1 def hash
  339. [id, owner, application_id, time, segment_count, direction, to, from, text, tag, media, priority, channel, content, suggestion_response, location_response].hash
  340. end
  341. # Builds the object from hash
  342. # @param [Hash] attributes Model attributes in the form of hash
  343. # @return [Object] Returns the model itself
  344. 1 def self.build_from_hash(attributes)
  345. 2 return nil unless attributes.is_a?(Hash)
  346. 2 attributes = attributes.transform_keys(&:to_sym)
  347. 2 transformed_hash = {}
  348. 2 openapi_types.each_pair do |key, type|
  349. 32 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  350. transformed_hash["#{key}"] = nil
  351. 32 elsif type =~ /\AArray<(.*)>/i
  352. # check to ensure the input is an array given that the attribute
  353. # is documented as an array but the input is not
  354. 4 if attributes[attribute_map[key]].is_a?(Array)
  355. 6 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  356. end
  357. 28 elsif !attributes[attribute_map[key]].nil?
  358. 19 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  359. end
  360. end
  361. 2 new(transformed_hash)
  362. end
  363. # Returns the object in the form of hash
  364. # @return [Hash] Returns the object in the form of hash
  365. 1 def to_hash
  366. 2 hash = {}
  367. 2 self.class.attribute_map.each_pair do |attr, param|
  368. 32 value = self.send(attr)
  369. 32 if value.nil?
  370. 6 is_nullable = self.class.openapi_nullable.include?(attr)
  371. 6 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  372. end
  373. 26 hash[param] = _to_hash(value)
  374. end
  375. 2 hash
  376. end
  377. end
  378. end

lib/bandwidth-sdk/models/inbound_callback_type_enum.rb

100.0% lines covered

14 relevant lines. 14 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class InboundCallbackTypeEnum
  13. 1 MESSAGE_RECEIVED = 'message-received'.freeze
  14. 1 REQUEST_LOCATION_RESPONSE = 'request-location-response'.freeze
  15. 1 SUGGESTION_RESPONSE = 'suggestion-response'.freeze
  16. 1 def self.all_vars
  17. 6 @all_vars ||= [MESSAGE_RECEIVED, REQUEST_LOCATION_RESPONSE, SUGGESTION_RESPONSE].freeze
  18. end
  19. # Builds the enum from string
  20. # @param [String] The enum value in the form of the string
  21. # @return [String] The enum value
  22. 1 def self.build_from_hash(value)
  23. 5 new.build_from_hash(value)
  24. end
  25. # Builds the enum from string
  26. # @param [String] The enum value in the form of the string
  27. # @return [String] The enum value
  28. 1 def build_from_hash(value)
  29. 5 return value if InboundCallbackTypeEnum.all_vars.include?(value)
  30. 1 raise "Invalid ENUM value #{value} for class #InboundCallbackTypeEnum"
  31. end
  32. end
  33. end

lib/bandwidth-sdk/models/initiate_callback.rb

81.2% lines covered

117 relevant lines. 95 lines covered and 22 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The Initiate event is fired when an inbound call is received for a Telephone Number on your Account. It is sent to the URL specified in the application associated with the location (sip-peer) that the called telephone number belongs to.
  13. 1 class InitiateCallback < ApiModelBase
  14. # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect.
  15. 1 attr_accessor :event_type
  16. # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.
  17. 1 attr_accessor :event_time
  18. # The user account associated with the call.
  19. 1 attr_accessor :account_id
  20. # The id of the application associated with the call.
  21. 1 attr_accessor :application_id
  22. # The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555).
  23. 1 attr_accessor :from
  24. # The phone number that received the call, in E.164 format (e.g. +15555555555).
  25. 1 attr_accessor :to
  26. 1 attr_accessor :direction
  27. # The call id associated with the event.
  28. 1 attr_accessor :call_id
  29. # The URL of the call associated with the event.
  30. 1 attr_accessor :call_url
  31. # Time the call was started, in ISO 8601 format.
  32. 1 attr_accessor :start_time
  33. 1 attr_accessor :diversion
  34. 1 attr_accessor :stir_shaken
  35. # The value of the `User-To-User` header to send within the initial `INVITE`. Must include the encoding parameter as specified in RFC 7433. Only `base64`, `jwt` and `hex` encoding are currently allowed. This value, including the encoding specifier, may not exceed 256 characters.
  36. 1 attr_accessor :uui
  37. 1 class EnumAttributeValidator
  38. 1 attr_reader :datatype
  39. 1 attr_reader :allowable_values
  40. 1 def initialize(datatype, allowable_values)
  41. @allowable_values = allowable_values.map do |value|
  42. case datatype.to_s
  43. when /Integer/i
  44. value.to_i
  45. when /Float/i
  46. value.to_f
  47. else
  48. value
  49. end
  50. end
  51. end
  52. 1 def valid?(value)
  53. !value || allowable_values.include?(value)
  54. end
  55. end
  56. # Attribute mapping from ruby-style variable name to JSON key.
  57. 1 def self.attribute_map
  58. 63 {
  59. :'event_type' => :'eventType',
  60. :'event_time' => :'eventTime',
  61. :'account_id' => :'accountId',
  62. :'application_id' => :'applicationId',
  63. :'from' => :'from',
  64. :'to' => :'to',
  65. :'direction' => :'direction',
  66. :'call_id' => :'callId',
  67. :'call_url' => :'callUrl',
  68. :'start_time' => :'startTime',
  69. :'diversion' => :'diversion',
  70. :'stir_shaken' => :'stirShaken',
  71. :'uui' => :'uui'
  72. }
  73. end
  74. # Returns attribute mapping this model knows about
  75. 1 def self.acceptable_attribute_map
  76. 8 attribute_map
  77. end
  78. # Returns all the JSON keys this model knows about
  79. 1 def self.acceptable_attributes
  80. 1 acceptable_attribute_map.values
  81. end
  82. # Attribute type mapping.
  83. 1 def self.openapi_types
  84. 1 {
  85. :'event_type' => :'String',
  86. :'event_time' => :'Time',
  87. :'account_id' => :'String',
  88. :'application_id' => :'String',
  89. :'from' => :'String',
  90. :'to' => :'String',
  91. :'direction' => :'CallDirectionEnum',
  92. :'call_id' => :'String',
  93. :'call_url' => :'String',
  94. :'start_time' => :'Time',
  95. :'diversion' => :'Diversion',
  96. :'stir_shaken' => :'StirShaken',
  97. :'uui' => :'String'
  98. }
  99. end
  100. # List of attributes with nullable: true
  101. 1 def self.openapi_nullable
  102. 1 Set.new([
  103. ])
  104. end
  105. # Initializes the object
  106. # @param [Hash] attributes Model attributes in the form of hash
  107. 1 def initialize(attributes = {})
  108. 8 if (!attributes.is_a?(Hash))
  109. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::InitiateCallback` initialize method'
  110. end
  111. # check to see if the attribute exists and convert string to symbol for hash key
  112. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  113. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  114. 53 if (!acceptable_attribute_map.key?(k.to_sym))
  115. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::InitiateCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  116. end
  117. 52 h[k.to_sym] = v
  118. }
  119. 6 if attributes.key?(:'event_type')
  120. 4 self.event_type = attributes[:'event_type']
  121. end
  122. 6 if attributes.key?(:'event_time')
  123. 4 self.event_time = attributes[:'event_time']
  124. end
  125. 6 if attributes.key?(:'account_id')
  126. 4 self.account_id = attributes[:'account_id']
  127. end
  128. 6 if attributes.key?(:'application_id')
  129. 4 self.application_id = attributes[:'application_id']
  130. end
  131. 6 if attributes.key?(:'from')
  132. 4 self.from = attributes[:'from']
  133. end
  134. 6 if attributes.key?(:'to')
  135. 4 self.to = attributes[:'to']
  136. end
  137. 6 if attributes.key?(:'direction')
  138. 4 self.direction = attributes[:'direction']
  139. end
  140. 6 if attributes.key?(:'call_id')
  141. 4 self.call_id = attributes[:'call_id']
  142. end
  143. 6 if attributes.key?(:'call_url')
  144. 4 self.call_url = attributes[:'call_url']
  145. end
  146. 6 if attributes.key?(:'start_time')
  147. 4 self.start_time = attributes[:'start_time']
  148. end
  149. 6 if attributes.key?(:'diversion')
  150. 4 self.diversion = attributes[:'diversion']
  151. end
  152. 6 if attributes.key?(:'stir_shaken')
  153. 4 self.stir_shaken = attributes[:'stir_shaken']
  154. end
  155. 6 if attributes.key?(:'uui')
  156. 4 self.uui = attributes[:'uui']
  157. end
  158. end
  159. # Show invalid properties with the reasons. Usually used together with valid?
  160. # @return Array for valid properties with the reasons
  161. 1 def list_invalid_properties
  162. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  163. invalid_properties = Array.new
  164. if !@uui.nil? && @uui.to_s.length > 256
  165. invalid_properties.push('invalid value for "uui", the character length must be smaller than or equal to 256.')
  166. end
  167. invalid_properties
  168. end
  169. # Check to see if the all the properties in the model are valid
  170. # @return true if the model is valid
  171. 1 def valid?
  172. warn '[DEPRECATED] the `valid?` method is obsolete'
  173. return false if !@uui.nil? && @uui.to_s.length > 256
  174. true
  175. end
  176. # Custom attribute writer method with validation
  177. # @param [Object] uui Value to be assigned
  178. 1 def uui=(uui)
  179. 4 if uui.nil?
  180. fail ArgumentError, 'uui cannot be nil'
  181. end
  182. 4 if uui.to_s.length > 256
  183. fail ArgumentError, 'invalid value for "uui", the character length must be smaller than or equal to 256.'
  184. end
  185. 4 @uui = uui
  186. end
  187. # Checks equality by comparing each attribute.
  188. # @param [Object] Object to be compared
  189. 1 def ==(o)
  190. 2 return true if self.equal?(o)
  191. 2 self.class == o.class &&
  192. event_type == o.event_type &&
  193. event_time == o.event_time &&
  194. account_id == o.account_id &&
  195. application_id == o.application_id &&
  196. from == o.from &&
  197. to == o.to &&
  198. direction == o.direction &&
  199. call_id == o.call_id &&
  200. call_url == o.call_url &&
  201. start_time == o.start_time &&
  202. diversion == o.diversion &&
  203. stir_shaken == o.stir_shaken &&
  204. uui == o.uui
  205. end
  206. # @see the `==` method
  207. # @param [Object] Object to be compared
  208. 1 def eql?(o)
  209. 2 self == o
  210. end
  211. # Calculates hash code according to all attributes.
  212. # @return [Integer] Hash code
  213. 1 def hash
  214. [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, start_time, diversion, stir_shaken, uui].hash
  215. end
  216. # Builds the object from hash
  217. # @param [Hash] attributes Model attributes in the form of hash
  218. # @return [Object] Returns the model itself
  219. 1 def self.build_from_hash(attributes)
  220. 1 return nil unless attributes.is_a?(Hash)
  221. 1 attributes = attributes.transform_keys(&:to_sym)
  222. 1 transformed_hash = {}
  223. 1 openapi_types.each_pair do |key, type|
  224. 13 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  225. transformed_hash["#{key}"] = nil
  226. 13 elsif type =~ /\AArray<(.*)>/i
  227. # check to ensure the input is an array given that the attribute
  228. # is documented as an array but the input is not
  229. if attributes[attribute_map[key]].is_a?(Array)
  230. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  231. end
  232. 13 elsif !attributes[attribute_map[key]].nil?
  233. 13 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  234. end
  235. end
  236. 1 new(transformed_hash)
  237. end
  238. # Returns the object in the form of hash
  239. # @return [Hash] Returns the object in the form of hash
  240. 1 def to_hash
  241. 2 hash = {}
  242. 2 self.class.attribute_map.each_pair do |attr, param|
  243. 26 value = self.send(attr)
  244. 26 if value.nil?
  245. is_nullable = self.class.openapi_nullable.include?(attr)
  246. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  247. end
  248. 26 hash[param] = _to_hash(value)
  249. end
  250. 2 hash
  251. end
  252. end
  253. end

lib/bandwidth-sdk/models/latest_message_delivery_status_enum.rb

100.0% lines covered

15 relevant lines. 15 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class LatestMessageDeliveryStatusEnum
  13. 1 ACTIVE = 'ACTIVE'.freeze
  14. 1 DEACTIVATED = 'DEACTIVATED'.freeze
  15. 1 UNKNOWN = 'UNKNOWN'.freeze
  16. 1 NOT_ENABLED = 'NOT_ENABLED'.freeze
  17. 1 def self.all_vars
  18. 15 @all_vars ||= [ACTIVE, DEACTIVATED, UNKNOWN, NOT_ENABLED].freeze
  19. end
  20. # Builds the enum from string
  21. # @param [String] The enum value in the form of the string
  22. # @return [String] The enum value
  23. 1 def self.build_from_hash(value)
  24. 14 new.build_from_hash(value)
  25. end
  26. # Builds the enum from string
  27. # @param [String] The enum value in the form of the string
  28. # @return [String] The enum value
  29. 1 def build_from_hash(value)
  30. 14 return value if LatestMessageDeliveryStatusEnum.all_vars.include?(value)
  31. 1 raise "Invalid ENUM value #{value} for class #LatestMessageDeliveryStatusEnum"
  32. end
  33. end
  34. end

lib/bandwidth-sdk/models/line_type_enum.rb

100.0% lines covered

15 relevant lines. 15 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class LineTypeEnum
  13. 1 FIXED = 'FIXED'.freeze
  14. 1 VOIP_FIXED = 'VOIP-FIXED'.freeze
  15. 1 MOBILE = 'MOBILE'.freeze
  16. 1 VOIP = 'VOIP'.freeze
  17. 1 def self.all_vars
  18. 15 @all_vars ||= [FIXED, VOIP_FIXED, MOBILE, VOIP].freeze
  19. end
  20. # Builds the enum from string
  21. # @param [String] The enum value in the form of the string
  22. # @return [String] The enum value
  23. 1 def self.build_from_hash(value)
  24. 14 new.build_from_hash(value)
  25. end
  26. # Builds the enum from string
  27. # @param [String] The enum value in the form of the string
  28. # @return [String] The enum value
  29. 1 def build_from_hash(value)
  30. 14 return value if LineTypeEnum.all_vars.include?(value)
  31. 1 raise "Invalid ENUM value #{value} for class #LineTypeEnum"
  32. end
  33. end
  34. end

lib/bandwidth-sdk/models/link.rb

82.81% lines covered

64 relevant lines. 53 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class Link < ApiModelBase
  13. 1 attr_accessor :rel
  14. 1 attr_accessor :href
  15. # Attribute mapping from ruby-style variable name to JSON key.
  16. 1 def self.attribute_map
  17. 47 {
  18. :'rel' => :'rel',
  19. :'href' => :'href'
  20. }
  21. end
  22. # Returns attribute mapping this model knows about
  23. 1 def self.acceptable_attribute_map
  24. 16 attribute_map
  25. end
  26. # Returns all the JSON keys this model knows about
  27. 1 def self.acceptable_attributes
  28. 1 acceptable_attribute_map.values
  29. end
  30. # Attribute type mapping.
  31. 1 def self.openapi_types
  32. 3 {
  33. :'rel' => :'String',
  34. :'href' => :'String'
  35. }
  36. end
  37. # List of attributes with nullable: true
  38. 1 def self.openapi_nullable
  39. 1 Set.new([
  40. ])
  41. end
  42. # Initializes the object
  43. # @param [Hash] attributes Model attributes in the form of hash
  44. 1 def initialize(attributes = {})
  45. 16 if (!attributes.is_a?(Hash))
  46. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::Link` initialize method'
  47. end
  48. # check to see if the attribute exists and convert string to symbol for hash key
  49. 15 acceptable_attribute_map = self.class.acceptable_attribute_map
  50. 15 attributes = attributes.each_with_object({}) { |(k, v), h|
  51. 25 if (!acceptable_attribute_map.key?(k.to_sym))
  52. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::Link`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  53. end
  54. 24 h[k.to_sym] = v
  55. }
  56. 14 if attributes.key?(:'rel')
  57. 12 self.rel = attributes[:'rel']
  58. end
  59. 14 if attributes.key?(:'href')
  60. 12 self.href = attributes[:'href']
  61. end
  62. end
  63. # Show invalid properties with the reasons. Usually used together with valid?
  64. # @return Array for valid properties with the reasons
  65. 1 def list_invalid_properties
  66. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  67. invalid_properties = Array.new
  68. invalid_properties
  69. end
  70. # Check to see if the all the properties in the model are valid
  71. # @return true if the model is valid
  72. 1 def valid?
  73. warn '[DEPRECATED] the `valid?` method is obsolete'
  74. true
  75. end
  76. # Checks equality by comparing each attribute.
  77. # @param [Object] Object to be compared
  78. 1 def ==(o)
  79. 2 return true if self.equal?(o)
  80. 2 self.class == o.class &&
  81. rel == o.rel &&
  82. href == o.href
  83. end
  84. # @see the `==` method
  85. # @param [Object] Object to be compared
  86. 1 def eql?(o)
  87. 2 self == o
  88. end
  89. # Calculates hash code according to all attributes.
  90. # @return [Integer] Hash code
  91. 1 def hash
  92. [rel, href].hash
  93. end
  94. # Builds the object from hash
  95. # @param [Hash] attributes Model attributes in the form of hash
  96. # @return [Object] Returns the model itself
  97. 1 def self.build_from_hash(attributes)
  98. 3 return nil unless attributes.is_a?(Hash)
  99. 3 attributes = attributes.transform_keys(&:to_sym)
  100. 3 transformed_hash = {}
  101. 3 openapi_types.each_pair do |key, type|
  102. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  103. transformed_hash["#{key}"] = nil
  104. 6 elsif type =~ /\AArray<(.*)>/i
  105. # check to ensure the input is an array given that the attribute
  106. # is documented as an array but the input is not
  107. if attributes[attribute_map[key]].is_a?(Array)
  108. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  109. end
  110. 6 elsif !attributes[attribute_map[key]].nil?
  111. 6 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  112. end
  113. end
  114. 3 new(transformed_hash)
  115. end
  116. # Returns the object in the form of hash
  117. # @return [Hash] Returns the object in the form of hash
  118. 1 def to_hash
  119. 6 hash = {}
  120. 6 self.class.attribute_map.each_pair do |attr, param|
  121. 12 value = self.send(attr)
  122. 12 if value.nil?
  123. is_nullable = self.class.openapi_nullable.include?(attr)
  124. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  125. end
  126. 12 hash[param] = _to_hash(value)
  127. end
  128. 6 hash
  129. end
  130. end
  131. end

lib/bandwidth-sdk/models/link_schema.rb

83.58% lines covered

67 relevant lines. 56 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class LinkSchema < ApiModelBase
  13. # URI of the link.
  14. 1 attr_accessor :href
  15. # Specifies the relationship between this link and the resource.
  16. 1 attr_accessor :rel
  17. # HTTP method to be used.
  18. 1 attr_accessor :method
  19. # Attribute mapping from ruby-style variable name to JSON key.
  20. 1 def self.attribute_map
  21. 108 {
  22. :'href' => :'href',
  23. :'rel' => :'rel',
  24. :'method' => :'method'
  25. }
  26. end
  27. # Returns attribute mapping this model knows about
  28. 1 def self.acceptable_attribute_map
  29. 25 attribute_map
  30. end
  31. # Returns all the JSON keys this model knows about
  32. 1 def self.acceptable_attributes
  33. 1 acceptable_attribute_map.values
  34. end
  35. # Attribute type mapping.
  36. 1 def self.openapi_types
  37. 6 {
  38. :'href' => :'String',
  39. :'rel' => :'String',
  40. :'method' => :'String'
  41. }
  42. end
  43. # List of attributes with nullable: true
  44. 1 def self.openapi_nullable
  45. 1 Set.new([
  46. ])
  47. end
  48. # Initializes the object
  49. # @param [Hash] attributes Model attributes in the form of hash
  50. 1 def initialize(attributes = {})
  51. 25 if (!attributes.is_a?(Hash))
  52. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::LinkSchema` initialize method'
  53. end
  54. # check to see if the attribute exists and convert string to symbol for hash key
  55. 24 acceptable_attribute_map = self.class.acceptable_attribute_map
  56. 24 attributes = attributes.each_with_object({}) { |(k, v), h|
  57. 64 if (!acceptable_attribute_map.key?(k.to_sym))
  58. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::LinkSchema`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  59. end
  60. 63 h[k.to_sym] = v
  61. }
  62. 23 if attributes.key?(:'href')
  63. 21 self.href = attributes[:'href']
  64. end
  65. 23 if attributes.key?(:'rel')
  66. 21 self.rel = attributes[:'rel']
  67. end
  68. 23 if attributes.key?(:'method')
  69. 21 self.method = attributes[:'method']
  70. end
  71. end
  72. # Show invalid properties with the reasons. Usually used together with valid?
  73. # @return Array for valid properties with the reasons
  74. 1 def list_invalid_properties
  75. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  76. invalid_properties = Array.new
  77. invalid_properties
  78. end
  79. # Check to see if the all the properties in the model are valid
  80. # @return true if the model is valid
  81. 1 def valid?
  82. warn '[DEPRECATED] the `valid?` method is obsolete'
  83. true
  84. end
  85. # Checks equality by comparing each attribute.
  86. # @param [Object] Object to be compared
  87. 1 def ==(o)
  88. 2 return true if self.equal?(o)
  89. 2 self.class == o.class &&
  90. href == o.href &&
  91. rel == o.rel &&
  92. method == o.method
  93. end
  94. # @see the `==` method
  95. # @param [Object] Object to be compared
  96. 1 def eql?(o)
  97. 2 self == o
  98. end
  99. # Calculates hash code according to all attributes.
  100. # @return [Integer] Hash code
  101. 1 def hash
  102. [href, rel, method].hash
  103. end
  104. # Builds the object from hash
  105. # @param [Hash] attributes Model attributes in the form of hash
  106. # @return [Object] Returns the model itself
  107. 1 def self.build_from_hash(attributes)
  108. 6 return nil unless attributes.is_a?(Hash)
  109. 6 attributes = attributes.transform_keys(&:to_sym)
  110. 6 transformed_hash = {}
  111. 6 openapi_types.each_pair do |key, type|
  112. 18 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  113. transformed_hash["#{key}"] = nil
  114. 18 elsif type =~ /\AArray<(.*)>/i
  115. # check to ensure the input is an array given that the attribute
  116. # is documented as an array but the input is not
  117. if attributes[attribute_map[key]].is_a?(Array)
  118. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  119. end
  120. 18 elsif !attributes[attribute_map[key]].nil?
  121. 18 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  122. end
  123. end
  124. 6 new(transformed_hash)
  125. end
  126. # Returns the object in the form of hash
  127. # @return [Hash] Returns the object in the form of hash
  128. 1 def to_hash
  129. 10 hash = {}
  130. 10 self.class.attribute_map.each_pair do |attr, param|
  131. 30 value = self.send(attr)
  132. 30 if value.nil?
  133. is_nullable = self.class.openapi_nullable.include?(attr)
  134. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  135. end
  136. 30 hash[param] = _to_hash(value)
  137. end
  138. 10 hash
  139. end
  140. end
  141. end

lib/bandwidth-sdk/models/links_object.rb

84.29% lines covered

70 relevant lines. 59 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class LinksObject < ApiModelBase
  13. # The first (or only) page of results matching the query.
  14. 1 attr_accessor :first
  15. # If more results exist than specified by 'size', this link returns the next page of 'size' results.
  16. 1 attr_accessor :_next
  17. # If the results are more than one page, this link returns the previous page of 'size' results.
  18. 1 attr_accessor :previous
  19. # If more results exist than specified by 'size', this link return the last page of result.
  20. 1 attr_accessor :last
  21. # Attribute mapping from ruby-style variable name to JSON key.
  22. 1 def self.attribute_map
  23. 53 {
  24. :'first' => :'first',
  25. :'_next' => :'next',
  26. :'previous' => :'previous',
  27. :'last' => :'last'
  28. }
  29. end
  30. # Returns attribute mapping this model knows about
  31. 1 def self.acceptable_attribute_map
  32. 10 attribute_map
  33. end
  34. # Returns all the JSON keys this model knows about
  35. 1 def self.acceptable_attributes
  36. 1 acceptable_attribute_map.values
  37. end
  38. # Attribute type mapping.
  39. 1 def self.openapi_types
  40. 3 {
  41. :'first' => :'String',
  42. :'_next' => :'String',
  43. :'previous' => :'String',
  44. :'last' => :'String'
  45. }
  46. end
  47. # List of attributes with nullable: true
  48. 1 def self.openapi_nullable
  49. 1 Set.new([
  50. ])
  51. end
  52. # Initializes the object
  53. # @param [Hash] attributes Model attributes in the form of hash
  54. 1 def initialize(attributes = {})
  55. 10 if (!attributes.is_a?(Hash))
  56. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::LinksObject` initialize method'
  57. end
  58. # check to see if the attribute exists and convert string to symbol for hash key
  59. 9 acceptable_attribute_map = self.class.acceptable_attribute_map
  60. 9 attributes = attributes.each_with_object({}) { |(k, v), h|
  61. 21 if (!acceptable_attribute_map.key?(k.to_sym))
  62. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::LinksObject`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  63. end
  64. 20 h[k.to_sym] = v
  65. }
  66. 8 if attributes.key?(:'first')
  67. 5 self.first = attributes[:'first']
  68. end
  69. 8 if attributes.key?(:'_next')
  70. 5 self._next = attributes[:'_next']
  71. end
  72. 8 if attributes.key?(:'previous')
  73. 5 self.previous = attributes[:'previous']
  74. end
  75. 8 if attributes.key?(:'last')
  76. 5 self.last = attributes[:'last']
  77. end
  78. end
  79. # Show invalid properties with the reasons. Usually used together with valid?
  80. # @return Array for valid properties with the reasons
  81. 1 def list_invalid_properties
  82. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  83. invalid_properties = Array.new
  84. invalid_properties
  85. end
  86. # Check to see if the all the properties in the model are valid
  87. # @return true if the model is valid
  88. 1 def valid?
  89. warn '[DEPRECATED] the `valid?` method is obsolete'
  90. true
  91. end
  92. # Checks equality by comparing each attribute.
  93. # @param [Object] Object to be compared
  94. 1 def ==(o)
  95. 2 return true if self.equal?(o)
  96. 2 self.class == o.class &&
  97. first == o.first &&
  98. _next == o._next &&
  99. previous == o.previous &&
  100. last == o.last
  101. end
  102. # @see the `==` method
  103. # @param [Object] Object to be compared
  104. 1 def eql?(o)
  105. 2 self == o
  106. end
  107. # Calculates hash code according to all attributes.
  108. # @return [Integer] Hash code
  109. 1 def hash
  110. [first, _next, previous, last].hash
  111. end
  112. # Builds the object from hash
  113. # @param [Hash] attributes Model attributes in the form of hash
  114. # @return [Object] Returns the model itself
  115. 1 def self.build_from_hash(attributes)
  116. 3 return nil unless attributes.is_a?(Hash)
  117. 3 attributes = attributes.transform_keys(&:to_sym)
  118. 3 transformed_hash = {}
  119. 3 openapi_types.each_pair do |key, type|
  120. 12 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  121. transformed_hash["#{key}"] = nil
  122. 12 elsif type =~ /\AArray<(.*)>/i
  123. # check to ensure the input is an array given that the attribute
  124. # is documented as an array but the input is not
  125. if attributes[attribute_map[key]].is_a?(Array)
  126. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  127. end
  128. 12 elsif !attributes[attribute_map[key]].nil?
  129. 8 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  130. end
  131. end
  132. 3 new(transformed_hash)
  133. end
  134. # Returns the object in the form of hash
  135. # @return [Hash] Returns the object in the form of hash
  136. 1 def to_hash
  137. 2 hash = {}
  138. 2 self.class.attribute_map.each_pair do |attr, param|
  139. 8 value = self.send(attr)
  140. 8 if value.nil?
  141. is_nullable = self.class.openapi_nullable.include?(attr)
  142. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  143. end
  144. 8 hash[param] = _to_hash(value)
  145. end
  146. 2 hash
  147. end
  148. end
  149. end

lib/bandwidth-sdk/models/list_endpoints_response.rb

78.35% lines covered

97 relevant lines. 76 lines covered and 21 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class ListEndpointsResponse < ApiModelBase
  13. 1 attr_accessor :links
  14. 1 attr_accessor :page
  15. 1 attr_accessor :data
  16. 1 attr_accessor :errors
  17. # Attribute mapping from ruby-style variable name to JSON key.
  18. 1 def self.attribute_map
  19. 47 {
  20. :'links' => :'links',
  21. :'page' => :'page',
  22. :'data' => :'data',
  23. :'errors' => :'errors'
  24. }
  25. end
  26. # Returns attribute mapping this model knows about
  27. 1 def self.acceptable_attribute_map
  28. 12 attribute_map
  29. end
  30. # Returns all the JSON keys this model knows about
  31. 1 def self.acceptable_attributes
  32. 1 acceptable_attribute_map.values
  33. end
  34. # Attribute type mapping.
  35. 1 def self.openapi_types
  36. 2 {
  37. :'links' => :'Array<BrtcLink>',
  38. :'page' => :'Page',
  39. :'data' => :'Array<Endpoints>',
  40. :'errors' => :'Array<BrtcError>'
  41. }
  42. end
  43. # List of attributes with nullable: true
  44. 1 def self.openapi_nullable
  45. 1 Set.new([
  46. ])
  47. end
  48. # Initializes the object
  49. # @param [Hash] attributes Model attributes in the form of hash
  50. 1 def initialize(attributes = {})
  51. 12 if (!attributes.is_a?(Hash))
  52. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::ListEndpointsResponse` initialize method'
  53. end
  54. # check to see if the attribute exists and convert string to symbol for hash key
  55. 11 acceptable_attribute_map = self.class.acceptable_attribute_map
  56. 11 attributes = attributes.each_with_object({}) { |(k, v), h|
  57. 39 if (!acceptable_attribute_map.key?(k.to_sym))
  58. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ListEndpointsResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  59. end
  60. 38 h[k.to_sym] = v
  61. }
  62. 10 if attributes.key?(:'links')
  63. 10 if (value = attributes[:'links']).is_a?(Array)
  64. 10 self.links = value
  65. end
  66. else
  67. self.links = nil
  68. end
  69. 10 if attributes.key?(:'page')
  70. 8 self.page = attributes[:'page']
  71. end
  72. 10 if attributes.key?(:'data')
  73. 10 if (value = attributes[:'data']).is_a?(Array)
  74. 10 self.data = value
  75. end
  76. else
  77. self.data = nil
  78. end
  79. 10 if attributes.key?(:'errors')
  80. 10 if (value = attributes[:'errors']).is_a?(Array)
  81. 10 self.errors = value
  82. end
  83. else
  84. self.errors = nil
  85. end
  86. end
  87. # Show invalid properties with the reasons. Usually used together with valid?
  88. # @return Array for valid properties with the reasons
  89. 1 def list_invalid_properties
  90. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  91. invalid_properties = Array.new
  92. if @links.nil?
  93. invalid_properties.push('invalid value for "links", links cannot be nil.')
  94. end
  95. if @data.nil?
  96. invalid_properties.push('invalid value for "data", data cannot be nil.')
  97. end
  98. if @errors.nil?
  99. invalid_properties.push('invalid value for "errors", errors cannot be nil.')
  100. end
  101. invalid_properties
  102. end
  103. # Check to see if the all the properties in the model are valid
  104. # @return true if the model is valid
  105. 1 def valid?
  106. warn '[DEPRECATED] the `valid?` method is obsolete'
  107. return false if @links.nil?
  108. return false if @data.nil?
  109. return false if @errors.nil?
  110. true
  111. end
  112. # Custom attribute writer method with validation
  113. # @param [Object] links Value to be assigned
  114. 1 def links=(links)
  115. 11 if links.nil?
  116. 1 fail ArgumentError, 'links cannot be nil'
  117. end
  118. 10 @links = links
  119. end
  120. # Custom attribute writer method with validation
  121. # @param [Object] data Value to be assigned
  122. 1 def data=(data)
  123. 11 if data.nil?
  124. 1 fail ArgumentError, 'data cannot be nil'
  125. end
  126. 10 @data = data
  127. end
  128. # Custom attribute writer method with validation
  129. # @param [Object] errors Value to be assigned
  130. 1 def errors=(errors)
  131. 11 if errors.nil?
  132. 1 fail ArgumentError, 'errors cannot be nil'
  133. end
  134. 10 @errors = errors
  135. end
  136. # Checks equality by comparing each attribute.
  137. # @param [Object] Object to be compared
  138. 1 def ==(o)
  139. 2 return true if self.equal?(o)
  140. 2 self.class == o.class &&
  141. links == o.links &&
  142. page == o.page &&
  143. data == o.data &&
  144. errors == o.errors
  145. end
  146. # @see the `==` method
  147. # @param [Object] Object to be compared
  148. 1 def eql?(o)
  149. 2 self == o
  150. end
  151. # Calculates hash code according to all attributes.
  152. # @return [Integer] Hash code
  153. 1 def hash
  154. [links, page, data, errors].hash
  155. end
  156. # Builds the object from hash
  157. # @param [Hash] attributes Model attributes in the form of hash
  158. # @return [Object] Returns the model itself
  159. 1 def self.build_from_hash(attributes)
  160. 2 return nil unless attributes.is_a?(Hash)
  161. 2 attributes = attributes.transform_keys(&:to_sym)
  162. 2 transformed_hash = {}
  163. 2 openapi_types.each_pair do |key, type|
  164. 8 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  165. transformed_hash["#{key}"] = nil
  166. 8 elsif type =~ /\AArray<(.*)>/i
  167. # check to ensure the input is an array given that the attribute
  168. # is documented as an array but the input is not
  169. 6 if attributes[attribute_map[key]].is_a?(Array)
  170. 13 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  171. end
  172. 2 elsif !attributes[attribute_map[key]].nil?
  173. 2 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  174. end
  175. end
  176. 2 new(transformed_hash)
  177. end
  178. # Returns the object in the form of hash
  179. # @return [Hash] Returns the object in the form of hash
  180. 1 def to_hash
  181. 2 hash = {}
  182. 2 self.class.attribute_map.each_pair do |attr, param|
  183. 8 value = self.send(attr)
  184. 8 if value.nil?
  185. is_nullable = self.class.openapi_nullable.include?(attr)
  186. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  187. end
  188. 8 hash[param] = _to_hash(value)
  189. end
  190. 2 hash
  191. end
  192. end
  193. end

lib/bandwidth-sdk/models/list_message_direction_enum.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class ListMessageDirectionEnum
  13. 1 INBOUND = 'INBOUND'.freeze
  14. 1 OUTBOUND = 'OUTBOUND'.freeze
  15. 1 def self.all_vars
  16. 7 @all_vars ||= [INBOUND, OUTBOUND].freeze
  17. end
  18. # Builds the enum from string
  19. # @param [String] The enum value in the form of the string
  20. # @return [String] The enum value
  21. 1 def self.build_from_hash(value)
  22. 5 new.build_from_hash(value)
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def build_from_hash(value)
  28. 5 return value if ListMessageDirectionEnum.all_vars.include?(value)
  29. 1 raise "Invalid ENUM value #{value} for class #ListMessageDirectionEnum"
  30. end
  31. end
  32. end

lib/bandwidth-sdk/models/list_message_item.rb

89.13% lines covered

138 relevant lines. 123 lines covered and 15 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class ListMessageItem < ApiModelBase
  13. # The message id
  14. 1 attr_accessor :message_id
  15. # The account id associated with this message.
  16. 1 attr_accessor :account_id
  17. # The source phone number of the message.
  18. 1 attr_accessor :source_tn
  19. # The recipient phone number of the message.
  20. 1 attr_accessor :destination_tn
  21. 1 attr_accessor :message_status
  22. 1 attr_accessor :message_direction
  23. 1 attr_accessor :message_type
  24. # The number of segments the user's message is broken into before sending over carrier networks.
  25. 1 attr_accessor :segment_count
  26. # The numeric error code of the message.
  27. 1 attr_accessor :error_code
  28. # The ISO 8601 datetime of the message.
  29. 1 attr_accessor :receive_time
  30. # The name of the carrier. Not currently supported for MMS coming soon.
  31. 1 attr_accessor :carrier_name
  32. # The size of the message including message content and headers.
  33. 1 attr_accessor :message_size
  34. # The length of the message content.
  35. 1 attr_accessor :message_length
  36. # The number of attachments the message has.
  37. 1 attr_accessor :attachment_count
  38. # The number of recipients the message has.
  39. 1 attr_accessor :recipient_count
  40. # The campaign class of the message if it has one.
  41. 1 attr_accessor :campaign_class
  42. # The campaign ID of the message if it has one.
  43. 1 attr_accessor :campaign_id
  44. # The Bandwidth latency of the message in seconds. Only available for accounts with the Advanced Quality Metrics feature enabled.
  45. 1 attr_accessor :bw_latency
  46. # The carrier latency of the message in seconds. Only available for OUTBOUND messages from accounts with the Advanced Quality Metrics feature enabled.
  47. 1 attr_accessor :carrier_latency
  48. # The A3 country code of the calling number.
  49. 1 attr_accessor :calling_number_country_a3
  50. # The A3 country code of the called number.
  51. 1 attr_accessor :called_number_country_a3
  52. # The messaging product associated with the message.
  53. 1 attr_accessor :product
  54. # The location ID associated with this message.
  55. 1 attr_accessor :location
  56. 1 class EnumAttributeValidator
  57. 1 attr_reader :datatype
  58. 1 attr_reader :allowable_values
  59. 1 def initialize(datatype, allowable_values)
  60. @allowable_values = allowable_values.map do |value|
  61. case datatype.to_s
  62. when /Integer/i
  63. value.to_i
  64. when /Float/i
  65. value.to_f
  66. else
  67. value
  68. end
  69. end
  70. end
  71. 1 def valid?(value)
  72. !value || allowable_values.include?(value)
  73. end
  74. end
  75. # Attribute mapping from ruby-style variable name to JSON key.
  76. 1 def self.attribute_map
  77. 252 {
  78. :'message_id' => :'messageId',
  79. :'account_id' => :'accountId',
  80. :'source_tn' => :'sourceTn',
  81. :'destination_tn' => :'destinationTn',
  82. :'message_status' => :'messageStatus',
  83. :'message_direction' => :'messageDirection',
  84. :'message_type' => :'messageType',
  85. :'segment_count' => :'segmentCount',
  86. :'error_code' => :'errorCode',
  87. :'receive_time' => :'receiveTime',
  88. :'carrier_name' => :'carrierName',
  89. :'message_size' => :'messageSize',
  90. :'message_length' => :'messageLength',
  91. :'attachment_count' => :'attachmentCount',
  92. :'recipient_count' => :'recipientCount',
  93. :'campaign_class' => :'campaignClass',
  94. :'campaign_id' => :'campaignId',
  95. :'bw_latency' => :'bwLatency',
  96. :'carrier_latency' => :'carrierLatency',
  97. :'calling_number_country_a3' => :'callingNumberCountryA3',
  98. :'called_number_country_a3' => :'calledNumberCountryA3',
  99. :'product' => :'product',
  100. :'location' => :'location'
  101. }
  102. end
  103. # Returns attribute mapping this model knows about
  104. 1 def self.acceptable_attribute_map
  105. 13 attribute_map
  106. end
  107. # Returns all the JSON keys this model knows about
  108. 1 def self.acceptable_attributes
  109. 1 acceptable_attribute_map.values
  110. end
  111. # Attribute type mapping.
  112. 1 def self.openapi_types
  113. 3 {
  114. :'message_id' => :'String',
  115. :'account_id' => :'String',
  116. :'source_tn' => :'String',
  117. :'destination_tn' => :'String',
  118. :'message_status' => :'MessageStatusEnum',
  119. :'message_direction' => :'ListMessageDirectionEnum',
  120. :'message_type' => :'MessageTypeEnum',
  121. :'segment_count' => :'Integer',
  122. :'error_code' => :'Integer',
  123. :'receive_time' => :'Time',
  124. :'carrier_name' => :'String',
  125. :'message_size' => :'Integer',
  126. :'message_length' => :'Integer',
  127. :'attachment_count' => :'Integer',
  128. :'recipient_count' => :'Integer',
  129. :'campaign_class' => :'String',
  130. :'campaign_id' => :'String',
  131. :'bw_latency' => :'Integer',
  132. :'carrier_latency' => :'Integer',
  133. :'calling_number_country_a3' => :'String',
  134. :'called_number_country_a3' => :'String',
  135. :'product' => :'String',
  136. :'location' => :'String'
  137. }
  138. end
  139. # List of attributes with nullable: true
  140. 1 def self.openapi_nullable
  141. 43 Set.new([
  142. :'carrier_name',
  143. :'message_size',
  144. :'attachment_count',
  145. :'recipient_count',
  146. :'campaign_class',
  147. :'campaign_id',
  148. :'bw_latency',
  149. :'carrier_latency',
  150. :'calling_number_country_a3',
  151. :'called_number_country_a3',
  152. :'product',
  153. :'location'
  154. ])
  155. end
  156. # Initializes the object
  157. # @param [Hash] attributes Model attributes in the form of hash
  158. 1 def initialize(attributes = {})
  159. 13 if (!attributes.is_a?(Hash))
  160. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::ListMessageItem` initialize method'
  161. end
  162. # check to see if the attribute exists and convert string to symbol for hash key
  163. 12 acceptable_attribute_map = self.class.acceptable_attribute_map
  164. 12 attributes = attributes.each_with_object({}) { |(k, v), h|
  165. 124 if (!acceptable_attribute_map.key?(k.to_sym))
  166. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ListMessageItem`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  167. end
  168. 123 h[k.to_sym] = v
  169. }
  170. 11 if attributes.key?(:'message_id')
  171. 9 self.message_id = attributes[:'message_id']
  172. end
  173. 11 if attributes.key?(:'account_id')
  174. 5 self.account_id = attributes[:'account_id']
  175. end
  176. 11 if attributes.key?(:'source_tn')
  177. 5 self.source_tn = attributes[:'source_tn']
  178. end
  179. 11 if attributes.key?(:'destination_tn')
  180. 5 self.destination_tn = attributes[:'destination_tn']
  181. end
  182. 11 if attributes.key?(:'message_status')
  183. 5 self.message_status = attributes[:'message_status']
  184. end
  185. 11 if attributes.key?(:'message_direction')
  186. 5 self.message_direction = attributes[:'message_direction']
  187. end
  188. 11 if attributes.key?(:'message_type')
  189. 5 self.message_type = attributes[:'message_type']
  190. end
  191. 11 if attributes.key?(:'segment_count')
  192. 5 self.segment_count = attributes[:'segment_count']
  193. end
  194. 11 if attributes.key?(:'error_code')
  195. 5 self.error_code = attributes[:'error_code']
  196. end
  197. 11 if attributes.key?(:'receive_time')
  198. 5 self.receive_time = attributes[:'receive_time']
  199. end
  200. 11 if attributes.key?(:'carrier_name')
  201. 5 self.carrier_name = attributes[:'carrier_name']
  202. end
  203. 11 if attributes.key?(:'message_size')
  204. 5 self.message_size = attributes[:'message_size']
  205. end
  206. 11 if attributes.key?(:'message_length')
  207. 9 self.message_length = attributes[:'message_length']
  208. end
  209. 11 if attributes.key?(:'attachment_count')
  210. 5 self.attachment_count = attributes[:'attachment_count']
  211. end
  212. 11 if attributes.key?(:'recipient_count')
  213. 5 self.recipient_count = attributes[:'recipient_count']
  214. end
  215. 11 if attributes.key?(:'campaign_class')
  216. 5 self.campaign_class = attributes[:'campaign_class']
  217. end
  218. 11 if attributes.key?(:'campaign_id')
  219. 5 self.campaign_id = attributes[:'campaign_id']
  220. end
  221. 11 if attributes.key?(:'bw_latency')
  222. 5 self.bw_latency = attributes[:'bw_latency']
  223. end
  224. 11 if attributes.key?(:'carrier_latency')
  225. 5 self.carrier_latency = attributes[:'carrier_latency']
  226. end
  227. 11 if attributes.key?(:'calling_number_country_a3')
  228. 5 self.calling_number_country_a3 = attributes[:'calling_number_country_a3']
  229. end
  230. 11 if attributes.key?(:'called_number_country_a3')
  231. 5 self.called_number_country_a3 = attributes[:'called_number_country_a3']
  232. end
  233. 11 if attributes.key?(:'product')
  234. 5 self.product = attributes[:'product']
  235. end
  236. 11 if attributes.key?(:'location')
  237. 5 self.location = attributes[:'location']
  238. end
  239. end
  240. # Show invalid properties with the reasons. Usually used together with valid?
  241. # @return Array for valid properties with the reasons
  242. 1 def list_invalid_properties
  243. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  244. invalid_properties = Array.new
  245. invalid_properties
  246. end
  247. # Check to see if the all the properties in the model are valid
  248. # @return true if the model is valid
  249. 1 def valid?
  250. warn '[DEPRECATED] the `valid?` method is obsolete'
  251. true
  252. end
  253. # Checks equality by comparing each attribute.
  254. # @param [Object] Object to be compared
  255. 1 def ==(o)
  256. 2 return true if self.equal?(o)
  257. 2 self.class == o.class &&
  258. message_id == o.message_id &&
  259. account_id == o.account_id &&
  260. source_tn == o.source_tn &&
  261. destination_tn == o.destination_tn &&
  262. message_status == o.message_status &&
  263. message_direction == o.message_direction &&
  264. message_type == o.message_type &&
  265. segment_count == o.segment_count &&
  266. error_code == o.error_code &&
  267. receive_time == o.receive_time &&
  268. carrier_name == o.carrier_name &&
  269. message_size == o.message_size &&
  270. message_length == o.message_length &&
  271. attachment_count == o.attachment_count &&
  272. recipient_count == o.recipient_count &&
  273. campaign_class == o.campaign_class &&
  274. campaign_id == o.campaign_id &&
  275. bw_latency == o.bw_latency &&
  276. carrier_latency == o.carrier_latency &&
  277. calling_number_country_a3 == o.calling_number_country_a3 &&
  278. called_number_country_a3 == o.called_number_country_a3 &&
  279. product == o.product &&
  280. location == o.location
  281. end
  282. # @see the `==` method
  283. # @param [Object] Object to be compared
  284. 1 def eql?(o)
  285. 2 self == o
  286. end
  287. # Calculates hash code according to all attributes.
  288. # @return [Integer] Hash code
  289. 1 def hash
  290. [message_id, account_id, source_tn, destination_tn, message_status, message_direction, message_type, segment_count, error_code, receive_time, carrier_name, message_size, message_length, attachment_count, recipient_count, campaign_class, campaign_id, bw_latency, carrier_latency, calling_number_country_a3, called_number_country_a3, product, location].hash
  291. end
  292. # Builds the object from hash
  293. # @param [Hash] attributes Model attributes in the form of hash
  294. # @return [Object] Returns the model itself
  295. 1 def self.build_from_hash(attributes)
  296. 3 return nil unless attributes.is_a?(Hash)
  297. 3 attributes = attributes.transform_keys(&:to_sym)
  298. 3 transformed_hash = {}
  299. 3 openapi_types.each_pair do |key, type|
  300. 69 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  301. transformed_hash["#{key}"] = nil
  302. 69 elsif type =~ /\AArray<(.*)>/i
  303. # check to ensure the input is an array given that the attribute
  304. # is documented as an array but the input is not
  305. if attributes[attribute_map[key]].is_a?(Array)
  306. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  307. end
  308. 69 elsif !attributes[attribute_map[key]].nil?
  309. 48 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  310. end
  311. end
  312. 3 new(transformed_hash)
  313. end
  314. # Returns the object in the form of hash
  315. # @return [Hash] Returns the object in the form of hash
  316. 1 def to_hash
  317. 4 hash = {}
  318. 4 self.class.attribute_map.each_pair do |attr, param|
  319. 92 value = self.send(attr)
  320. 92 if value.nil?
  321. 42 is_nullable = self.class.openapi_nullable.include?(attr)
  322. 42 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  323. end
  324. 50 hash[param] = _to_hash(value)
  325. end
  326. 4 hash
  327. end
  328. end
  329. end

lib/bandwidth-sdk/models/lookup_error_response.rb

86.96% lines covered

69 relevant lines. 60 lines covered and 9 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class LookupErrorResponse < ApiModelBase
  13. 1 attr_accessor :links
  14. # The phone number lookup response data
  15. 1 attr_accessor :data
  16. 1 attr_accessor :errors
  17. # Attribute mapping from ruby-style variable name to JSON key.
  18. 1 def self.attribute_map
  19. 23 {
  20. :'links' => :'links',
  21. :'data' => :'data',
  22. :'errors' => :'errors'
  23. }
  24. end
  25. # Returns attribute mapping this model knows about
  26. 1 def self.acceptable_attribute_map
  27. 8 attribute_map
  28. end
  29. # Returns all the JSON keys this model knows about
  30. 1 def self.acceptable_attributes
  31. 1 acceptable_attribute_map.values
  32. end
  33. # Attribute type mapping.
  34. 1 def self.openapi_types
  35. 1 {
  36. :'links' => :'Array<LinkSchema>',
  37. :'data' => :'Object',
  38. :'errors' => :'Array<LookupErrorSchema>'
  39. }
  40. end
  41. # List of attributes with nullable: true
  42. 1 def self.openapi_nullable
  43. 1 Set.new([
  44. ])
  45. end
  46. # Initializes the object
  47. # @param [Hash] attributes Model attributes in the form of hash
  48. 1 def initialize(attributes = {})
  49. 8 if (!attributes.is_a?(Hash))
  50. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::LookupErrorResponse` initialize method'
  51. end
  52. # check to see if the attribute exists and convert string to symbol for hash key
  53. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  54. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  55. 13 if (!acceptable_attribute_map.key?(k.to_sym))
  56. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::LookupErrorResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  57. end
  58. 12 h[k.to_sym] = v
  59. }
  60. 6 if attributes.key?(:'links')
  61. 4 if (value = attributes[:'links']).is_a?(Array)
  62. 4 self.links = value
  63. end
  64. end
  65. 6 if attributes.key?(:'data')
  66. 4 self.data = attributes[:'data']
  67. end
  68. 6 if attributes.key?(:'errors')
  69. 4 if (value = attributes[:'errors']).is_a?(Array)
  70. 4 self.errors = value
  71. end
  72. end
  73. end
  74. # Show invalid properties with the reasons. Usually used together with valid?
  75. # @return Array for valid properties with the reasons
  76. 1 def list_invalid_properties
  77. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  78. invalid_properties = Array.new
  79. invalid_properties
  80. end
  81. # Check to see if the all the properties in the model are valid
  82. # @return true if the model is valid
  83. 1 def valid?
  84. warn '[DEPRECATED] the `valid?` method is obsolete'
  85. true
  86. end
  87. # Checks equality by comparing each attribute.
  88. # @param [Object] Object to be compared
  89. 1 def ==(o)
  90. 2 return true if self.equal?(o)
  91. 2 self.class == o.class &&
  92. links == o.links &&
  93. data == o.data &&
  94. errors == o.errors
  95. end
  96. # @see the `==` method
  97. # @param [Object] Object to be compared
  98. 1 def eql?(o)
  99. 2 self == o
  100. end
  101. # Calculates hash code according to all attributes.
  102. # @return [Integer] Hash code
  103. 1 def hash
  104. [links, data, errors].hash
  105. end
  106. # Builds the object from hash
  107. # @param [Hash] attributes Model attributes in the form of hash
  108. # @return [Object] Returns the model itself
  109. 1 def self.build_from_hash(attributes)
  110. 1 return nil unless attributes.is_a?(Hash)
  111. 1 attributes = attributes.transform_keys(&:to_sym)
  112. 1 transformed_hash = {}
  113. 1 openapi_types.each_pair do |key, type|
  114. 3 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  115. transformed_hash["#{key}"] = nil
  116. 3 elsif type =~ /\AArray<(.*)>/i
  117. # check to ensure the input is an array given that the attribute
  118. # is documented as an array but the input is not
  119. 2 if attributes[attribute_map[key]].is_a?(Array)
  120. 4 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  121. end
  122. 1 elsif !attributes[attribute_map[key]].nil?
  123. 1 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  124. end
  125. end
  126. 1 new(transformed_hash)
  127. end
  128. # Returns the object in the form of hash
  129. # @return [Hash] Returns the object in the form of hash
  130. 1 def to_hash
  131. 2 hash = {}
  132. 2 self.class.attribute_map.each_pair do |attr, param|
  133. 6 value = self.send(attr)
  134. 6 if value.nil?
  135. is_nullable = self.class.openapi_nullable.include?(attr)
  136. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  137. end
  138. 6 hash[param] = _to_hash(value)
  139. end
  140. 2 hash
  141. end
  142. end
  143. end

lib/bandwidth-sdk/models/lookup_error_schema.rb

77.66% lines covered

94 relevant lines. 73 lines covered and 21 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class LookupErrorSchema < ApiModelBase
  13. # Validation error code
  14. 1 attr_accessor :code
  15. # Description of validation error
  16. 1 attr_accessor :description
  17. # Type of validation error
  18. 1 attr_accessor :type
  19. 1 attr_accessor :meta
  20. # Attribute mapping from ruby-style variable name to JSON key.
  21. 1 def self.attribute_map
  22. 110 {
  23. :'code' => :'code',
  24. :'description' => :'description',
  25. :'type' => :'type',
  26. :'meta' => :'meta'
  27. }
  28. end
  29. # Returns attribute mapping this model knows about
  30. 1 def self.acceptable_attribute_map
  31. 27 attribute_map
  32. end
  33. # Returns all the JSON keys this model knows about
  34. 1 def self.acceptable_attributes
  35. 1 acceptable_attribute_map.values
  36. end
  37. # Attribute type mapping.
  38. 1 def self.openapi_types
  39. 5 {
  40. :'code' => :'String',
  41. :'description' => :'String',
  42. :'type' => :'String',
  43. :'meta' => :'LookupErrorSchemaMeta'
  44. }
  45. end
  46. # List of attributes with nullable: true
  47. 1 def self.openapi_nullable
  48. 9 Set.new([
  49. ])
  50. end
  51. # Initializes the object
  52. # @param [Hash] attributes Model attributes in the form of hash
  53. 1 def initialize(attributes = {})
  54. 27 if (!attributes.is_a?(Hash))
  55. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::LookupErrorSchema` initialize method'
  56. end
  57. # check to see if the attribute exists and convert string to symbol for hash key
  58. 26 acceptable_attribute_map = self.class.acceptable_attribute_map
  59. 26 attributes = attributes.each_with_object({}) { |(k, v), h|
  60. 77 if (!acceptable_attribute_map.key?(k.to_sym))
  61. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::LookupErrorSchema`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  62. end
  63. 76 h[k.to_sym] = v
  64. }
  65. 25 if attributes.key?(:'code')
  66. 25 self.code = attributes[:'code']
  67. else
  68. self.code = nil
  69. end
  70. 24 if attributes.key?(:'description')
  71. 24 self.description = attributes[:'description']
  72. else
  73. self.description = nil
  74. end
  75. 23 if attributes.key?(:'type')
  76. 23 self.type = attributes[:'type']
  77. else
  78. self.type = nil
  79. end
  80. 22 if attributes.key?(:'meta')
  81. 4 self.meta = attributes[:'meta']
  82. end
  83. end
  84. # Show invalid properties with the reasons. Usually used together with valid?
  85. # @return Array for valid properties with the reasons
  86. 1 def list_invalid_properties
  87. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  88. invalid_properties = Array.new
  89. if @code.nil?
  90. invalid_properties.push('invalid value for "code", code cannot be nil.')
  91. end
  92. if @description.nil?
  93. invalid_properties.push('invalid value for "description", description cannot be nil.')
  94. end
  95. if @type.nil?
  96. invalid_properties.push('invalid value for "type", type cannot be nil.')
  97. end
  98. invalid_properties
  99. end
  100. # Check to see if the all the properties in the model are valid
  101. # @return true if the model is valid
  102. 1 def valid?
  103. warn '[DEPRECATED] the `valid?` method is obsolete'
  104. return false if @code.nil?
  105. return false if @description.nil?
  106. return false if @type.nil?
  107. true
  108. end
  109. # Custom attribute writer method with validation
  110. # @param [Object] code Value to be assigned
  111. 1 def code=(code)
  112. 25 if code.nil?
  113. 1 fail ArgumentError, 'code cannot be nil'
  114. end
  115. 24 @code = code
  116. end
  117. # Custom attribute writer method with validation
  118. # @param [Object] description Value to be assigned
  119. 1 def description=(description)
  120. 24 if description.nil?
  121. 1 fail ArgumentError, 'description cannot be nil'
  122. end
  123. 23 @description = description
  124. end
  125. # Custom attribute writer method with validation
  126. # @param [Object] type Value to be assigned
  127. 1 def type=(type)
  128. 23 if type.nil?
  129. 1 fail ArgumentError, 'type cannot be nil'
  130. end
  131. 22 @type = type
  132. end
  133. # Checks equality by comparing each attribute.
  134. # @param [Object] Object to be compared
  135. 1 def ==(o)
  136. 2 return true if self.equal?(o)
  137. 2 self.class == o.class &&
  138. code == o.code &&
  139. description == o.description &&
  140. type == o.type &&
  141. meta == o.meta
  142. end
  143. # @see the `==` method
  144. # @param [Object] Object to be compared
  145. 1 def eql?(o)
  146. 2 self == o
  147. end
  148. # Calculates hash code according to all attributes.
  149. # @return [Integer] Hash code
  150. 1 def hash
  151. [code, description, type, meta].hash
  152. end
  153. # Builds the object from hash
  154. # @param [Hash] attributes Model attributes in the form of hash
  155. # @return [Object] Returns the model itself
  156. 1 def self.build_from_hash(attributes)
  157. 5 return nil unless attributes.is_a?(Hash)
  158. 5 attributes = attributes.transform_keys(&:to_sym)
  159. 5 transformed_hash = {}
  160. 5 openapi_types.each_pair do |key, type|
  161. 20 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  162. transformed_hash["#{key}"] = nil
  163. 20 elsif type =~ /\AArray<(.*)>/i
  164. # check to ensure the input is an array given that the attribute
  165. # is documented as an array but the input is not
  166. if attributes[attribute_map[key]].is_a?(Array)
  167. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  168. end
  169. 20 elsif !attributes[attribute_map[key]].nil?
  170. 16 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  171. end
  172. end
  173. 5 new(transformed_hash)
  174. end
  175. # Returns the object in the form of hash
  176. # @return [Hash] Returns the object in the form of hash
  177. 1 def to_hash
  178. 10 hash = {}
  179. 10 self.class.attribute_map.each_pair do |attr, param|
  180. 40 value = self.send(attr)
  181. 40 if value.nil?
  182. 8 is_nullable = self.class.openapi_nullable.include?(attr)
  183. 8 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  184. end
  185. 32 hash[param] = _to_hash(value)
  186. end
  187. 10 hash
  188. end
  189. end
  190. end

lib/bandwidth-sdk/models/lookup_error_schema_meta.rb

86.76% lines covered

68 relevant lines. 59 lines covered and 9 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class LookupErrorSchemaMeta < ApiModelBase
  13. 1 attr_accessor :phone_numbers
  14. # Message describing the error
  15. 1 attr_accessor :message
  16. # Error code associated with the message
  17. 1 attr_accessor :code
  18. # Attribute mapping from ruby-style variable name to JSON key.
  19. 1 def self.attribute_map
  20. 41 {
  21. :'phone_numbers' => :'phoneNumbers',
  22. :'message' => :'message',
  23. :'code' => :'code'
  24. }
  25. end
  26. # Returns attribute mapping this model knows about
  27. 1 def self.acceptable_attribute_map
  28. 12 attribute_map
  29. end
  30. # Returns all the JSON keys this model knows about
  31. 1 def self.acceptable_attributes
  32. 1 acceptable_attribute_map.values
  33. end
  34. # Attribute type mapping.
  35. 1 def self.openapi_types
  36. 2 {
  37. :'phone_numbers' => :'Array<String>',
  38. :'message' => :'String',
  39. :'code' => :'Integer'
  40. }
  41. end
  42. # List of attributes with nullable: true
  43. 1 def self.openapi_nullable
  44. 1 Set.new([
  45. ])
  46. end
  47. # Initializes the object
  48. # @param [Hash] attributes Model attributes in the form of hash
  49. 1 def initialize(attributes = {})
  50. 12 if (!attributes.is_a?(Hash))
  51. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::LookupErrorSchemaMeta` initialize method'
  52. end
  53. # check to see if the attribute exists and convert string to symbol for hash key
  54. 11 acceptable_attribute_map = self.class.acceptable_attribute_map
  55. 11 attributes = attributes.each_with_object({}) { |(k, v), h|
  56. 25 if (!acceptable_attribute_map.key?(k.to_sym))
  57. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::LookupErrorSchemaMeta`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  58. end
  59. 24 h[k.to_sym] = v
  60. }
  61. 10 if attributes.key?(:'phone_numbers')
  62. 8 if (value = attributes[:'phone_numbers']).is_a?(Array)
  63. 8 self.phone_numbers = value
  64. end
  65. end
  66. 10 if attributes.key?(:'message')
  67. 8 self.message = attributes[:'message']
  68. end
  69. 10 if attributes.key?(:'code')
  70. 8 self.code = attributes[:'code']
  71. end
  72. end
  73. # Show invalid properties with the reasons. Usually used together with valid?
  74. # @return Array for valid properties with the reasons
  75. 1 def list_invalid_properties
  76. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  77. invalid_properties = Array.new
  78. invalid_properties
  79. end
  80. # Check to see if the all the properties in the model are valid
  81. # @return true if the model is valid
  82. 1 def valid?
  83. warn '[DEPRECATED] the `valid?` method is obsolete'
  84. true
  85. end
  86. # Checks equality by comparing each attribute.
  87. # @param [Object] Object to be compared
  88. 1 def ==(o)
  89. 2 return true if self.equal?(o)
  90. 2 self.class == o.class &&
  91. phone_numbers == o.phone_numbers &&
  92. message == o.message &&
  93. code == o.code
  94. end
  95. # @see the `==` method
  96. # @param [Object] Object to be compared
  97. 1 def eql?(o)
  98. 2 self == o
  99. end
  100. # Calculates hash code according to all attributes.
  101. # @return [Integer] Hash code
  102. 1 def hash
  103. [phone_numbers, message, code].hash
  104. end
  105. # Builds the object from hash
  106. # @param [Hash] attributes Model attributes in the form of hash
  107. # @return [Object] Returns the model itself
  108. 1 def self.build_from_hash(attributes)
  109. 2 return nil unless attributes.is_a?(Hash)
  110. 2 attributes = attributes.transform_keys(&:to_sym)
  111. 2 transformed_hash = {}
  112. 2 openapi_types.each_pair do |key, type|
  113. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  114. transformed_hash["#{key}"] = nil
  115. 6 elsif type =~ /\AArray<(.*)>/i
  116. # check to ensure the input is an array given that the attribute
  117. # is documented as an array but the input is not
  118. 2 if attributes[attribute_map[key]].is_a?(Array)
  119. 4 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  120. end
  121. 4 elsif !attributes[attribute_map[key]].nil?
  122. 4 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  123. end
  124. end
  125. 2 new(transformed_hash)
  126. end
  127. # Returns the object in the form of hash
  128. # @return [Hash] Returns the object in the form of hash
  129. 1 def to_hash
  130. 4 hash = {}
  131. 4 self.class.attribute_map.each_pair do |attr, param|
  132. 12 value = self.send(attr)
  133. 12 if value.nil?
  134. is_nullable = self.class.openapi_nullable.include?(attr)
  135. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  136. end
  137. 12 hash[param] = _to_hash(value)
  138. end
  139. 4 hash
  140. end
  141. end
  142. end

lib/bandwidth-sdk/models/lookup_result.rb

85.71% lines covered

105 relevant lines. 90 lines covered and 15 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # Carrier information results for the specified telephone number.
  13. 1 class LookupResult < ApiModelBase
  14. # The telephone number in E.164 format.
  15. 1 attr_accessor :phone_number
  16. 1 attr_accessor :line_type
  17. # The messaging service provider of the telephone number.
  18. 1 attr_accessor :messaging_provider
  19. # The voice service provider of the telephone number.
  20. 1 attr_accessor :voice_provider
  21. # The country code of the telephone number in ISO 3166-1 alpha-3 format.
  22. 1 attr_accessor :country_code_a3
  23. # [DNI-Only](#section/DNI-Only). The carrier that reported a deactivation event for this phone number.
  24. 1 attr_accessor :deactivation_reporter
  25. # [DNI-Only](#section/DNI-Only). The datetime the carrier reported a deactivation event.
  26. 1 attr_accessor :deactivation_date
  27. 1 attr_accessor :deactivation_event
  28. 1 attr_accessor :latest_message_delivery_status
  29. # [DNI-Only](#section/DNI-Only). The date the phone number entered the status described in `latestMessageDeliveryStatus`. Think of this as the \"start time\" for that status. Value resets every time the `latestMessageDeliveryStatus` changes.
  30. 1 attr_accessor :initial_message_delivery_status_date
  31. # [DNI-Only](#section/DNI-Only). The date bandwidth last received delivery status information for this phone number. Use this field to understand how up-to-date the `latestMessageDeliveryStatus` is. Value resets every time the `latestMessageDeliveryStatus` changes.
  32. 1 attr_accessor :latest_message_delivery_status_date
  33. # [RCS-Only](#section/RCS-Only). Indicates whether the phone number is capable of receiving RCS messages. Value will be null if account has RCS, but no value was returned. Absent when account does not have RCS.
  34. 1 attr_accessor :rcs_enabled
  35. 1 class EnumAttributeValidator
  36. 1 attr_reader :datatype
  37. 1 attr_reader :allowable_values
  38. 1 def initialize(datatype, allowable_values)
  39. @allowable_values = allowable_values.map do |value|
  40. case datatype.to_s
  41. when /Integer/i
  42. value.to_i
  43. when /Float/i
  44. value.to_f
  45. else
  46. value
  47. end
  48. end
  49. end
  50. 1 def valid?(value)
  51. !value || allowable_values.include?(value)
  52. end
  53. end
  54. # Attribute mapping from ruby-style variable name to JSON key.
  55. 1 def self.attribute_map
  56. 451 {
  57. :'phone_number' => :'phoneNumber',
  58. :'line_type' => :'lineType',
  59. :'messaging_provider' => :'messagingProvider',
  60. :'voice_provider' => :'voiceProvider',
  61. :'country_code_a3' => :'countryCodeA3',
  62. :'deactivation_reporter' => :'deactivationReporter',
  63. :'deactivation_date' => :'deactivationDate',
  64. :'deactivation_event' => :'deactivationEvent',
  65. :'latest_message_delivery_status' => :'latestMessageDeliveryStatus',
  66. :'initial_message_delivery_status_date' => :'initialMessageDeliveryStatusDate',
  67. :'latest_message_delivery_status_date' => :'latestMessageDeliveryStatusDate',
  68. :'rcs_enabled' => :'rcsEnabled'
  69. }
  70. end
  71. # Returns attribute mapping this model knows about
  72. 1 def self.acceptable_attribute_map
  73. 24 attribute_map
  74. end
  75. # Returns all the JSON keys this model knows about
  76. 1 def self.acceptable_attributes
  77. 1 acceptable_attribute_map.values
  78. end
  79. # Attribute type mapping.
  80. 1 def self.openapi_types
  81. 11 {
  82. :'phone_number' => :'String',
  83. :'line_type' => :'LineTypeEnum',
  84. :'messaging_provider' => :'String',
  85. :'voice_provider' => :'String',
  86. :'country_code_a3' => :'String',
  87. :'deactivation_reporter' => :'String',
  88. :'deactivation_date' => :'String',
  89. :'deactivation_event' => :'DeactivationEventEnum',
  90. :'latest_message_delivery_status' => :'LatestMessageDeliveryStatusEnum',
  91. :'initial_message_delivery_status_date' => :'Date',
  92. :'latest_message_delivery_status_date' => :'Date',
  93. :'rcs_enabled' => :'Boolean'
  94. }
  95. end
  96. # List of attributes with nullable: true
  97. 1 def self.openapi_nullable
  98. 45 Set.new([
  99. ])
  100. end
  101. # Initializes the object
  102. # @param [Hash] attributes Model attributes in the form of hash
  103. 1 def initialize(attributes = {})
  104. 24 if (!attributes.is_a?(Hash))
  105. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::LookupResult` initialize method'
  106. end
  107. # check to see if the attribute exists and convert string to symbol for hash key
  108. 23 acceptable_attribute_map = self.class.acceptable_attribute_map
  109. 23 attributes = attributes.each_with_object({}) { |(k, v), h|
  110. 121 if (!acceptable_attribute_map.key?(k.to_sym))
  111. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::LookupResult`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  112. end
  113. 120 h[k.to_sym] = v
  114. }
  115. 22 if attributes.key?(:'phone_number')
  116. 20 self.phone_number = attributes[:'phone_number']
  117. end
  118. 22 if attributes.key?(:'line_type')
  119. 12 self.line_type = attributes[:'line_type']
  120. end
  121. 22 if attributes.key?(:'messaging_provider')
  122. 8 self.messaging_provider = attributes[:'messaging_provider']
  123. end
  124. 22 if attributes.key?(:'voice_provider')
  125. 12 self.voice_provider = attributes[:'voice_provider']
  126. end
  127. 22 if attributes.key?(:'country_code_a3')
  128. 12 self.country_code_a3 = attributes[:'country_code_a3']
  129. end
  130. 22 if attributes.key?(:'deactivation_reporter')
  131. 8 self.deactivation_reporter = attributes[:'deactivation_reporter']
  132. end
  133. 22 if attributes.key?(:'deactivation_date')
  134. 8 self.deactivation_date = attributes[:'deactivation_date']
  135. end
  136. 22 if attributes.key?(:'deactivation_event')
  137. 8 self.deactivation_event = attributes[:'deactivation_event']
  138. end
  139. 22 if attributes.key?(:'latest_message_delivery_status')
  140. 12 self.latest_message_delivery_status = attributes[:'latest_message_delivery_status']
  141. end
  142. 22 if attributes.key?(:'initial_message_delivery_status_date')
  143. 8 self.initial_message_delivery_status_date = attributes[:'initial_message_delivery_status_date']
  144. end
  145. 22 if attributes.key?(:'latest_message_delivery_status_date')
  146. 8 self.latest_message_delivery_status_date = attributes[:'latest_message_delivery_status_date']
  147. end
  148. 22 if attributes.key?(:'rcs_enabled')
  149. 4 self.rcs_enabled = attributes[:'rcs_enabled']
  150. end
  151. end
  152. # Show invalid properties with the reasons. Usually used together with valid?
  153. # @return Array for valid properties with the reasons
  154. 1 def list_invalid_properties
  155. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  156. invalid_properties = Array.new
  157. invalid_properties
  158. end
  159. # Check to see if the all the properties in the model are valid
  160. # @return true if the model is valid
  161. 1 def valid?
  162. warn '[DEPRECATED] the `valid?` method is obsolete'
  163. true
  164. end
  165. # Checks equality by comparing each attribute.
  166. # @param [Object] Object to be compared
  167. 1 def ==(o)
  168. 2 return true if self.equal?(o)
  169. 2 self.class == o.class &&
  170. phone_number == o.phone_number &&
  171. line_type == o.line_type &&
  172. messaging_provider == o.messaging_provider &&
  173. voice_provider == o.voice_provider &&
  174. country_code_a3 == o.country_code_a3 &&
  175. deactivation_reporter == o.deactivation_reporter &&
  176. deactivation_date == o.deactivation_date &&
  177. deactivation_event == o.deactivation_event &&
  178. latest_message_delivery_status == o.latest_message_delivery_status &&
  179. initial_message_delivery_status_date == o.initial_message_delivery_status_date &&
  180. latest_message_delivery_status_date == o.latest_message_delivery_status_date &&
  181. rcs_enabled == o.rcs_enabled
  182. end
  183. # @see the `==` method
  184. # @param [Object] Object to be compared
  185. 1 def eql?(o)
  186. 2 self == o
  187. end
  188. # Calculates hash code according to all attributes.
  189. # @return [Integer] Hash code
  190. 1 def hash
  191. [phone_number, line_type, messaging_provider, voice_provider, country_code_a3, deactivation_reporter, deactivation_date, deactivation_event, latest_message_delivery_status, initial_message_delivery_status_date, latest_message_delivery_status_date, rcs_enabled].hash
  192. end
  193. # Builds the object from hash
  194. # @param [Hash] attributes Model attributes in the form of hash
  195. # @return [Object] Returns the model itself
  196. 1 def self.build_from_hash(attributes)
  197. 11 return nil unless attributes.is_a?(Hash)
  198. 11 attributes = attributes.transform_keys(&:to_sym)
  199. 11 transformed_hash = {}
  200. 11 openapi_types.each_pair do |key, type|
  201. 132 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  202. transformed_hash["#{key}"] = nil
  203. 132 elsif type =~ /\AArray<(.*)>/i
  204. # check to ensure the input is an array given that the attribute
  205. # is documented as an array but the input is not
  206. if attributes[attribute_map[key]].is_a?(Array)
  207. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  208. end
  209. 132 elsif !attributes[attribute_map[key]].nil?
  210. 78 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  211. end
  212. end
  213. 11 new(transformed_hash)
  214. end
  215. # Returns the object in the form of hash
  216. # @return [Hash] Returns the object in the form of hash
  217. 1 def to_hash
  218. 6 hash = {}
  219. 6 self.class.attribute_map.each_pair do |attr, param|
  220. 72 value = self.send(attr)
  221. 72 if value.nil?
  222. 44 is_nullable = self.class.openapi_nullable.include?(attr)
  223. 44 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  224. end
  225. 28 hash[param] = _to_hash(value)
  226. end
  227. 6 hash
  228. end
  229. end
  230. end

lib/bandwidth-sdk/models/machine_detection_complete_callback.rb

84.68% lines covered

111 relevant lines. 94 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # This event is sent to the url informed when requesting a machine detection operation. It contains the machine detection operation result, which can be: human, answering-machine, silence, timeout, error. This event is not sent when sync answering machine detection mode is chosen.
  13. 1 class MachineDetectionCompleteCallback < ApiModelBase
  14. # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect.
  15. 1 attr_accessor :event_type
  16. # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.
  17. 1 attr_accessor :event_time
  18. # The user account associated with the call.
  19. 1 attr_accessor :account_id
  20. # The id of the application associated with the call.
  21. 1 attr_accessor :application_id
  22. # The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555).
  23. 1 attr_accessor :from
  24. # The phone number that received the call, in E.164 format (e.g. +15555555555).
  25. 1 attr_accessor :to
  26. 1 attr_accessor :direction
  27. # The call id associated with the event.
  28. 1 attr_accessor :call_id
  29. # The URL of the call associated with the event.
  30. 1 attr_accessor :call_url
  31. # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format.
  32. 1 attr_accessor :enqueued_time
  33. # Time the call was started, in ISO 8601 format.
  34. 1 attr_accessor :start_time
  35. # Time the call was answered, in ISO 8601 format.
  36. 1 attr_accessor :answer_time
  37. # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.
  38. 1 attr_accessor :tag
  39. 1 attr_accessor :machine_detection_result
  40. 1 class EnumAttributeValidator
  41. 1 attr_reader :datatype
  42. 1 attr_reader :allowable_values
  43. 1 def initialize(datatype, allowable_values)
  44. @allowable_values = allowable_values.map do |value|
  45. case datatype.to_s
  46. when /Integer/i
  47. value.to_i
  48. when /Float/i
  49. value.to_f
  50. else
  51. value
  52. end
  53. end
  54. end
  55. 1 def valid?(value)
  56. !value || allowable_values.include?(value)
  57. end
  58. end
  59. # Attribute mapping from ruby-style variable name to JSON key.
  60. 1 def self.attribute_map
  61. 67 {
  62. :'event_type' => :'eventType',
  63. :'event_time' => :'eventTime',
  64. :'account_id' => :'accountId',
  65. :'application_id' => :'applicationId',
  66. :'from' => :'from',
  67. :'to' => :'to',
  68. :'direction' => :'direction',
  69. :'call_id' => :'callId',
  70. :'call_url' => :'callUrl',
  71. :'enqueued_time' => :'enqueuedTime',
  72. :'start_time' => :'startTime',
  73. :'answer_time' => :'answerTime',
  74. :'tag' => :'tag',
  75. :'machine_detection_result' => :'machineDetectionResult'
  76. }
  77. end
  78. # Returns attribute mapping this model knows about
  79. 1 def self.acceptable_attribute_map
  80. 8 attribute_map
  81. end
  82. # Returns all the JSON keys this model knows about
  83. 1 def self.acceptable_attributes
  84. 1 acceptable_attribute_map.values
  85. end
  86. # Attribute type mapping.
  87. 1 def self.openapi_types
  88. 1 {
  89. :'event_type' => :'String',
  90. :'event_time' => :'Time',
  91. :'account_id' => :'String',
  92. :'application_id' => :'String',
  93. :'from' => :'String',
  94. :'to' => :'String',
  95. :'direction' => :'CallDirectionEnum',
  96. :'call_id' => :'String',
  97. :'call_url' => :'String',
  98. :'enqueued_time' => :'Time',
  99. :'start_time' => :'Time',
  100. :'answer_time' => :'Time',
  101. :'tag' => :'String',
  102. :'machine_detection_result' => :'MachineDetectionResult'
  103. }
  104. end
  105. # List of attributes with nullable: true
  106. 1 def self.openapi_nullable
  107. 1 Set.new([
  108. :'enqueued_time',
  109. :'answer_time',
  110. :'tag',
  111. :'machine_detection_result'
  112. ])
  113. end
  114. # Initializes the object
  115. # @param [Hash] attributes Model attributes in the form of hash
  116. 1 def initialize(attributes = {})
  117. 8 if (!attributes.is_a?(Hash))
  118. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MachineDetectionCompleteCallback` initialize method'
  119. end
  120. # check to see if the attribute exists and convert string to symbol for hash key
  121. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  122. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  123. 57 if (!acceptable_attribute_map.key?(k.to_sym))
  124. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MachineDetectionCompleteCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  125. end
  126. 56 h[k.to_sym] = v
  127. }
  128. 6 if attributes.key?(:'event_type')
  129. 4 self.event_type = attributes[:'event_type']
  130. end
  131. 6 if attributes.key?(:'event_time')
  132. 4 self.event_time = attributes[:'event_time']
  133. end
  134. 6 if attributes.key?(:'account_id')
  135. 4 self.account_id = attributes[:'account_id']
  136. end
  137. 6 if attributes.key?(:'application_id')
  138. 4 self.application_id = attributes[:'application_id']
  139. end
  140. 6 if attributes.key?(:'from')
  141. 4 self.from = attributes[:'from']
  142. end
  143. 6 if attributes.key?(:'to')
  144. 4 self.to = attributes[:'to']
  145. end
  146. 6 if attributes.key?(:'direction')
  147. 4 self.direction = attributes[:'direction']
  148. end
  149. 6 if attributes.key?(:'call_id')
  150. 4 self.call_id = attributes[:'call_id']
  151. end
  152. 6 if attributes.key?(:'call_url')
  153. 4 self.call_url = attributes[:'call_url']
  154. end
  155. 6 if attributes.key?(:'enqueued_time')
  156. 4 self.enqueued_time = attributes[:'enqueued_time']
  157. end
  158. 6 if attributes.key?(:'start_time')
  159. 4 self.start_time = attributes[:'start_time']
  160. end
  161. 6 if attributes.key?(:'answer_time')
  162. 4 self.answer_time = attributes[:'answer_time']
  163. end
  164. 6 if attributes.key?(:'tag')
  165. 4 self.tag = attributes[:'tag']
  166. end
  167. 6 if attributes.key?(:'machine_detection_result')
  168. 4 self.machine_detection_result = attributes[:'machine_detection_result']
  169. end
  170. end
  171. # Show invalid properties with the reasons. Usually used together with valid?
  172. # @return Array for valid properties with the reasons
  173. 1 def list_invalid_properties
  174. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  175. invalid_properties = Array.new
  176. invalid_properties
  177. end
  178. # Check to see if the all the properties in the model are valid
  179. # @return true if the model is valid
  180. 1 def valid?
  181. warn '[DEPRECATED] the `valid?` method is obsolete'
  182. true
  183. end
  184. # Checks equality by comparing each attribute.
  185. # @param [Object] Object to be compared
  186. 1 def ==(o)
  187. 2 return true if self.equal?(o)
  188. 2 self.class == o.class &&
  189. event_type == o.event_type &&
  190. event_time == o.event_time &&
  191. account_id == o.account_id &&
  192. application_id == o.application_id &&
  193. from == o.from &&
  194. to == o.to &&
  195. direction == o.direction &&
  196. call_id == o.call_id &&
  197. call_url == o.call_url &&
  198. enqueued_time == o.enqueued_time &&
  199. start_time == o.start_time &&
  200. answer_time == o.answer_time &&
  201. tag == o.tag &&
  202. machine_detection_result == o.machine_detection_result
  203. end
  204. # @see the `==` method
  205. # @param [Object] Object to be compared
  206. 1 def eql?(o)
  207. 2 self == o
  208. end
  209. # Calculates hash code according to all attributes.
  210. # @return [Integer] Hash code
  211. 1 def hash
  212. [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, enqueued_time, start_time, answer_time, tag, machine_detection_result].hash
  213. end
  214. # Builds the object from hash
  215. # @param [Hash] attributes Model attributes in the form of hash
  216. # @return [Object] Returns the model itself
  217. 1 def self.build_from_hash(attributes)
  218. 1 return nil unless attributes.is_a?(Hash)
  219. 1 attributes = attributes.transform_keys(&:to_sym)
  220. 1 transformed_hash = {}
  221. 1 openapi_types.each_pair do |key, type|
  222. 14 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  223. transformed_hash["#{key}"] = nil
  224. 14 elsif type =~ /\AArray<(.*)>/i
  225. # check to ensure the input is an array given that the attribute
  226. # is documented as an array but the input is not
  227. if attributes[attribute_map[key]].is_a?(Array)
  228. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  229. end
  230. 14 elsif !attributes[attribute_map[key]].nil?
  231. 14 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  232. end
  233. end
  234. 1 new(transformed_hash)
  235. end
  236. # Returns the object in the form of hash
  237. # @return [Hash] Returns the object in the form of hash
  238. 1 def to_hash
  239. 2 hash = {}
  240. 2 self.class.attribute_map.each_pair do |attr, param|
  241. 28 value = self.send(attr)
  242. 28 if value.nil?
  243. is_nullable = self.class.openapi_nullable.include?(attr)
  244. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  245. end
  246. 28 hash[param] = _to_hash(value)
  247. end
  248. 2 hash
  249. end
  250. end
  251. end

lib/bandwidth-sdk/models/machine_detection_configuration.rb

78.66% lines covered

164 relevant lines. 129 lines covered and 35 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The machine detection request used to perform <a href='/docs/voice/guides/machineDetection'>machine detection</a> on the call. Currently, there is an issue where decimal values are not getting processed correctly. Please use whole number values. We are working to resolve this issue. Please contact Bandwidth Support if you need more information.
  13. 1 class MachineDetectionConfiguration < ApiModelBase
  14. 1 attr_accessor :mode
  15. # The timeout used for the whole operation, in seconds. If no result is determined in this period, a callback with a `timeout` result is sent.
  16. 1 attr_accessor :detection_timeout
  17. # If no speech is detected in this period, a callback with a 'silence' result is sent.
  18. 1 attr_accessor :silence_timeout
  19. # When speech has ended and a result couldn't be determined based on the audio content itself, this value is used to determine if the speaker is a machine based on the speech duration. If the length of the speech detected is greater than or equal to this threshold, the result will be 'answering-machine'. If the length of speech detected is below this threshold, the result will be 'human'.
  20. 1 attr_accessor :speech_threshold
  21. # Amount of silence (in seconds) before assuming the callee has finished speaking.
  22. 1 attr_accessor :speech_end_threshold
  23. # When an answering machine is detected, the amount of silence (in seconds) before assuming the message has finished playing. If not provided it will default to the speechEndThreshold value.
  24. 1 attr_accessor :machine_speech_end_threshold
  25. # If set to 'true' and if an answering machine is detected, the 'answering-machine' callback will be delayed until the machine is done speaking, or an end of message tone is detected, or until the 'detectionTimeout' is exceeded. If false, the 'answering-machine' result is sent immediately.
  26. 1 attr_accessor :delay_result
  27. # The URL to send the 'machineDetectionComplete' webhook when the detection is completed. Only for 'async' mode.
  28. 1 attr_accessor :callback_url
  29. 1 attr_accessor :callback_method
  30. # Basic auth username.
  31. 1 attr_accessor :username
  32. # Basic auth password.
  33. 1 attr_accessor :password
  34. # A fallback URL which, if provided, will be used to retry the machine detection complete webhook delivery in case `callbackUrl` fails to respond
  35. 1 attr_accessor :fallback_url
  36. 1 attr_accessor :fallback_method
  37. # Basic auth username.
  38. 1 attr_accessor :fallback_username
  39. # Basic auth password.
  40. 1 attr_accessor :fallback_password
  41. 1 class EnumAttributeValidator
  42. 1 attr_reader :datatype
  43. 1 attr_reader :allowable_values
  44. 1 def initialize(datatype, allowable_values)
  45. @allowable_values = allowable_values.map do |value|
  46. case datatype.to_s
  47. when /Integer/i
  48. value.to_i
  49. when /Float/i
  50. value.to_f
  51. else
  52. value
  53. end
  54. end
  55. end
  56. 1 def valid?(value)
  57. !value || allowable_values.include?(value)
  58. end
  59. end
  60. # Attribute mapping from ruby-style variable name to JSON key.
  61. 1 def self.attribute_map
  62. 79 {
  63. :'mode' => :'mode',
  64. :'detection_timeout' => :'detectionTimeout',
  65. :'silence_timeout' => :'silenceTimeout',
  66. :'speech_threshold' => :'speechThreshold',
  67. :'speech_end_threshold' => :'speechEndThreshold',
  68. :'machine_speech_end_threshold' => :'machineSpeechEndThreshold',
  69. :'delay_result' => :'delayResult',
  70. :'callback_url' => :'callbackUrl',
  71. :'callback_method' => :'callbackMethod',
  72. :'username' => :'username',
  73. :'password' => :'password',
  74. :'fallback_url' => :'fallbackUrl',
  75. :'fallback_method' => :'fallbackMethod',
  76. :'fallback_username' => :'fallbackUsername',
  77. :'fallback_password' => :'fallbackPassword'
  78. }
  79. end
  80. # Returns attribute mapping this model knows about
  81. 1 def self.acceptable_attribute_map
  82. 15 attribute_map
  83. end
  84. # Returns all the JSON keys this model knows about
  85. 1 def self.acceptable_attributes
  86. 1 acceptable_attribute_map.values
  87. end
  88. # Attribute type mapping.
  89. 1 def self.openapi_types
  90. 1 {
  91. :'mode' => :'MachineDetectionModeEnum',
  92. :'detection_timeout' => :'Float',
  93. :'silence_timeout' => :'Float',
  94. :'speech_threshold' => :'Float',
  95. :'speech_end_threshold' => :'Float',
  96. :'machine_speech_end_threshold' => :'Float',
  97. :'delay_result' => :'Boolean',
  98. :'callback_url' => :'String',
  99. :'callback_method' => :'CallbackMethodEnum',
  100. :'username' => :'String',
  101. :'password' => :'String',
  102. :'fallback_url' => :'String',
  103. :'fallback_method' => :'CallbackMethodEnum',
  104. :'fallback_username' => :'String',
  105. :'fallback_password' => :'String'
  106. }
  107. end
  108. # List of attributes with nullable: true
  109. 1 def self.openapi_nullable
  110. 1 Set.new([
  111. :'detection_timeout',
  112. :'silence_timeout',
  113. :'speech_threshold',
  114. :'speech_end_threshold',
  115. :'machine_speech_end_threshold',
  116. :'delay_result',
  117. :'callback_url',
  118. :'callback_method',
  119. :'username',
  120. :'password',
  121. :'fallback_url',
  122. :'fallback_method',
  123. :'fallback_username',
  124. :'fallback_password'
  125. ])
  126. end
  127. # Initializes the object
  128. # @param [Hash] attributes Model attributes in the form of hash
  129. 1 def initialize(attributes = {})
  130. 15 if (!attributes.is_a?(Hash))
  131. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MachineDetectionConfiguration` initialize method'
  132. end
  133. # check to see if the attribute exists and convert string to symbol for hash key
  134. 14 acceptable_attribute_map = self.class.acceptable_attribute_map
  135. 14 attributes = attributes.each_with_object({}) { |(k, v), h|
  136. 82 if (!acceptable_attribute_map.key?(k.to_sym))
  137. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MachineDetectionConfiguration`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  138. end
  139. 81 h[k.to_sym] = v
  140. }
  141. 13 if attributes.key?(:'mode')
  142. 5 self.mode = attributes[:'mode']
  143. else
  144. 8 self.mode = 'async'
  145. end
  146. 13 if attributes.key?(:'detection_timeout')
  147. 5 self.detection_timeout = attributes[:'detection_timeout']
  148. else
  149. 8 self.detection_timeout = 15
  150. end
  151. 13 if attributes.key?(:'silence_timeout')
  152. 5 self.silence_timeout = attributes[:'silence_timeout']
  153. else
  154. 8 self.silence_timeout = 10
  155. end
  156. 13 if attributes.key?(:'speech_threshold')
  157. 5 self.speech_threshold = attributes[:'speech_threshold']
  158. else
  159. 8 self.speech_threshold = 10
  160. end
  161. 13 if attributes.key?(:'speech_end_threshold')
  162. 5 self.speech_end_threshold = attributes[:'speech_end_threshold']
  163. else
  164. 8 self.speech_end_threshold = 5
  165. end
  166. 13 if attributes.key?(:'machine_speech_end_threshold')
  167. 5 self.machine_speech_end_threshold = attributes[:'machine_speech_end_threshold']
  168. end
  169. 13 if attributes.key?(:'delay_result')
  170. 5 self.delay_result = attributes[:'delay_result']
  171. else
  172. 8 self.delay_result = false
  173. end
  174. 13 if attributes.key?(:'callback_url')
  175. 6 self.callback_url = attributes[:'callback_url']
  176. end
  177. 12 if attributes.key?(:'callback_method')
  178. 5 self.callback_method = attributes[:'callback_method']
  179. else
  180. 7 self.callback_method = 'POST'
  181. end
  182. 12 if attributes.key?(:'username')
  183. 6 self.username = attributes[:'username']
  184. end
  185. 11 if attributes.key?(:'password')
  186. 6 self.password = attributes[:'password']
  187. end
  188. 10 if attributes.key?(:'fallback_url')
  189. 6 self.fallback_url = attributes[:'fallback_url']
  190. end
  191. 9 if attributes.key?(:'fallback_method')
  192. 5 self.fallback_method = attributes[:'fallback_method']
  193. else
  194. 4 self.fallback_method = 'POST'
  195. end
  196. 9 if attributes.key?(:'fallback_username')
  197. 6 self.fallback_username = attributes[:'fallback_username']
  198. end
  199. 8 if attributes.key?(:'fallback_password')
  200. 6 self.fallback_password = attributes[:'fallback_password']
  201. end
  202. end
  203. # Show invalid properties with the reasons. Usually used together with valid?
  204. # @return Array for valid properties with the reasons
  205. 1 def list_invalid_properties
  206. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  207. invalid_properties = Array.new
  208. if !@callback_url.nil? && @callback_url.to_s.length > 2048
  209. invalid_properties.push('invalid value for "callback_url", the character length must be smaller than or equal to 2048.')
  210. end
  211. if !@username.nil? && @username.to_s.length > 1024
  212. invalid_properties.push('invalid value for "username", the character length must be smaller than or equal to 1024.')
  213. end
  214. if !@password.nil? && @password.to_s.length > 1024
  215. invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 1024.')
  216. end
  217. if !@fallback_url.nil? && @fallback_url.to_s.length > 2048
  218. invalid_properties.push('invalid value for "fallback_url", the character length must be smaller than or equal to 2048.')
  219. end
  220. if !@fallback_username.nil? && @fallback_username.to_s.length > 1024
  221. invalid_properties.push('invalid value for "fallback_username", the character length must be smaller than or equal to 1024.')
  222. end
  223. if !@fallback_password.nil? && @fallback_password.to_s.length > 1024
  224. invalid_properties.push('invalid value for "fallback_password", the character length must be smaller than or equal to 1024.')
  225. end
  226. invalid_properties
  227. end
  228. # Check to see if the all the properties in the model are valid
  229. # @return true if the model is valid
  230. 1 def valid?
  231. warn '[DEPRECATED] the `valid?` method is obsolete'
  232. return false if !@callback_url.nil? && @callback_url.to_s.length > 2048
  233. return false if !@username.nil? && @username.to_s.length > 1024
  234. return false if !@password.nil? && @password.to_s.length > 1024
  235. return false if !@fallback_url.nil? && @fallback_url.to_s.length > 2048
  236. return false if !@fallback_username.nil? && @fallback_username.to_s.length > 1024
  237. return false if !@fallback_password.nil? && @fallback_password.to_s.length > 1024
  238. true
  239. end
  240. # Custom attribute writer method with validation
  241. # @param [Object] callback_url Value to be assigned
  242. 1 def callback_url=(callback_url)
  243. 6 if !callback_url.nil? && callback_url.to_s.length > 2048
  244. 1 fail ArgumentError, 'invalid value for "callback_url", the character length must be smaller than or equal to 2048.'
  245. end
  246. 5 @callback_url = callback_url
  247. end
  248. # Custom attribute writer method with validation
  249. # @param [Object] username Value to be assigned
  250. 1 def username=(username)
  251. 6 if !username.nil? && username.to_s.length > 1024
  252. 1 fail ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 1024.'
  253. end
  254. 5 @username = username
  255. end
  256. # Custom attribute writer method with validation
  257. # @param [Object] password Value to be assigned
  258. 1 def password=(password)
  259. 6 if !password.nil? && password.to_s.length > 1024
  260. 1 fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 1024.'
  261. end
  262. 5 @password = password
  263. end
  264. # Custom attribute writer method with validation
  265. # @param [Object] fallback_url Value to be assigned
  266. 1 def fallback_url=(fallback_url)
  267. 6 if !fallback_url.nil? && fallback_url.to_s.length > 2048
  268. 1 fail ArgumentError, 'invalid value for "fallback_url", the character length must be smaller than or equal to 2048.'
  269. end
  270. 5 @fallback_url = fallback_url
  271. end
  272. # Custom attribute writer method with validation
  273. # @param [Object] fallback_username Value to be assigned
  274. 1 def fallback_username=(fallback_username)
  275. 6 if !fallback_username.nil? && fallback_username.to_s.length > 1024
  276. 1 fail ArgumentError, 'invalid value for "fallback_username", the character length must be smaller than or equal to 1024.'
  277. end
  278. 5 @fallback_username = fallback_username
  279. end
  280. # Custom attribute writer method with validation
  281. # @param [Object] fallback_password Value to be assigned
  282. 1 def fallback_password=(fallback_password)
  283. 6 if !fallback_password.nil? && fallback_password.to_s.length > 1024
  284. 1 fail ArgumentError, 'invalid value for "fallback_password", the character length must be smaller than or equal to 1024.'
  285. end
  286. 5 @fallback_password = fallback_password
  287. end
  288. # Checks equality by comparing each attribute.
  289. # @param [Object] Object to be compared
  290. 1 def ==(o)
  291. 2 return true if self.equal?(o)
  292. 2 self.class == o.class &&
  293. mode == o.mode &&
  294. detection_timeout == o.detection_timeout &&
  295. silence_timeout == o.silence_timeout &&
  296. speech_threshold == o.speech_threshold &&
  297. speech_end_threshold == o.speech_end_threshold &&
  298. machine_speech_end_threshold == o.machine_speech_end_threshold &&
  299. delay_result == o.delay_result &&
  300. callback_url == o.callback_url &&
  301. callback_method == o.callback_method &&
  302. username == o.username &&
  303. password == o.password &&
  304. fallback_url == o.fallback_url &&
  305. fallback_method == o.fallback_method &&
  306. fallback_username == o.fallback_username &&
  307. fallback_password == o.fallback_password
  308. end
  309. # @see the `==` method
  310. # @param [Object] Object to be compared
  311. 1 def eql?(o)
  312. 2 self == o
  313. end
  314. # Calculates hash code according to all attributes.
  315. # @return [Integer] Hash code
  316. 1 def hash
  317. [mode, detection_timeout, silence_timeout, speech_threshold, speech_end_threshold, machine_speech_end_threshold, delay_result, callback_url, callback_method, username, password, fallback_url, fallback_method, fallback_username, fallback_password].hash
  318. end
  319. # Builds the object from hash
  320. # @param [Hash] attributes Model attributes in the form of hash
  321. # @return [Object] Returns the model itself
  322. 1 def self.build_from_hash(attributes)
  323. 1 return nil unless attributes.is_a?(Hash)
  324. 1 attributes = attributes.transform_keys(&:to_sym)
  325. 1 transformed_hash = {}
  326. 1 openapi_types.each_pair do |key, type|
  327. 15 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  328. transformed_hash["#{key}"] = nil
  329. 15 elsif type =~ /\AArray<(.*)>/i
  330. # check to ensure the input is an array given that the attribute
  331. # is documented as an array but the input is not
  332. if attributes[attribute_map[key]].is_a?(Array)
  333. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  334. end
  335. 15 elsif !attributes[attribute_map[key]].nil?
  336. 15 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  337. end
  338. end
  339. 1 new(transformed_hash)
  340. end
  341. # Returns the object in the form of hash
  342. # @return [Hash] Returns the object in the form of hash
  343. 1 def to_hash
  344. 3 hash = {}
  345. 3 self.class.attribute_map.each_pair do |attr, param|
  346. 45 value = self.send(attr)
  347. 45 if value.nil?
  348. is_nullable = self.class.openapi_nullable.include?(attr)
  349. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  350. end
  351. 45 hash[param] = _to_hash(value)
  352. end
  353. 3 hash
  354. end
  355. end
  356. end

lib/bandwidth-sdk/models/machine_detection_mode_enum.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MachineDetectionModeEnum
  13. 1 SYNC = 'sync'.freeze
  14. 1 ASYNC = 'async'.freeze
  15. 1 def self.all_vars
  16. 5 @all_vars ||= [SYNC, ASYNC].freeze
  17. end
  18. # Builds the enum from string
  19. # @param [String] The enum value in the form of the string
  20. # @return [String] The enum value
  21. 1 def self.build_from_hash(value)
  22. 4 new.build_from_hash(value)
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def build_from_hash(value)
  28. 4 return value if MachineDetectionModeEnum.all_vars.include?(value)
  29. 1 raise "Invalid ENUM value #{value} for class #MachineDetectionModeEnum"
  30. end
  31. end
  32. end

lib/bandwidth-sdk/models/machine_detection_result.rb

82.81% lines covered

64 relevant lines. 53 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # (optional) if machine detection was requested in sync mode, the result will be specified here. Possible values are the same as the async counterpart: Machine Detection Complete
  13. 1 class MachineDetectionResult < ApiModelBase
  14. # Possible values are answering-machine, human, silence, timeout, or error.
  15. 1 attr_accessor :value
  16. # The amount of time it took to determine the result.
  17. 1 attr_accessor :duration
  18. # Attribute mapping from ruby-style variable name to JSON key.
  19. 1 def self.attribute_map
  20. 37 {
  21. :'value' => :'value',
  22. :'duration' => :'duration'
  23. }
  24. end
  25. # Returns attribute mapping this model knows about
  26. 1 def self.acceptable_attribute_map
  27. 10 attribute_map
  28. end
  29. # Returns all the JSON keys this model knows about
  30. 1 def self.acceptable_attributes
  31. 1 acceptable_attribute_map.values
  32. end
  33. # Attribute type mapping.
  34. 1 def self.openapi_types
  35. 3 {
  36. :'value' => :'String',
  37. :'duration' => :'String'
  38. }
  39. end
  40. # List of attributes with nullable: true
  41. 1 def self.openapi_nullable
  42. 1 Set.new([
  43. ])
  44. end
  45. # Initializes the object
  46. # @param [Hash] attributes Model attributes in the form of hash
  47. 1 def initialize(attributes = {})
  48. 10 if (!attributes.is_a?(Hash))
  49. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MachineDetectionResult` initialize method'
  50. end
  51. # check to see if the attribute exists and convert string to symbol for hash key
  52. 9 acceptable_attribute_map = self.class.acceptable_attribute_map
  53. 9 attributes = attributes.each_with_object({}) { |(k, v), h|
  54. 13 if (!acceptable_attribute_map.key?(k.to_sym))
  55. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MachineDetectionResult`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  56. end
  57. 12 h[k.to_sym] = v
  58. }
  59. 8 if attributes.key?(:'value')
  60. 6 self.value = attributes[:'value']
  61. end
  62. 8 if attributes.key?(:'duration')
  63. 6 self.duration = attributes[:'duration']
  64. end
  65. end
  66. # Show invalid properties with the reasons. Usually used together with valid?
  67. # @return Array for valid properties with the reasons
  68. 1 def list_invalid_properties
  69. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  70. invalid_properties = Array.new
  71. invalid_properties
  72. end
  73. # Check to see if the all the properties in the model are valid
  74. # @return true if the model is valid
  75. 1 def valid?
  76. warn '[DEPRECATED] the `valid?` method is obsolete'
  77. true
  78. end
  79. # Checks equality by comparing each attribute.
  80. # @param [Object] Object to be compared
  81. 1 def ==(o)
  82. 2 return true if self.equal?(o)
  83. 2 self.class == o.class &&
  84. value == o.value &&
  85. duration == o.duration
  86. end
  87. # @see the `==` method
  88. # @param [Object] Object to be compared
  89. 1 def eql?(o)
  90. 2 self == o
  91. end
  92. # Calculates hash code according to all attributes.
  93. # @return [Integer] Hash code
  94. 1 def hash
  95. [value, duration].hash
  96. end
  97. # Builds the object from hash
  98. # @param [Hash] attributes Model attributes in the form of hash
  99. # @return [Object] Returns the model itself
  100. 1 def self.build_from_hash(attributes)
  101. 3 return nil unless attributes.is_a?(Hash)
  102. 3 attributes = attributes.transform_keys(&:to_sym)
  103. 3 transformed_hash = {}
  104. 3 openapi_types.each_pair do |key, type|
  105. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  106. transformed_hash["#{key}"] = nil
  107. 6 elsif type =~ /\AArray<(.*)>/i
  108. # check to ensure the input is an array given that the attribute
  109. # is documented as an array but the input is not
  110. if attributes[attribute_map[key]].is_a?(Array)
  111. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  112. end
  113. 6 elsif !attributes[attribute_map[key]].nil?
  114. 6 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  115. end
  116. end
  117. 3 new(transformed_hash)
  118. end
  119. # Returns the object in the form of hash
  120. # @return [Hash] Returns the object in the form of hash
  121. 1 def to_hash
  122. 2 hash = {}
  123. 2 self.class.attribute_map.each_pair do |attr, param|
  124. 4 value = self.send(attr)
  125. 4 if value.nil?
  126. is_nullable = self.class.openapi_nullable.include?(attr)
  127. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  128. end
  129. 4 hash[param] = _to_hash(value)
  130. end
  131. 2 hash
  132. end
  133. end
  134. end

lib/bandwidth-sdk/models/media.rb

83.58% lines covered

67 relevant lines. 56 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class Media < ApiModelBase
  13. 1 attr_accessor :content
  14. 1 attr_accessor :content_length
  15. 1 attr_accessor :media_name
  16. # Attribute mapping from ruby-style variable name to JSON key.
  17. 1 def self.attribute_map
  18. 36 {
  19. :'content' => :'content',
  20. :'content_length' => :'contentLength',
  21. :'media_name' => :'mediaName'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 9 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 1 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 2 {
  35. :'content' => :'String',
  36. :'content_length' => :'Integer',
  37. :'media_name' => :'String'
  38. }
  39. end
  40. # List of attributes with nullable: true
  41. 1 def self.openapi_nullable
  42. 1 Set.new([
  43. ])
  44. end
  45. # Initializes the object
  46. # @param [Hash] attributes Model attributes in the form of hash
  47. 1 def initialize(attributes = {})
  48. 9 if (!attributes.is_a?(Hash))
  49. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::Media` initialize method'
  50. end
  51. # check to see if the attribute exists and convert string to symbol for hash key
  52. 8 acceptable_attribute_map = self.class.acceptable_attribute_map
  53. 8 attributes = attributes.each_with_object({}) { |(k, v), h|
  54. 16 if (!acceptable_attribute_map.key?(k.to_sym))
  55. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::Media`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  56. end
  57. 15 h[k.to_sym] = v
  58. }
  59. 7 if attributes.key?(:'content')
  60. 5 self.content = attributes[:'content']
  61. end
  62. 7 if attributes.key?(:'content_length')
  63. 5 self.content_length = attributes[:'content_length']
  64. end
  65. 7 if attributes.key?(:'media_name')
  66. 5 self.media_name = attributes[:'media_name']
  67. end
  68. end
  69. # Show invalid properties with the reasons. Usually used together with valid?
  70. # @return Array for valid properties with the reasons
  71. 1 def list_invalid_properties
  72. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  73. invalid_properties = Array.new
  74. invalid_properties
  75. end
  76. # Check to see if the all the properties in the model are valid
  77. # @return true if the model is valid
  78. 1 def valid?
  79. warn '[DEPRECATED] the `valid?` method is obsolete'
  80. true
  81. end
  82. # Checks equality by comparing each attribute.
  83. # @param [Object] Object to be compared
  84. 1 def ==(o)
  85. 2 return true if self.equal?(o)
  86. 2 self.class == o.class &&
  87. content == o.content &&
  88. content_length == o.content_length &&
  89. media_name == o.media_name
  90. end
  91. # @see the `==` method
  92. # @param [Object] Object to be compared
  93. 1 def eql?(o)
  94. 2 self == o
  95. end
  96. # Calculates hash code according to all attributes.
  97. # @return [Integer] Hash code
  98. 1 def hash
  99. [content, content_length, media_name].hash
  100. end
  101. # Builds the object from hash
  102. # @param [Hash] attributes Model attributes in the form of hash
  103. # @return [Object] Returns the model itself
  104. 1 def self.build_from_hash(attributes)
  105. 2 return nil unless attributes.is_a?(Hash)
  106. 2 attributes = attributes.transform_keys(&:to_sym)
  107. 2 transformed_hash = {}
  108. 2 openapi_types.each_pair do |key, type|
  109. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  110. transformed_hash["#{key}"] = nil
  111. 6 elsif type =~ /\AArray<(.*)>/i
  112. # check to ensure the input is an array given that the attribute
  113. # is documented as an array but the input is not
  114. if attributes[attribute_map[key]].is_a?(Array)
  115. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  116. end
  117. 6 elsif !attributes[attribute_map[key]].nil?
  118. 6 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  119. end
  120. end
  121. 2 new(transformed_hash)
  122. end
  123. # Returns the object in the form of hash
  124. # @return [Hash] Returns the object in the form of hash
  125. 1 def to_hash
  126. 2 hash = {}
  127. 2 self.class.attribute_map.each_pair do |attr, param|
  128. 6 value = self.send(attr)
  129. 6 if value.nil?
  130. is_nullable = self.class.openapi_nullable.include?(attr)
  131. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  132. end
  133. 6 hash[param] = _to_hash(value)
  134. end
  135. 2 hash
  136. end
  137. end
  138. end

lib/bandwidth-sdk/models/message.rb

87.29% lines covered

118 relevant lines. 103 lines covered and 15 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class Message < ApiModelBase
  13. # The id of the message.
  14. 1 attr_accessor :id
  15. # The Bandwidth phone number associated with the message.
  16. 1 attr_accessor :owner
  17. # The ID of the Application your from number or senderId is associated with in the Bandwidth App.
  18. 1 attr_accessor :application_id
  19. # The datetime stamp of the message in ISO 8601
  20. 1 attr_accessor :time
  21. # The number of segments the user's message is broken into before sending over carrier networks.
  22. 1 attr_accessor :segment_count
  23. 1 attr_accessor :direction
  24. # The phone number recipients of the message.
  25. 1 attr_accessor :to
  26. # The phone number the message was sent from.
  27. 1 attr_accessor :from
  28. # The list of media URLs sent in the message. Including a `filename` field in the `Content-Disposition` header of the media linked with a URL will set the displayed file name. This is a best practice to ensure that your media has a readable file name.
  29. 1 attr_accessor :media
  30. # The contents of the message.
  31. 1 attr_accessor :text
  32. # A custom string that will be included in callback events of the message. Max 1024 characters.
  33. 1 attr_accessor :tag
  34. 1 attr_accessor :priority
  35. # A string with the date/time value that the message will automatically expire by. This must be a valid RFC-3339 value, e.g., 2021-03-14T01:59:26Z or 2021-03-13T20:59:26-05:00. Must be a date-time in the future.
  36. 1 attr_accessor :expiration
  37. 1 class EnumAttributeValidator
  38. 1 attr_reader :datatype
  39. 1 attr_reader :allowable_values
  40. 1 def initialize(datatype, allowable_values)
  41. @allowable_values = allowable_values.map do |value|
  42. case datatype.to_s
  43. when /Integer/i
  44. value.to_i
  45. when /Float/i
  46. value.to_f
  47. else
  48. value
  49. end
  50. end
  51. end
  52. 1 def valid?(value)
  53. !value || allowable_values.include?(value)
  54. end
  55. end
  56. # Attribute mapping from ruby-style variable name to JSON key.
  57. 1 def self.attribute_map
  58. 118 {
  59. :'id' => :'id',
  60. :'owner' => :'owner',
  61. :'application_id' => :'applicationId',
  62. :'time' => :'time',
  63. :'segment_count' => :'segmentCount',
  64. :'direction' => :'direction',
  65. :'to' => :'to',
  66. :'from' => :'from',
  67. :'media' => :'media',
  68. :'text' => :'text',
  69. :'tag' => :'tag',
  70. :'priority' => :'priority',
  71. :'expiration' => :'expiration'
  72. }
  73. end
  74. # Returns attribute mapping this model knows about
  75. 1 def self.acceptable_attribute_map
  76. 11 attribute_map
  77. end
  78. # Returns all the JSON keys this model knows about
  79. 1 def self.acceptable_attributes
  80. 1 acceptable_attribute_map.values
  81. end
  82. # Attribute type mapping.
  83. 1 def self.openapi_types
  84. 2 {
  85. :'id' => :'String',
  86. :'owner' => :'String',
  87. :'application_id' => :'String',
  88. :'time' => :'Time',
  89. :'segment_count' => :'Integer',
  90. :'direction' => :'MessageDirectionEnum',
  91. :'to' => :'Array<String>',
  92. :'from' => :'String',
  93. :'media' => :'Array<String>',
  94. :'text' => :'String',
  95. :'tag' => :'String',
  96. :'priority' => :'PriorityEnum',
  97. :'expiration' => :'Time'
  98. }
  99. end
  100. # List of attributes with nullable: true
  101. 1 def self.openapi_nullable
  102. 1 Set.new([
  103. ])
  104. end
  105. # Initializes the object
  106. # @param [Hash] attributes Model attributes in the form of hash
  107. 1 def initialize(attributes = {})
  108. 11 if (!attributes.is_a?(Hash))
  109. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::Message` initialize method'
  110. end
  111. # check to see if the attribute exists and convert string to symbol for hash key
  112. 10 acceptable_attribute_map = self.class.acceptable_attribute_map
  113. 10 attributes = attributes.each_with_object({}) { |(k, v), h|
  114. 92 if (!acceptable_attribute_map.key?(k.to_sym))
  115. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::Message`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  116. end
  117. 91 h[k.to_sym] = v
  118. }
  119. 9 if attributes.key?(:'id')
  120. 7 self.id = attributes[:'id']
  121. end
  122. 9 if attributes.key?(:'owner')
  123. 7 self.owner = attributes[:'owner']
  124. end
  125. 9 if attributes.key?(:'application_id')
  126. 7 self.application_id = attributes[:'application_id']
  127. end
  128. 9 if attributes.key?(:'time')
  129. 7 self.time = attributes[:'time']
  130. end
  131. 9 if attributes.key?(:'segment_count')
  132. 7 self.segment_count = attributes[:'segment_count']
  133. end
  134. 9 if attributes.key?(:'direction')
  135. 7 self.direction = attributes[:'direction']
  136. end
  137. 9 if attributes.key?(:'to')
  138. 7 if (value = attributes[:'to']).is_a?(Array)
  139. 7 self.to = value
  140. end
  141. end
  142. 9 if attributes.key?(:'from')
  143. 7 self.from = attributes[:'from']
  144. end
  145. 9 if attributes.key?(:'media')
  146. 7 if (value = attributes[:'media']).is_a?(Array)
  147. 7 self.media = value
  148. end
  149. end
  150. 9 if attributes.key?(:'text')
  151. 7 self.text = attributes[:'text']
  152. end
  153. 9 if attributes.key?(:'tag')
  154. 7 self.tag = attributes[:'tag']
  155. end
  156. 9 if attributes.key?(:'priority')
  157. 7 self.priority = attributes[:'priority']
  158. end
  159. 9 if attributes.key?(:'expiration')
  160. 7 self.expiration = attributes[:'expiration']
  161. end
  162. end
  163. # Show invalid properties with the reasons. Usually used together with valid?
  164. # @return Array for valid properties with the reasons
  165. 1 def list_invalid_properties
  166. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  167. invalid_properties = Array.new
  168. invalid_properties
  169. end
  170. # Check to see if the all the properties in the model are valid
  171. # @return true if the model is valid
  172. 1 def valid?
  173. warn '[DEPRECATED] the `valid?` method is obsolete'
  174. true
  175. end
  176. # Custom attribute writer method with validation
  177. # @param [Object] to Value to be assigned
  178. 1 def to=(to)
  179. 8 if to.nil?
  180. 1 fail ArgumentError, 'to cannot be nil'
  181. end
  182. 7 @to = to
  183. end
  184. # Custom attribute writer method with validation
  185. # @param [Object] media Value to be assigned
  186. 1 def media=(media)
  187. 8 if media.nil?
  188. 1 fail ArgumentError, 'media cannot be nil'
  189. end
  190. 7 @media = media
  191. end
  192. # Checks equality by comparing each attribute.
  193. # @param [Object] Object to be compared
  194. 1 def ==(o)
  195. 2 return true if self.equal?(o)
  196. 2 self.class == o.class &&
  197. id == o.id &&
  198. owner == o.owner &&
  199. application_id == o.application_id &&
  200. time == o.time &&
  201. segment_count == o.segment_count &&
  202. direction == o.direction &&
  203. to == o.to &&
  204. from == o.from &&
  205. media == o.media &&
  206. text == o.text &&
  207. tag == o.tag &&
  208. priority == o.priority &&
  209. expiration == o.expiration
  210. end
  211. # @see the `==` method
  212. # @param [Object] Object to be compared
  213. 1 def eql?(o)
  214. 2 self == o
  215. end
  216. # Calculates hash code according to all attributes.
  217. # @return [Integer] Hash code
  218. 1 def hash
  219. [id, owner, application_id, time, segment_count, direction, to, from, media, text, tag, priority, expiration].hash
  220. end
  221. # Builds the object from hash
  222. # @param [Hash] attributes Model attributes in the form of hash
  223. # @return [Object] Returns the model itself
  224. 1 def self.build_from_hash(attributes)
  225. 2 return nil unless attributes.is_a?(Hash)
  226. 2 attributes = attributes.transform_keys(&:to_sym)
  227. 2 transformed_hash = {}
  228. 2 openapi_types.each_pair do |key, type|
  229. 26 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  230. transformed_hash["#{key}"] = nil
  231. 26 elsif type =~ /\AArray<(.*)>/i
  232. # check to ensure the input is an array given that the attribute
  233. # is documented as an array but the input is not
  234. 4 if attributes[attribute_map[key]].is_a?(Array)
  235. 8 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  236. end
  237. 22 elsif !attributes[attribute_map[key]].nil?
  238. 22 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  239. end
  240. end
  241. 2 new(transformed_hash)
  242. end
  243. # Returns the object in the form of hash
  244. # @return [Hash] Returns the object in the form of hash
  245. 1 def to_hash
  246. 2 hash = {}
  247. 2 self.class.attribute_map.each_pair do |attr, param|
  248. 26 value = self.send(attr)
  249. 26 if value.nil?
  250. is_nullable = self.class.openapi_nullable.include?(attr)
  251. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  252. end
  253. 26 hash[param] = _to_hash(value)
  254. end
  255. 2 hash
  256. end
  257. end
  258. end

lib/bandwidth-sdk/models/message_direction_enum.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MessageDirectionEnum
  13. 1 IN = 'in'.freeze
  14. 1 OUT = 'out'.freeze
  15. 1 def self.all_vars
  16. 14 @all_vars ||= [IN, OUT].freeze
  17. end
  18. # Builds the enum from string
  19. # @param [String] The enum value in the form of the string
  20. # @return [String] The enum value
  21. 1 def self.build_from_hash(value)
  22. 11 new.build_from_hash(value)
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def build_from_hash(value)
  28. 11 return value if MessageDirectionEnum.all_vars.include?(value)
  29. 1 raise "Invalid ENUM value #{value} for class #MessageDirectionEnum"
  30. end
  31. end
  32. end

lib/bandwidth-sdk/models/message_request.rb

78.13% lines covered

128 relevant lines. 100 lines covered and 28 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MessageRequest < ApiModelBase
  13. # The ID of the Application your from number or senderId is associated with in the Bandwidth App.
  14. 1 attr_accessor :application_id
  15. # The phone number(s) the message should be sent to in E164 format.
  16. 1 attr_accessor :to
  17. # Either an alphanumeric sender ID or the sender's Bandwidth phone number in E.164 format, which must be hosted within Bandwidth and linked to the account that is generating the message. Alphanumeric Sender IDs can contain up to 11 characters, upper-case letters A-Z, lower-case letters a-z, numbers 0-9, space, hyphen -, plus +, underscore _ and ampersand &. Alphanumeric Sender IDs must contain at least one letter.
  18. 1 attr_accessor :from
  19. # The contents of the text message. Must be 2048 characters or less.
  20. 1 attr_accessor :text
  21. # A list of URLs to include as media attachments as part of the message. Each URL can be at most 4096 characters.
  22. 1 attr_accessor :media
  23. # A custom string that will be included in callback events of the message. Max 1024 characters.
  24. 1 attr_accessor :tag
  25. 1 attr_accessor :priority
  26. # A string with the date/time value that the message will automatically expire by. This must be a valid RFC-3339 value, e.g., 2021-03-14T01:59:26Z or 2021-03-13T20:59:26-05:00. Must be a date-time in the future.
  27. 1 attr_accessor :expiration
  28. 1 class EnumAttributeValidator
  29. 1 attr_reader :datatype
  30. 1 attr_reader :allowable_values
  31. 1 def initialize(datatype, allowable_values)
  32. @allowable_values = allowable_values.map do |value|
  33. case datatype.to_s
  34. when /Integer/i
  35. value.to_i
  36. when /Float/i
  37. value.to_f
  38. else
  39. value
  40. end
  41. end
  42. end
  43. 1 def valid?(value)
  44. !value || allowable_values.include?(value)
  45. end
  46. end
  47. # Attribute mapping from ruby-style variable name to JSON key.
  48. 1 def self.attribute_map
  49. 49 {
  50. :'application_id' => :'applicationId',
  51. :'to' => :'to',
  52. :'from' => :'from',
  53. :'text' => :'text',
  54. :'media' => :'media',
  55. :'tag' => :'tag',
  56. :'priority' => :'priority',
  57. :'expiration' => :'expiration'
  58. }
  59. end
  60. # Returns attribute mapping this model knows about
  61. 1 def self.acceptable_attribute_map
  62. 13 attribute_map
  63. end
  64. # Returns all the JSON keys this model knows about
  65. 1 def self.acceptable_attributes
  66. 1 acceptable_attribute_map.values
  67. end
  68. # Attribute type mapping.
  69. 1 def self.openapi_types
  70. 1 {
  71. :'application_id' => :'String',
  72. :'to' => :'Array<String>',
  73. :'from' => :'String',
  74. :'text' => :'String',
  75. :'media' => :'Array<String>',
  76. :'tag' => :'String',
  77. :'priority' => :'PriorityEnum',
  78. :'expiration' => :'Time'
  79. }
  80. end
  81. # List of attributes with nullable: true
  82. 1 def self.openapi_nullable
  83. 5 Set.new([
  84. ])
  85. end
  86. # Initializes the object
  87. # @param [Hash] attributes Model attributes in the form of hash
  88. 1 def initialize(attributes = {})
  89. 13 if (!attributes.is_a?(Hash))
  90. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MessageRequest` initialize method'
  91. end
  92. # check to see if the attribute exists and convert string to symbol for hash key
  93. 12 acceptable_attribute_map = self.class.acceptable_attribute_map
  94. 12 attributes = attributes.each_with_object({}) { |(k, v), h|
  95. 63 if (!acceptable_attribute_map.key?(k.to_sym))
  96. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MessageRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  97. end
  98. 62 h[k.to_sym] = v
  99. }
  100. 11 if attributes.key?(:'application_id')
  101. 11 self.application_id = attributes[:'application_id']
  102. else
  103. self.application_id = nil
  104. end
  105. 10 if attributes.key?(:'to')
  106. 10 if (value = attributes[:'to']).is_a?(Array)
  107. 10 self.to = value
  108. end
  109. else
  110. self.to = nil
  111. end
  112. 10 if attributes.key?(:'from')
  113. 10 self.from = attributes[:'from']
  114. else
  115. self.from = nil
  116. end
  117. 9 if attributes.key?(:'text')
  118. 7 self.text = attributes[:'text']
  119. end
  120. 9 if attributes.key?(:'media')
  121. 6 if (value = attributes[:'media']).is_a?(Array)
  122. 6 self.media = value
  123. end
  124. end
  125. 9 if attributes.key?(:'tag')
  126. 6 self.tag = attributes[:'tag']
  127. end
  128. 9 if attributes.key?(:'priority')
  129. 6 self.priority = attributes[:'priority']
  130. end
  131. 9 if attributes.key?(:'expiration')
  132. 6 self.expiration = attributes[:'expiration']
  133. end
  134. end
  135. # Show invalid properties with the reasons. Usually used together with valid?
  136. # @return Array for valid properties with the reasons
  137. 1 def list_invalid_properties
  138. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  139. invalid_properties = Array.new
  140. if @application_id.nil?
  141. invalid_properties.push('invalid value for "application_id", application_id cannot be nil.')
  142. end
  143. if @to.nil?
  144. invalid_properties.push('invalid value for "to", to cannot be nil.')
  145. end
  146. if @from.nil?
  147. invalid_properties.push('invalid value for "from", from cannot be nil.')
  148. end
  149. if !@text.nil? && @text.to_s.length > 2048
  150. invalid_properties.push('invalid value for "text", the character length must be smaller than or equal to 2048.')
  151. end
  152. invalid_properties
  153. end
  154. # Check to see if the all the properties in the model are valid
  155. # @return true if the model is valid
  156. 1 def valid?
  157. warn '[DEPRECATED] the `valid?` method is obsolete'
  158. return false if @application_id.nil?
  159. return false if @to.nil?
  160. return false if @from.nil?
  161. return false if !@text.nil? && @text.to_s.length > 2048
  162. true
  163. end
  164. # Custom attribute writer method with validation
  165. # @param [Object] application_id Value to be assigned
  166. 1 def application_id=(application_id)
  167. 11 if application_id.nil?
  168. 1 fail ArgumentError, 'application_id cannot be nil'
  169. end
  170. 10 @application_id = application_id
  171. end
  172. # Custom attribute writer method with validation
  173. # @param [Object] to Value to be assigned
  174. 1 def to=(to)
  175. 11 if to.nil?
  176. 1 fail ArgumentError, 'to cannot be nil'
  177. end
  178. 10 @to = to
  179. end
  180. # Custom attribute writer method with validation
  181. # @param [Object] from Value to be assigned
  182. 1 def from=(from)
  183. 10 if from.nil?
  184. 1 fail ArgumentError, 'from cannot be nil'
  185. end
  186. 9 @from = from
  187. end
  188. # Custom attribute writer method with validation
  189. # @param [Object] text Value to be assigned
  190. 1 def text=(text)
  191. 9 if text.nil?
  192. 1 fail ArgumentError, 'text cannot be nil'
  193. end
  194. 8 if text.to_s.length > 2048
  195. 1 fail ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 2048.'
  196. end
  197. 7 @text = text
  198. end
  199. # Checks equality by comparing each attribute.
  200. # @param [Object] Object to be compared
  201. 1 def ==(o)
  202. 2 return true if self.equal?(o)
  203. 2 self.class == o.class &&
  204. application_id == o.application_id &&
  205. to == o.to &&
  206. from == o.from &&
  207. text == o.text &&
  208. media == o.media &&
  209. tag == o.tag &&
  210. priority == o.priority &&
  211. expiration == o.expiration
  212. end
  213. # @see the `==` method
  214. # @param [Object] Object to be compared
  215. 1 def eql?(o)
  216. 2 self == o
  217. end
  218. # Calculates hash code according to all attributes.
  219. # @return [Integer] Hash code
  220. 1 def hash
  221. [application_id, to, from, text, media, tag, priority, expiration].hash
  222. end
  223. # Builds the object from hash
  224. # @param [Hash] attributes Model attributes in the form of hash
  225. # @return [Object] Returns the model itself
  226. 1 def self.build_from_hash(attributes)
  227. 1 return nil unless attributes.is_a?(Hash)
  228. 1 attributes = attributes.transform_keys(&:to_sym)
  229. 1 transformed_hash = {}
  230. 1 openapi_types.each_pair do |key, type|
  231. 8 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  232. transformed_hash["#{key}"] = nil
  233. 8 elsif type =~ /\AArray<(.*)>/i
  234. # check to ensure the input is an array given that the attribute
  235. # is documented as an array but the input is not
  236. 2 if attributes[attribute_map[key]].is_a?(Array)
  237. 4 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  238. end
  239. 6 elsif !attributes[attribute_map[key]].nil?
  240. 6 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  241. end
  242. end
  243. 1 new(transformed_hash)
  244. end
  245. # Returns the object in the form of hash
  246. # @return [Hash] Returns the object in the form of hash
  247. 1 def to_hash
  248. 3 hash = {}
  249. 3 self.class.attribute_map.each_pair do |attr, param|
  250. 24 value = self.send(attr)
  251. 24 if value.nil?
  252. 4 is_nullable = self.class.openapi_nullable.include?(attr)
  253. 4 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  254. end
  255. 20 hash[param] = _to_hash(value)
  256. end
  257. 3 hash
  258. end
  259. end
  260. end

lib/bandwidth-sdk/models/message_status_enum.rb

100.0% lines covered

19 relevant lines. 19 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MessageStatusEnum
  13. 1 RECEIVED = 'RECEIVED'.freeze
  14. 1 QUEUED = 'QUEUED'.freeze
  15. 1 SENDING = 'SENDING'.freeze
  16. 1 SENT = 'SENT'.freeze
  17. 1 FAILED = 'FAILED'.freeze
  18. 1 DELIVERED = 'DELIVERED'.freeze
  19. 1 ACCEPTED = 'ACCEPTED'.freeze
  20. 1 UNDELIVERED = 'UNDELIVERED'.freeze
  21. 1 def self.all_vars
  22. 13 @all_vars ||= [RECEIVED, QUEUED, SENDING, SENT, FAILED, DELIVERED, ACCEPTED, UNDELIVERED].freeze
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def self.build_from_hash(value)
  28. 11 new.build_from_hash(value)
  29. end
  30. # Builds the enum from string
  31. # @param [String] The enum value in the form of the string
  32. # @return [String] The enum value
  33. 1 def build_from_hash(value)
  34. 11 return value if MessageStatusEnum.all_vars.include?(value)
  35. 1 raise "Invalid ENUM value #{value} for class #MessageStatusEnum"
  36. end
  37. end
  38. end

lib/bandwidth-sdk/models/message_type_enum.rb

100.0% lines covered

14 relevant lines. 14 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MessageTypeEnum
  13. 1 SMS = 'sms'.freeze
  14. 1 MMS = 'mms'.freeze
  15. 1 RCS = 'rcs'.freeze
  16. 1 def self.all_vars
  17. 8 @all_vars ||= [SMS, MMS, RCS].freeze
  18. end
  19. # Builds the enum from string
  20. # @param [String] The enum value in the form of the string
  21. # @return [String] The enum value
  22. 1 def self.build_from_hash(value)
  23. 6 new.build_from_hash(value)
  24. end
  25. # Builds the enum from string
  26. # @param [String] The enum value in the form of the string
  27. # @return [String] The enum value
  28. 1 def build_from_hash(value)
  29. 6 return value if MessageTypeEnum.all_vars.include?(value)
  30. 1 raise "Invalid ENUM value #{value} for class #MessageTypeEnum"
  31. end
  32. end
  33. end

lib/bandwidth-sdk/models/messages_list.rb

86.76% lines covered

68 relevant lines. 59 lines covered and 9 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MessagesList < ApiModelBase
  13. # The total number of messages matched by the search. When the request has limitTotalCount set to true this value is limited to 10,000.
  14. 1 attr_accessor :total_count
  15. 1 attr_accessor :page_info
  16. 1 attr_accessor :messages
  17. # Attribute mapping from ruby-style variable name to JSON key.
  18. 1 def self.attribute_map
  19. 36 {
  20. :'total_count' => :'totalCount',
  21. :'page_info' => :'pageInfo',
  22. :'messages' => :'messages'
  23. }
  24. end
  25. # Returns attribute mapping this model knows about
  26. 1 def self.acceptable_attribute_map
  27. 9 attribute_map
  28. end
  29. # Returns all the JSON keys this model knows about
  30. 1 def self.acceptable_attributes
  31. 1 acceptable_attribute_map.values
  32. end
  33. # Attribute type mapping.
  34. 1 def self.openapi_types
  35. 2 {
  36. :'total_count' => :'Integer',
  37. :'page_info' => :'PageInfo',
  38. :'messages' => :'Array<ListMessageItem>'
  39. }
  40. end
  41. # List of attributes with nullable: true
  42. 1 def self.openapi_nullable
  43. 1 Set.new([
  44. ])
  45. end
  46. # Initializes the object
  47. # @param [Hash] attributes Model attributes in the form of hash
  48. 1 def initialize(attributes = {})
  49. 9 if (!attributes.is_a?(Hash))
  50. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MessagesList` initialize method'
  51. end
  52. # check to see if the attribute exists and convert string to symbol for hash key
  53. 8 acceptable_attribute_map = self.class.acceptable_attribute_map
  54. 8 attributes = attributes.each_with_object({}) { |(k, v), h|
  55. 16 if (!acceptable_attribute_map.key?(k.to_sym))
  56. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MessagesList`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  57. end
  58. 15 h[k.to_sym] = v
  59. }
  60. 7 if attributes.key?(:'total_count')
  61. 5 self.total_count = attributes[:'total_count']
  62. end
  63. 7 if attributes.key?(:'page_info')
  64. 5 self.page_info = attributes[:'page_info']
  65. end
  66. 7 if attributes.key?(:'messages')
  67. 5 if (value = attributes[:'messages']).is_a?(Array)
  68. 5 self.messages = value
  69. end
  70. end
  71. end
  72. # Show invalid properties with the reasons. Usually used together with valid?
  73. # @return Array for valid properties with the reasons
  74. 1 def list_invalid_properties
  75. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  76. invalid_properties = Array.new
  77. invalid_properties
  78. end
  79. # Check to see if the all the properties in the model are valid
  80. # @return true if the model is valid
  81. 1 def valid?
  82. warn '[DEPRECATED] the `valid?` method is obsolete'
  83. true
  84. end
  85. # Checks equality by comparing each attribute.
  86. # @param [Object] Object to be compared
  87. 1 def ==(o)
  88. 2 return true if self.equal?(o)
  89. 2 self.class == o.class &&
  90. total_count == o.total_count &&
  91. page_info == o.page_info &&
  92. messages == o.messages
  93. end
  94. # @see the `==` method
  95. # @param [Object] Object to be compared
  96. 1 def eql?(o)
  97. 2 self == o
  98. end
  99. # Calculates hash code according to all attributes.
  100. # @return [Integer] Hash code
  101. 1 def hash
  102. [total_count, page_info, messages].hash
  103. end
  104. # Builds the object from hash
  105. # @param [Hash] attributes Model attributes in the form of hash
  106. # @return [Object] Returns the model itself
  107. 1 def self.build_from_hash(attributes)
  108. 2 return nil unless attributes.is_a?(Hash)
  109. 2 attributes = attributes.transform_keys(&:to_sym)
  110. 2 transformed_hash = {}
  111. 2 openapi_types.each_pair do |key, type|
  112. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  113. transformed_hash["#{key}"] = nil
  114. 6 elsif type =~ /\AArray<(.*)>/i
  115. # check to ensure the input is an array given that the attribute
  116. # is documented as an array but the input is not
  117. 2 if attributes[attribute_map[key]].is_a?(Array)
  118. 4 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  119. end
  120. 4 elsif !attributes[attribute_map[key]].nil?
  121. 4 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  122. end
  123. end
  124. 2 new(transformed_hash)
  125. end
  126. # Returns the object in the form of hash
  127. # @return [Hash] Returns the object in the form of hash
  128. 1 def to_hash
  129. 2 hash = {}
  130. 2 self.class.attribute_map.each_pair do |attr, param|
  131. 6 value = self.send(attr)
  132. 6 if value.nil?
  133. is_nullable = self.class.openapi_nullable.include?(attr)
  134. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  135. end
  136. 6 hash[param] = _to_hash(value)
  137. end
  138. 2 hash
  139. end
  140. end
  141. end

lib/bandwidth-sdk/models/messaging_code_response.rb

81.97% lines covered

61 relevant lines. 50 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MessagingCodeResponse < ApiModelBase
  13. # Messaging API Message ID.
  14. 1 attr_accessor :message_id
  15. # Attribute mapping from ruby-style variable name to JSON key.
  16. 1 def self.attribute_map
  17. 20 {
  18. :'message_id' => :'messageId'
  19. }
  20. end
  21. # Returns attribute mapping this model knows about
  22. 1 def self.acceptable_attribute_map
  23. 9 attribute_map
  24. end
  25. # Returns all the JSON keys this model knows about
  26. 1 def self.acceptable_attributes
  27. 1 acceptable_attribute_map.values
  28. end
  29. # Attribute type mapping.
  30. 1 def self.openapi_types
  31. 2 {
  32. :'message_id' => :'String'
  33. }
  34. end
  35. # List of attributes with nullable: true
  36. 1 def self.openapi_nullable
  37. 1 Set.new([
  38. ])
  39. end
  40. # Initializes the object
  41. # @param [Hash] attributes Model attributes in the form of hash
  42. 1 def initialize(attributes = {})
  43. 9 if (!attributes.is_a?(Hash))
  44. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MessagingCodeResponse` initialize method'
  45. end
  46. # check to see if the attribute exists and convert string to symbol for hash key
  47. 8 acceptable_attribute_map = self.class.acceptable_attribute_map
  48. 8 attributes = attributes.each_with_object({}) { |(k, v), h|
  49. 6 if (!acceptable_attribute_map.key?(k.to_sym))
  50. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MessagingCodeResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  51. end
  52. 5 h[k.to_sym] = v
  53. }
  54. 7 if attributes.key?(:'message_id')
  55. 5 self.message_id = attributes[:'message_id']
  56. end
  57. end
  58. # Show invalid properties with the reasons. Usually used together with valid?
  59. # @return Array for valid properties with the reasons
  60. 1 def list_invalid_properties
  61. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  62. invalid_properties = Array.new
  63. invalid_properties
  64. end
  65. # Check to see if the all the properties in the model are valid
  66. # @return true if the model is valid
  67. 1 def valid?
  68. warn '[DEPRECATED] the `valid?` method is obsolete'
  69. true
  70. end
  71. # Checks equality by comparing each attribute.
  72. # @param [Object] Object to be compared
  73. 1 def ==(o)
  74. 2 return true if self.equal?(o)
  75. 2 self.class == o.class &&
  76. message_id == o.message_id
  77. end
  78. # @see the `==` method
  79. # @param [Object] Object to be compared
  80. 1 def eql?(o)
  81. 2 self == o
  82. end
  83. # Calculates hash code according to all attributes.
  84. # @return [Integer] Hash code
  85. 1 def hash
  86. [message_id].hash
  87. end
  88. # Builds the object from hash
  89. # @param [Hash] attributes Model attributes in the form of hash
  90. # @return [Object] Returns the model itself
  91. 1 def self.build_from_hash(attributes)
  92. 2 return nil unless attributes.is_a?(Hash)
  93. 2 attributes = attributes.transform_keys(&:to_sym)
  94. 2 transformed_hash = {}
  95. 2 openapi_types.each_pair do |key, type|
  96. 2 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  97. transformed_hash["#{key}"] = nil
  98. 2 elsif type =~ /\AArray<(.*)>/i
  99. # check to ensure the input is an array given that the attribute
  100. # is documented as an array but the input is not
  101. if attributes[attribute_map[key]].is_a?(Array)
  102. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  103. end
  104. 2 elsif !attributes[attribute_map[key]].nil?
  105. 2 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  106. end
  107. end
  108. 2 new(transformed_hash)
  109. end
  110. # Returns the object in the form of hash
  111. # @return [Hash] Returns the object in the form of hash
  112. 1 def to_hash
  113. 2 hash = {}
  114. 2 self.class.attribute_map.each_pair do |attr, param|
  115. 2 value = self.send(attr)
  116. 2 if value.nil?
  117. is_nullable = self.class.openapi_nullable.include?(attr)
  118. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  119. end
  120. 2 hash[param] = _to_hash(value)
  121. end
  122. 2 hash
  123. end
  124. end
  125. end

lib/bandwidth-sdk/models/messaging_request_error.rb

76.25% lines covered

80 relevant lines. 61 lines covered and 19 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MessagingRequestError < ApiModelBase
  13. 1 attr_accessor :type
  14. 1 attr_accessor :description
  15. # Attribute mapping from ruby-style variable name to JSON key.
  16. 1 def self.attribute_map
  17. 21 {
  18. :'type' => :'type',
  19. :'description' => :'description'
  20. }
  21. end
  22. # Returns attribute mapping this model knows about
  23. 1 def self.acceptable_attribute_map
  24. 10 attribute_map
  25. end
  26. # Returns all the JSON keys this model knows about
  27. 1 def self.acceptable_attributes
  28. 1 acceptable_attribute_map.values
  29. end
  30. # Attribute type mapping.
  31. 1 def self.openapi_types
  32. 1 {
  33. :'type' => :'String',
  34. :'description' => :'String'
  35. }
  36. end
  37. # List of attributes with nullable: true
  38. 1 def self.openapi_nullable
  39. 1 Set.new([
  40. ])
  41. end
  42. # Initializes the object
  43. # @param [Hash] attributes Model attributes in the form of hash
  44. 1 def initialize(attributes = {})
  45. 10 if (!attributes.is_a?(Hash))
  46. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MessagingRequestError` initialize method'
  47. end
  48. # check to see if the attribute exists and convert string to symbol for hash key
  49. 9 acceptable_attribute_map = self.class.acceptable_attribute_map
  50. 9 attributes = attributes.each_with_object({}) { |(k, v), h|
  51. 16 if (!acceptable_attribute_map.key?(k.to_sym))
  52. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MessagingRequestError`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  53. end
  54. 15 h[k.to_sym] = v
  55. }
  56. 8 if attributes.key?(:'type')
  57. 8 self.type = attributes[:'type']
  58. else
  59. self.type = nil
  60. end
  61. 7 if attributes.key?(:'description')
  62. 7 self.description = attributes[:'description']
  63. else
  64. self.description = nil
  65. end
  66. end
  67. # Show invalid properties with the reasons. Usually used together with valid?
  68. # @return Array for valid properties with the reasons
  69. 1 def list_invalid_properties
  70. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  71. invalid_properties = Array.new
  72. if @type.nil?
  73. invalid_properties.push('invalid value for "type", type cannot be nil.')
  74. end
  75. if @description.nil?
  76. invalid_properties.push('invalid value for "description", description cannot be nil.')
  77. end
  78. invalid_properties
  79. end
  80. # Check to see if the all the properties in the model are valid
  81. # @return true if the model is valid
  82. 1 def valid?
  83. warn '[DEPRECATED] the `valid?` method is obsolete'
  84. return false if @type.nil?
  85. return false if @description.nil?
  86. true
  87. end
  88. # Custom attribute writer method with validation
  89. # @param [Object] type Value to be assigned
  90. 1 def type=(type)
  91. 8 if type.nil?
  92. 1 fail ArgumentError, 'type cannot be nil'
  93. end
  94. 7 @type = type
  95. end
  96. # Custom attribute writer method with validation
  97. # @param [Object] description Value to be assigned
  98. 1 def description=(description)
  99. 7 if description.nil?
  100. 1 fail ArgumentError, 'description cannot be nil'
  101. end
  102. 6 @description = description
  103. end
  104. # Checks equality by comparing each attribute.
  105. # @param [Object] Object to be compared
  106. 1 def ==(o)
  107. 2 return true if self.equal?(o)
  108. 2 self.class == o.class &&
  109. type == o.type &&
  110. description == o.description
  111. end
  112. # @see the `==` method
  113. # @param [Object] Object to be compared
  114. 1 def eql?(o)
  115. 2 self == o
  116. end
  117. # Calculates hash code according to all attributes.
  118. # @return [Integer] Hash code
  119. 1 def hash
  120. [type, description].hash
  121. end
  122. # Builds the object from hash
  123. # @param [Hash] attributes Model attributes in the form of hash
  124. # @return [Object] Returns the model itself
  125. 1 def self.build_from_hash(attributes)
  126. 1 return nil unless attributes.is_a?(Hash)
  127. 1 attributes = attributes.transform_keys(&:to_sym)
  128. 1 transformed_hash = {}
  129. 1 openapi_types.each_pair do |key, type|
  130. 2 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  131. transformed_hash["#{key}"] = nil
  132. 2 elsif type =~ /\AArray<(.*)>/i
  133. # check to ensure the input is an array given that the attribute
  134. # is documented as an array but the input is not
  135. if attributes[attribute_map[key]].is_a?(Array)
  136. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  137. end
  138. 2 elsif !attributes[attribute_map[key]].nil?
  139. 2 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  140. end
  141. end
  142. 1 new(transformed_hash)
  143. end
  144. # Returns the object in the form of hash
  145. # @return [Hash] Returns the object in the form of hash
  146. 1 def to_hash
  147. 2 hash = {}
  148. 2 self.class.attribute_map.each_pair do |attr, param|
  149. 4 value = self.send(attr)
  150. 4 if value.nil?
  151. is_nullable = self.class.openapi_nullable.include?(attr)
  152. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  153. end
  154. 4 hash[param] = _to_hash(value)
  155. end
  156. 2 hash
  157. end
  158. end
  159. end

lib/bandwidth-sdk/models/mfa_forbidden_request_error.rb

81.97% lines covered

61 relevant lines. 50 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MfaForbiddenRequestError < ApiModelBase
  13. # The message containing the reason behind the request being forbidden.
  14. 1 attr_accessor :message
  15. # Attribute mapping from ruby-style variable name to JSON key.
  16. 1 def self.attribute_map
  17. 15 {
  18. :'message' => :'message'
  19. }
  20. end
  21. # Returns attribute mapping this model knows about
  22. 1 def self.acceptable_attribute_map
  23. 8 attribute_map
  24. end
  25. # Returns all the JSON keys this model knows about
  26. 1 def self.acceptable_attributes
  27. 1 acceptable_attribute_map.values
  28. end
  29. # Attribute type mapping.
  30. 1 def self.openapi_types
  31. 1 {
  32. :'message' => :'String'
  33. }
  34. end
  35. # List of attributes with nullable: true
  36. 1 def self.openapi_nullable
  37. 1 Set.new([
  38. ])
  39. end
  40. # Initializes the object
  41. # @param [Hash] attributes Model attributes in the form of hash
  42. 1 def initialize(attributes = {})
  43. 8 if (!attributes.is_a?(Hash))
  44. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MfaForbiddenRequestError` initialize method'
  45. end
  46. # check to see if the attribute exists and convert string to symbol for hash key
  47. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  48. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  49. 5 if (!acceptable_attribute_map.key?(k.to_sym))
  50. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MfaForbiddenRequestError`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  51. end
  52. 4 h[k.to_sym] = v
  53. }
  54. 6 if attributes.key?(:'message')
  55. 4 self.message = attributes[:'message']
  56. end
  57. end
  58. # Show invalid properties with the reasons. Usually used together with valid?
  59. # @return Array for valid properties with the reasons
  60. 1 def list_invalid_properties
  61. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  62. invalid_properties = Array.new
  63. invalid_properties
  64. end
  65. # Check to see if the all the properties in the model are valid
  66. # @return true if the model is valid
  67. 1 def valid?
  68. warn '[DEPRECATED] the `valid?` method is obsolete'
  69. true
  70. end
  71. # Checks equality by comparing each attribute.
  72. # @param [Object] Object to be compared
  73. 1 def ==(o)
  74. 2 return true if self.equal?(o)
  75. 2 self.class == o.class &&
  76. message == o.message
  77. end
  78. # @see the `==` method
  79. # @param [Object] Object to be compared
  80. 1 def eql?(o)
  81. 2 self == o
  82. end
  83. # Calculates hash code according to all attributes.
  84. # @return [Integer] Hash code
  85. 1 def hash
  86. [message].hash
  87. end
  88. # Builds the object from hash
  89. # @param [Hash] attributes Model attributes in the form of hash
  90. # @return [Object] Returns the model itself
  91. 1 def self.build_from_hash(attributes)
  92. 1 return nil unless attributes.is_a?(Hash)
  93. 1 attributes = attributes.transform_keys(&:to_sym)
  94. 1 transformed_hash = {}
  95. 1 openapi_types.each_pair do |key, type|
  96. 1 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  97. transformed_hash["#{key}"] = nil
  98. 1 elsif type =~ /\AArray<(.*)>/i
  99. # check to ensure the input is an array given that the attribute
  100. # is documented as an array but the input is not
  101. if attributes[attribute_map[key]].is_a?(Array)
  102. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  103. end
  104. 1 elsif !attributes[attribute_map[key]].nil?
  105. 1 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  106. end
  107. end
  108. 1 new(transformed_hash)
  109. end
  110. # Returns the object in the form of hash
  111. # @return [Hash] Returns the object in the form of hash
  112. 1 def to_hash
  113. 2 hash = {}
  114. 2 self.class.attribute_map.each_pair do |attr, param|
  115. 2 value = self.send(attr)
  116. 2 if value.nil?
  117. is_nullable = self.class.openapi_nullable.include?(attr)
  118. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  119. end
  120. 2 hash[param] = _to_hash(value)
  121. end
  122. 2 hash
  123. end
  124. end
  125. end

lib/bandwidth-sdk/models/mfa_request_error.rb

82.81% lines covered

64 relevant lines. 53 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MfaRequestError < ApiModelBase
  13. # A message describing the error with your request.
  14. 1 attr_accessor :error
  15. # The associated requestId from AWS.
  16. 1 attr_accessor :request_id
  17. # Attribute mapping from ruby-style variable name to JSON key.
  18. 1 def self.attribute_map
  19. 19 {
  20. :'error' => :'error',
  21. :'request_id' => :'requestId'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 8 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 1 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 1 {
  35. :'error' => :'String',
  36. :'request_id' => :'String'
  37. }
  38. end
  39. # List of attributes with nullable: true
  40. 1 def self.openapi_nullable
  41. 1 Set.new([
  42. ])
  43. end
  44. # Initializes the object
  45. # @param [Hash] attributes Model attributes in the form of hash
  46. 1 def initialize(attributes = {})
  47. 8 if (!attributes.is_a?(Hash))
  48. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MfaRequestError` initialize method'
  49. end
  50. # check to see if the attribute exists and convert string to symbol for hash key
  51. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  52. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  53. 9 if (!acceptable_attribute_map.key?(k.to_sym))
  54. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MfaRequestError`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  55. end
  56. 8 h[k.to_sym] = v
  57. }
  58. 6 if attributes.key?(:'error')
  59. 4 self.error = attributes[:'error']
  60. end
  61. 6 if attributes.key?(:'request_id')
  62. 4 self.request_id = attributes[:'request_id']
  63. end
  64. end
  65. # Show invalid properties with the reasons. Usually used together with valid?
  66. # @return Array for valid properties with the reasons
  67. 1 def list_invalid_properties
  68. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  69. invalid_properties = Array.new
  70. invalid_properties
  71. end
  72. # Check to see if the all the properties in the model are valid
  73. # @return true if the model is valid
  74. 1 def valid?
  75. warn '[DEPRECATED] the `valid?` method is obsolete'
  76. true
  77. end
  78. # Checks equality by comparing each attribute.
  79. # @param [Object] Object to be compared
  80. 1 def ==(o)
  81. 2 return true if self.equal?(o)
  82. 2 self.class == o.class &&
  83. error == o.error &&
  84. request_id == o.request_id
  85. end
  86. # @see the `==` method
  87. # @param [Object] Object to be compared
  88. 1 def eql?(o)
  89. 2 self == o
  90. end
  91. # Calculates hash code according to all attributes.
  92. # @return [Integer] Hash code
  93. 1 def hash
  94. [error, request_id].hash
  95. end
  96. # Builds the object from hash
  97. # @param [Hash] attributes Model attributes in the form of hash
  98. # @return [Object] Returns the model itself
  99. 1 def self.build_from_hash(attributes)
  100. 1 return nil unless attributes.is_a?(Hash)
  101. 1 attributes = attributes.transform_keys(&:to_sym)
  102. 1 transformed_hash = {}
  103. 1 openapi_types.each_pair do |key, type|
  104. 2 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  105. transformed_hash["#{key}"] = nil
  106. 2 elsif type =~ /\AArray<(.*)>/i
  107. # check to ensure the input is an array given that the attribute
  108. # is documented as an array but the input is not
  109. if attributes[attribute_map[key]].is_a?(Array)
  110. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  111. end
  112. 2 elsif !attributes[attribute_map[key]].nil?
  113. 2 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  114. end
  115. end
  116. 1 new(transformed_hash)
  117. end
  118. # Returns the object in the form of hash
  119. # @return [Hash] Returns the object in the form of hash
  120. 1 def to_hash
  121. 2 hash = {}
  122. 2 self.class.attribute_map.each_pair do |attr, param|
  123. 4 value = self.send(attr)
  124. 4 if value.nil?
  125. is_nullable = self.class.openapi_nullable.include?(attr)
  126. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  127. end
  128. 4 hash[param] = _to_hash(value)
  129. end
  130. 2 hash
  131. end
  132. end
  133. end

lib/bandwidth-sdk/models/mfa_unauthorized_request_error.rb

81.97% lines covered

61 relevant lines. 50 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MfaUnauthorizedRequestError < ApiModelBase
  13. # Unauthorized
  14. 1 attr_accessor :message
  15. # Attribute mapping from ruby-style variable name to JSON key.
  16. 1 def self.attribute_map
  17. 15 {
  18. :'message' => :'message'
  19. }
  20. end
  21. # Returns attribute mapping this model knows about
  22. 1 def self.acceptable_attribute_map
  23. 8 attribute_map
  24. end
  25. # Returns all the JSON keys this model knows about
  26. 1 def self.acceptable_attributes
  27. 1 acceptable_attribute_map.values
  28. end
  29. # Attribute type mapping.
  30. 1 def self.openapi_types
  31. 1 {
  32. :'message' => :'String'
  33. }
  34. end
  35. # List of attributes with nullable: true
  36. 1 def self.openapi_nullable
  37. 1 Set.new([
  38. ])
  39. end
  40. # Initializes the object
  41. # @param [Hash] attributes Model attributes in the form of hash
  42. 1 def initialize(attributes = {})
  43. 8 if (!attributes.is_a?(Hash))
  44. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MfaUnauthorizedRequestError` initialize method'
  45. end
  46. # check to see if the attribute exists and convert string to symbol for hash key
  47. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  48. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  49. 5 if (!acceptable_attribute_map.key?(k.to_sym))
  50. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MfaUnauthorizedRequestError`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  51. end
  52. 4 h[k.to_sym] = v
  53. }
  54. 6 if attributes.key?(:'message')
  55. 4 self.message = attributes[:'message']
  56. end
  57. end
  58. # Show invalid properties with the reasons. Usually used together with valid?
  59. # @return Array for valid properties with the reasons
  60. 1 def list_invalid_properties
  61. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  62. invalid_properties = Array.new
  63. invalid_properties
  64. end
  65. # Check to see if the all the properties in the model are valid
  66. # @return true if the model is valid
  67. 1 def valid?
  68. warn '[DEPRECATED] the `valid?` method is obsolete'
  69. true
  70. end
  71. # Checks equality by comparing each attribute.
  72. # @param [Object] Object to be compared
  73. 1 def ==(o)
  74. 2 return true if self.equal?(o)
  75. 2 self.class == o.class &&
  76. message == o.message
  77. end
  78. # @see the `==` method
  79. # @param [Object] Object to be compared
  80. 1 def eql?(o)
  81. 2 self == o
  82. end
  83. # Calculates hash code according to all attributes.
  84. # @return [Integer] Hash code
  85. 1 def hash
  86. [message].hash
  87. end
  88. # Builds the object from hash
  89. # @param [Hash] attributes Model attributes in the form of hash
  90. # @return [Object] Returns the model itself
  91. 1 def self.build_from_hash(attributes)
  92. 1 return nil unless attributes.is_a?(Hash)
  93. 1 attributes = attributes.transform_keys(&:to_sym)
  94. 1 transformed_hash = {}
  95. 1 openapi_types.each_pair do |key, type|
  96. 1 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  97. transformed_hash["#{key}"] = nil
  98. 1 elsif type =~ /\AArray<(.*)>/i
  99. # check to ensure the input is an array given that the attribute
  100. # is documented as an array but the input is not
  101. if attributes[attribute_map[key]].is_a?(Array)
  102. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  103. end
  104. 1 elsif !attributes[attribute_map[key]].nil?
  105. 1 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  106. end
  107. end
  108. 1 new(transformed_hash)
  109. end
  110. # Returns the object in the form of hash
  111. # @return [Hash] Returns the object in the form of hash
  112. 1 def to_hash
  113. 2 hash = {}
  114. 2 self.class.attribute_map.each_pair do |attr, param|
  115. 2 value = self.send(attr)
  116. 2 if value.nil?
  117. is_nullable = self.class.openapi_nullable.include?(attr)
  118. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  119. end
  120. 2 hash[param] = _to_hash(value)
  121. end
  122. 2 hash
  123. end
  124. end
  125. end

lib/bandwidth-sdk/models/mms_message_content.rb

86.49% lines covered

74 relevant lines. 64 lines covered and 10 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MmsMessageContent < ApiModelBase
  13. # The contents of the text message. Must be 2048 characters or less.
  14. 1 attr_accessor :text
  15. 1 attr_accessor :media
  16. # Attribute mapping from ruby-style variable name to JSON key.
  17. 1 def self.attribute_map
  18. 49 {
  19. :'text' => :'text',
  20. :'media' => :'media'
  21. }
  22. end
  23. # Returns attribute mapping this model knows about
  24. 1 def self.acceptable_attribute_map
  25. 22 attribute_map
  26. end
  27. # Returns all the JSON keys this model knows about
  28. 1 def self.acceptable_attributes
  29. 1 acceptable_attribute_map.values
  30. end
  31. # Attribute type mapping.
  32. 1 def self.openapi_types
  33. 3 {
  34. :'text' => :'String',
  35. :'media' => :'Array<MmsMessageContentFile>'
  36. }
  37. end
  38. # List of attributes with nullable: true
  39. 1 def self.openapi_nullable
  40. 5 Set.new([
  41. ])
  42. end
  43. # Initializes the object
  44. # @param [Hash] attributes Model attributes in the form of hash
  45. 1 def initialize(attributes = {})
  46. 22 if (!attributes.is_a?(Hash))
  47. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MmsMessageContent` initialize method'
  48. end
  49. # check to see if the attribute exists and convert string to symbol for hash key
  50. 21 acceptable_attribute_map = self.class.acceptable_attribute_map
  51. 21 attributes = attributes.each_with_object({}) { |(k, v), h|
  52. 23 if (!acceptable_attribute_map.key?(k.to_sym))
  53. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MmsMessageContent`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  54. end
  55. 22 h[k.to_sym] = v
  56. }
  57. 20 if attributes.key?(:'text')
  58. 18 self.text = attributes[:'text']
  59. end
  60. 18 if attributes.key?(:'media')
  61. 4 if (value = attributes[:'media']).is_a?(Array)
  62. 4 self.media = value
  63. end
  64. end
  65. end
  66. # Show invalid properties with the reasons. Usually used together with valid?
  67. # @return Array for valid properties with the reasons
  68. 1 def list_invalid_properties
  69. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  70. invalid_properties = Array.new
  71. if !@text.nil? && @text.to_s.length > 2048
  72. invalid_properties.push('invalid value for "text", the character length must be smaller than or equal to 2048.')
  73. end
  74. invalid_properties
  75. end
  76. # Check to see if the all the properties in the model are valid
  77. # @return true if the model is valid
  78. 1 def valid?
  79. warn '[DEPRECATED] the `valid?` method is obsolete'
  80. return false if !@text.nil? && @text.to_s.length > 2048
  81. true
  82. end
  83. # Custom attribute writer method with validation
  84. # @param [Object] text Value to be assigned
  85. 1 def text=(text)
  86. 18 if text.nil?
  87. 1 fail ArgumentError, 'text cannot be nil'
  88. end
  89. 17 if text.to_s.length > 2048
  90. 1 fail ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 2048.'
  91. end
  92. 16 @text = text
  93. end
  94. # Checks equality by comparing each attribute.
  95. # @param [Object] Object to be compared
  96. 1 def ==(o)
  97. 4 return true if self.equal?(o)
  98. 4 self.class == o.class &&
  99. text == o.text &&
  100. media == o.media
  101. end
  102. # @see the `==` method
  103. # @param [Object] Object to be compared
  104. 1 def eql?(o)
  105. 2 self == o
  106. end
  107. # Calculates hash code according to all attributes.
  108. # @return [Integer] Hash code
  109. 1 def hash
  110. [text, media].hash
  111. end
  112. # Builds the object from hash
  113. # @param [Hash] attributes Model attributes in the form of hash
  114. # @return [Object] Returns the model itself
  115. 1 def self.build_from_hash(attributes)
  116. 3 return nil unless attributes.is_a?(Hash)
  117. 3 attributes = attributes.transform_keys(&:to_sym)
  118. 3 transformed_hash = {}
  119. 3 openapi_types.each_pair do |key, type|
  120. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  121. transformed_hash["#{key}"] = nil
  122. 6 elsif type =~ /\AArray<(.*)>/i
  123. # check to ensure the input is an array given that the attribute
  124. # is documented as an array but the input is not
  125. 3 if attributes[attribute_map[key]].is_a?(Array)
  126. 2 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  127. end
  128. 3 elsif !attributes[attribute_map[key]].nil?
  129. 3 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  130. end
  131. end
  132. 3 new(transformed_hash)
  133. end
  134. # Returns the object in the form of hash
  135. # @return [Hash] Returns the object in the form of hash
  136. 1 def to_hash
  137. 6 hash = {}
  138. 6 self.class.attribute_map.each_pair do |attr, param|
  139. 12 value = self.send(attr)
  140. 12 if value.nil?
  141. 4 is_nullable = self.class.openapi_nullable.include?(attr)
  142. 4 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  143. end
  144. 8 hash[param] = _to_hash(value)
  145. end
  146. 6 hash
  147. end
  148. end
  149. end

lib/bandwidth-sdk/models/mms_message_content_file.rb

75.68% lines covered

74 relevant lines. 56 lines covered and 18 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MmsMessageContentFile < ApiModelBase
  13. # The URL of a media attachment. For MMS, the API limits file size to 3.5MB. Specific carriers and channels may have a smaller limit that could cause a large file to fail, see more at [Bandwidth Support](https://www.bandwidth.com/support/en/articles/12823216-what-are-the-mms-file-size-limits) for more details.
  14. 1 attr_accessor :file_url
  15. # Attribute mapping from ruby-style variable name to JSON key.
  16. 1 def self.attribute_map
  17. 27 {
  18. :'file_url' => :'fileUrl'
  19. }
  20. end
  21. # Returns attribute mapping this model knows about
  22. 1 def self.acceptable_attribute_map
  23. 14 attribute_map
  24. end
  25. # Returns all the JSON keys this model knows about
  26. 1 def self.acceptable_attributes
  27. 1 acceptable_attribute_map.values
  28. end
  29. # Attribute type mapping.
  30. 1 def self.openapi_types
  31. 2 {
  32. :'file_url' => :'String'
  33. }
  34. end
  35. # List of attributes with nullable: true
  36. 1 def self.openapi_nullable
  37. 1 Set.new([
  38. ])
  39. end
  40. # Initializes the object
  41. # @param [Hash] attributes Model attributes in the form of hash
  42. 1 def initialize(attributes = {})
  43. 14 if (!attributes.is_a?(Hash))
  44. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MmsMessageContentFile` initialize method'
  45. end
  46. # check to see if the attribute exists and convert string to symbol for hash key
  47. 13 acceptable_attribute_map = self.class.acceptable_attribute_map
  48. 13 attributes = attributes.each_with_object({}) { |(k, v), h|
  49. 13 if (!acceptable_attribute_map.key?(k.to_sym))
  50. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MmsMessageContentFile`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  51. end
  52. 12 h[k.to_sym] = v
  53. }
  54. 12 if attributes.key?(:'file_url')
  55. 12 self.file_url = attributes[:'file_url']
  56. else
  57. self.file_url = nil
  58. end
  59. end
  60. # Show invalid properties with the reasons. Usually used together with valid?
  61. # @return Array for valid properties with the reasons
  62. 1 def list_invalid_properties
  63. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  64. invalid_properties = Array.new
  65. if @file_url.nil?
  66. invalid_properties.push('invalid value for "file_url", file_url cannot be nil.')
  67. end
  68. if @file_url.to_s.length > 1000
  69. invalid_properties.push('invalid value for "file_url", the character length must be smaller than or equal to 1000.')
  70. end
  71. invalid_properties
  72. end
  73. # Check to see if the all the properties in the model are valid
  74. # @return true if the model is valid
  75. 1 def valid?
  76. warn '[DEPRECATED] the `valid?` method is obsolete'
  77. return false if @file_url.nil?
  78. return false if @file_url.to_s.length > 1000
  79. true
  80. end
  81. # Custom attribute writer method with validation
  82. # @param [Object] file_url Value to be assigned
  83. 1 def file_url=(file_url)
  84. 12 if file_url.nil?
  85. 1 fail ArgumentError, 'file_url cannot be nil'
  86. end
  87. 11 if file_url.to_s.length > 1000
  88. 1 fail ArgumentError, 'invalid value for "file_url", the character length must be smaller than or equal to 1000.'
  89. end
  90. 10 @file_url = file_url
  91. end
  92. # Checks equality by comparing each attribute.
  93. # @param [Object] Object to be compared
  94. 1 def ==(o)
  95. 2 return true if self.equal?(o)
  96. 2 self.class == o.class &&
  97. file_url == o.file_url
  98. end
  99. # @see the `==` method
  100. # @param [Object] Object to be compared
  101. 1 def eql?(o)
  102. 2 self == o
  103. end
  104. # Calculates hash code according to all attributes.
  105. # @return [Integer] Hash code
  106. 1 def hash
  107. [file_url].hash
  108. end
  109. # Builds the object from hash
  110. # @param [Hash] attributes Model attributes in the form of hash
  111. # @return [Object] Returns the model itself
  112. 1 def self.build_from_hash(attributes)
  113. 2 return nil unless attributes.is_a?(Hash)
  114. 2 attributes = attributes.transform_keys(&:to_sym)
  115. 2 transformed_hash = {}
  116. 2 openapi_types.each_pair do |key, type|
  117. 2 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  118. transformed_hash["#{key}"] = nil
  119. 2 elsif type =~ /\AArray<(.*)>/i
  120. # check to ensure the input is an array given that the attribute
  121. # is documented as an array but the input is not
  122. if attributes[attribute_map[key]].is_a?(Array)
  123. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  124. end
  125. 2 elsif !attributes[attribute_map[key]].nil?
  126. 2 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  127. end
  128. end
  129. 2 new(transformed_hash)
  130. end
  131. # Returns the object in the form of hash
  132. # @return [Hash] Returns the object in the form of hash
  133. 1 def to_hash
  134. 4 hash = {}
  135. 4 self.class.attribute_map.each_pair do |attr, param|
  136. 4 value = self.send(attr)
  137. 4 if value.nil?
  138. is_nullable = self.class.openapi_nullable.include?(attr)
  139. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  140. end
  141. 4 hash[param] = _to_hash(value)
  142. end
  143. 4 hash
  144. end
  145. end
  146. end

lib/bandwidth-sdk/models/multi_channel_action.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 module MultiChannelAction
  13. 1 class << self
  14. # List of class defined in anyOf (OpenAPI v3)
  15. 1 def openapi_any_of
  16. 2 [
  17. :'MultiChannelActionCalendarEvent',
  18. :'RbmActionBase',
  19. :'RbmActionDial',
  20. :'RbmActionOpenUrl',
  21. :'RbmActionViewLocation'
  22. ]
  23. end
  24. # Discriminator's property name (OpenAPI v3)
  25. 1 def openapi_discriminator_name
  26. 15 :'type'
  27. end
  28. # Discriminator's mapping (OpenAPI v3)
  29. 1 def openapi_discriminator_mapping
  30. 20 {
  31. :'CREATE_CALENDAR_EVENT' => :'MultiChannelActionCalendarEvent',
  32. :'DIAL_PHONE' => :'RbmActionDial',
  33. :'OPEN_URL' => :'RbmActionOpenUrl',
  34. :'REPLY' => :'RbmActionBase',
  35. :'REQUEST_LOCATION' => :'RbmActionBase',
  36. :'SHOW_LOCATION' => :'RbmActionViewLocation'
  37. }
  38. end
  39. # Builds the object
  40. # @param [Mixed] Data to be matched against the list of anyOf items
  41. # @return [Object] Returns the model or the data itself
  42. 1 def build(data)
  43. 14 discriminator_value = data[openapi_discriminator_name]
  44. 14 return nil if discriminator_value.nil?
  45. 13 klass = openapi_discriminator_mapping[discriminator_value.to_s.to_sym]
  46. 13 return nil unless klass
  47. 12 Bandwidth.const_get(klass).build_from_hash(data)
  48. end
  49. end
  50. end
  51. end

lib/bandwidth-sdk/models/multi_channel_action_calendar_event.rb

67.07% lines covered

164 relevant lines. 110 lines covered and 54 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MultiChannelActionCalendarEvent < ApiModelBase
  13. 1 attr_accessor :type
  14. # Displayed text for user to click
  15. 1 attr_accessor :text
  16. # Base64 payload the customer receives when the reply is clicked.
  17. 1 attr_accessor :postback_data
  18. # The title of the event.
  19. 1 attr_accessor :title
  20. # The start time of the event. Must be a valid RFC-3339 value, e.g., 2021-03-14T01:59:26Z or 2021-03-13T20:59:26-05:00.
  21. 1 attr_accessor :start_time
  22. # The end time of the event. Must be a valid RFC-3339 value, e.g., 2021-03-14T01:59:26Z or 2021-03-13T20:59:26-05:00.
  23. 1 attr_accessor :end_time
  24. # The description of the event.
  25. 1 attr_accessor :description
  26. 1 class EnumAttributeValidator
  27. 1 attr_reader :datatype
  28. 1 attr_reader :allowable_values
  29. 1 def initialize(datatype, allowable_values)
  30. @allowable_values = allowable_values.map do |value|
  31. case datatype.to_s
  32. when /Integer/i
  33. value.to_i
  34. when /Float/i
  35. value.to_f
  36. else
  37. value
  38. end
  39. end
  40. end
  41. 1 def valid?(value)
  42. !value || allowable_values.include?(value)
  43. end
  44. end
  45. # Attribute mapping from ruby-style variable name to JSON key.
  46. 1 def self.attribute_map
  47. 49 {
  48. :'type' => :'type',
  49. :'text' => :'text',
  50. :'postback_data' => :'postbackData',
  51. :'title' => :'title',
  52. :'start_time' => :'startTime',
  53. :'end_time' => :'endTime',
  54. :'description' => :'description'
  55. }
  56. end
  57. # Returns attribute mapping this model knows about
  58. 1 def self.acceptable_attribute_map
  59. 18 attribute_map
  60. end
  61. # Returns all the JSON keys this model knows about
  62. 1 def self.acceptable_attributes
  63. 1 acceptable_attribute_map.values
  64. end
  65. # Attribute type mapping.
  66. 1 def self.openapi_types
  67. 1 {
  68. :'type' => :'RbmActionTypeEnum',
  69. :'text' => :'String',
  70. :'postback_data' => :'String',
  71. :'title' => :'String',
  72. :'start_time' => :'Time',
  73. :'end_time' => :'Time',
  74. :'description' => :'String'
  75. }
  76. end
  77. # List of attributes with nullable: true
  78. 1 def self.openapi_nullable
  79. 1 Set.new([
  80. ])
  81. end
  82. # List of class defined in allOf (OpenAPI v3)
  83. 1 def self.openapi_all_of
  84. [
  85. :'RbmActionBase'
  86. ]
  87. end
  88. # Initializes the object
  89. # @param [Hash] attributes Model attributes in the form of hash
  90. 1 def initialize(attributes = {})
  91. 18 if (!attributes.is_a?(Hash))
  92. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelActionCalendarEvent` initialize method'
  93. end
  94. # check to see if the attribute exists and convert string to symbol for hash key
  95. 17 acceptable_attribute_map = self.class.acceptable_attribute_map
  96. 17 attributes = attributes.each_with_object({}) { |(k, v), h|
  97. 78 if (!acceptable_attribute_map.key?(k.to_sym))
  98. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelActionCalendarEvent`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  99. end
  100. 77 h[k.to_sym] = v
  101. }
  102. 16 if attributes.key?(:'type')
  103. 16 self.type = attributes[:'type']
  104. else
  105. self.type = nil
  106. end
  107. 15 if attributes.key?(:'text')
  108. 15 self.text = attributes[:'text']
  109. else
  110. self.text = nil
  111. end
  112. 13 if attributes.key?(:'postback_data')
  113. 13 self.postback_data = attributes[:'postback_data']
  114. else
  115. self.postback_data = nil
  116. end
  117. 11 if attributes.key?(:'title')
  118. 11 self.title = attributes[:'title']
  119. else
  120. self.title = nil
  121. end
  122. 9 if attributes.key?(:'start_time')
  123. 9 self.start_time = attributes[:'start_time']
  124. else
  125. self.start_time = nil
  126. end
  127. 8 if attributes.key?(:'end_time')
  128. 8 self.end_time = attributes[:'end_time']
  129. else
  130. self.end_time = nil
  131. end
  132. 7 if attributes.key?(:'description')
  133. 5 self.description = attributes[:'description']
  134. end
  135. end
  136. # Show invalid properties with the reasons. Usually used together with valid?
  137. # @return Array for valid properties with the reasons
  138. 1 def list_invalid_properties
  139. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  140. invalid_properties = Array.new
  141. if @type.nil?
  142. invalid_properties.push('invalid value for "type", type cannot be nil.')
  143. end
  144. if @text.nil?
  145. invalid_properties.push('invalid value for "text", text cannot be nil.')
  146. end
  147. if @text.to_s.length > 25
  148. invalid_properties.push('invalid value for "text", the character length must be smaller than or equal to 25.')
  149. end
  150. if @postback_data.nil?
  151. invalid_properties.push('invalid value for "postback_data", postback_data cannot be nil.')
  152. end
  153. if @postback_data.to_s.length > 2048
  154. invalid_properties.push('invalid value for "postback_data", the character length must be smaller than or equal to 2048.')
  155. end
  156. if @title.nil?
  157. invalid_properties.push('invalid value for "title", title cannot be nil.')
  158. end
  159. if @title.to_s.length > 100
  160. invalid_properties.push('invalid value for "title", the character length must be smaller than or equal to 100.')
  161. end
  162. if @start_time.nil?
  163. invalid_properties.push('invalid value for "start_time", start_time cannot be nil.')
  164. end
  165. if @end_time.nil?
  166. invalid_properties.push('invalid value for "end_time", end_time cannot be nil.')
  167. end
  168. if !@description.nil? && @description.to_s.length > 500
  169. invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 500.')
  170. end
  171. invalid_properties
  172. end
  173. # Check to see if the all the properties in the model are valid
  174. # @return true if the model is valid
  175. 1 def valid?
  176. warn '[DEPRECATED] the `valid?` method is obsolete'
  177. return false if @type.nil?
  178. return false if @text.nil?
  179. return false if @text.to_s.length > 25
  180. return false if @postback_data.nil?
  181. return false if @postback_data.to_s.length > 2048
  182. return false if @title.nil?
  183. return false if @title.to_s.length > 100
  184. return false if @start_time.nil?
  185. return false if @end_time.nil?
  186. return false if !@description.nil? && @description.to_s.length > 500
  187. true
  188. end
  189. # Custom attribute writer method with validation
  190. # @param [Object] type Value to be assigned
  191. 1 def type=(type)
  192. 16 if type.nil?
  193. 1 fail ArgumentError, 'type cannot be nil'
  194. end
  195. 15 @type = type
  196. end
  197. # Custom attribute writer method with validation
  198. # @param [Object] text Value to be assigned
  199. 1 def text=(text)
  200. 15 if text.nil?
  201. 1 fail ArgumentError, 'text cannot be nil'
  202. end
  203. 14 if text.to_s.length > 25
  204. 1 fail ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 25.'
  205. end
  206. 13 @text = text
  207. end
  208. # Custom attribute writer method with validation
  209. # @param [Object] postback_data Value to be assigned
  210. 1 def postback_data=(postback_data)
  211. 13 if postback_data.nil?
  212. 1 fail ArgumentError, 'postback_data cannot be nil'
  213. end
  214. 12 if postback_data.to_s.length > 2048
  215. 1 fail ArgumentError, 'invalid value for "postback_data", the character length must be smaller than or equal to 2048.'
  216. end
  217. 11 @postback_data = postback_data
  218. end
  219. # Custom attribute writer method with validation
  220. # @param [Object] title Value to be assigned
  221. 1 def title=(title)
  222. 11 if title.nil?
  223. 1 fail ArgumentError, 'title cannot be nil'
  224. end
  225. 10 if title.to_s.length > 100
  226. 1 fail ArgumentError, 'invalid value for "title", the character length must be smaller than or equal to 100.'
  227. end
  228. 9 @title = title
  229. end
  230. # Custom attribute writer method with validation
  231. # @param [Object] start_time Value to be assigned
  232. 1 def start_time=(start_time)
  233. 9 if start_time.nil?
  234. 1 fail ArgumentError, 'start_time cannot be nil'
  235. end
  236. 8 @start_time = start_time
  237. end
  238. # Custom attribute writer method with validation
  239. # @param [Object] end_time Value to be assigned
  240. 1 def end_time=(end_time)
  241. 8 if end_time.nil?
  242. 1 fail ArgumentError, 'end_time cannot be nil'
  243. end
  244. 7 @end_time = end_time
  245. end
  246. # Custom attribute writer method with validation
  247. # @param [Object] description Value to be assigned
  248. 1 def description=(description)
  249. 7 if description.nil?
  250. 1 fail ArgumentError, 'description cannot be nil'
  251. end
  252. 6 if description.to_s.length > 500
  253. 1 fail ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 500.'
  254. end
  255. 5 @description = description
  256. end
  257. # Checks equality by comparing each attribute.
  258. # @param [Object] Object to be compared
  259. 1 def ==(o)
  260. 2 return true if self.equal?(o)
  261. 2 self.class == o.class &&
  262. type == o.type &&
  263. text == o.text &&
  264. postback_data == o.postback_data &&
  265. title == o.title &&
  266. start_time == o.start_time &&
  267. end_time == o.end_time &&
  268. description == o.description
  269. end
  270. # @see the `==` method
  271. # @param [Object] Object to be compared
  272. 1 def eql?(o)
  273. 2 self == o
  274. end
  275. # Calculates hash code according to all attributes.
  276. # @return [Integer] Hash code
  277. 1 def hash
  278. [type, text, postback_data, title, start_time, end_time, description].hash
  279. end
  280. # Builds the object from hash
  281. # @param [Hash] attributes Model attributes in the form of hash
  282. # @return [Object] Returns the model itself
  283. 1 def self.build_from_hash(attributes)
  284. 1 return nil unless attributes.is_a?(Hash)
  285. 1 attributes = attributes.transform_keys(&:to_sym)
  286. 1 transformed_hash = {}
  287. 1 openapi_types.each_pair do |key, type|
  288. 7 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  289. transformed_hash["#{key}"] = nil
  290. 7 elsif type =~ /\AArray<(.*)>/i
  291. # check to ensure the input is an array given that the attribute
  292. # is documented as an array but the input is not
  293. if attributes[attribute_map[key]].is_a?(Array)
  294. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  295. end
  296. 7 elsif !attributes[attribute_map[key]].nil?
  297. 7 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  298. end
  299. end
  300. 1 new(transformed_hash)
  301. end
  302. # Returns the object in the form of hash
  303. # @return [Hash] Returns the object in the form of hash
  304. 1 def to_hash
  305. 2 hash = {}
  306. 2 self.class.attribute_map.each_pair do |attr, param|
  307. 14 value = self.send(attr)
  308. 14 if value.nil?
  309. is_nullable = self.class.openapi_nullable.include?(attr)
  310. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  311. end
  312. 14 hash[param] = _to_hash(value)
  313. end
  314. 2 hash
  315. end
  316. end
  317. end

lib/bandwidth-sdk/models/multi_channel_channel_list_mms_object.rb

70.43% lines covered

115 relevant lines. 81 lines covered and 34 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MultiChannelChannelListMMSObject < ApiModelBase
  13. # The sender ID of the message. This could be an alphanumeric sender ID.
  14. 1 attr_accessor :from
  15. # The ID of the Application your from number or senderId is associated with in the Bandwidth App.
  16. 1 attr_accessor :application_id
  17. 1 attr_accessor :channel
  18. 1 attr_accessor :content
  19. 1 class EnumAttributeValidator
  20. 1 attr_reader :datatype
  21. 1 attr_reader :allowable_values
  22. 1 def initialize(datatype, allowable_values)
  23. @allowable_values = allowable_values.map do |value|
  24. case datatype.to_s
  25. when /Integer/i
  26. value.to_i
  27. when /Float/i
  28. value.to_f
  29. else
  30. value
  31. end
  32. end
  33. end
  34. 1 def valid?(value)
  35. !value || allowable_values.include?(value)
  36. end
  37. end
  38. # Attribute mapping from ruby-style variable name to JSON key.
  39. 1 def self.attribute_map
  40. 31 {
  41. :'from' => :'from',
  42. :'application_id' => :'applicationId',
  43. :'channel' => :'channel',
  44. :'content' => :'content'
  45. }
  46. end
  47. # Returns attribute mapping this model knows about
  48. 1 def self.acceptable_attribute_map
  49. 12 attribute_map
  50. end
  51. # Returns all the JSON keys this model knows about
  52. 1 def self.acceptable_attributes
  53. 1 acceptable_attribute_map.values
  54. end
  55. # Attribute type mapping.
  56. 1 def self.openapi_types
  57. 1 {
  58. :'from' => :'String',
  59. :'application_id' => :'String',
  60. :'channel' => :'MultiChannelMessageChannelEnum',
  61. :'content' => :'MmsMessageContent'
  62. }
  63. end
  64. # List of attributes with nullable: true
  65. 1 def self.openapi_nullable
  66. 1 Set.new([
  67. ])
  68. end
  69. # List of class defined in allOf (OpenAPI v3)
  70. 1 def self.openapi_all_of
  71. [
  72. :'MultiChannelChannelListObjectBase'
  73. ]
  74. end
  75. # Initializes the object
  76. # @param [Hash] attributes Model attributes in the form of hash
  77. 1 def initialize(attributes = {})
  78. 12 if (!attributes.is_a?(Hash))
  79. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelChannelListMMSObject` initialize method'
  80. end
  81. # check to see if the attribute exists and convert string to symbol for hash key
  82. 11 acceptable_attribute_map = self.class.acceptable_attribute_map
  83. 11 attributes = attributes.each_with_object({}) { |(k, v), h|
  84. 35 if (!acceptable_attribute_map.key?(k.to_sym))
  85. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelChannelListMMSObject`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  86. end
  87. 34 h[k.to_sym] = v
  88. }
  89. 10 if attributes.key?(:'from')
  90. 10 self.from = attributes[:'from']
  91. else
  92. self.from = nil
  93. end
  94. 9 if attributes.key?(:'application_id')
  95. 9 self.application_id = attributes[:'application_id']
  96. else
  97. self.application_id = nil
  98. end
  99. 8 if attributes.key?(:'channel')
  100. 8 self.channel = attributes[:'channel']
  101. else
  102. self.channel = nil
  103. end
  104. 7 if attributes.key?(:'content')
  105. 7 self.content = attributes[:'content']
  106. else
  107. self.content = nil
  108. end
  109. end
  110. # Show invalid properties with the reasons. Usually used together with valid?
  111. # @return Array for valid properties with the reasons
  112. 1 def list_invalid_properties
  113. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  114. invalid_properties = Array.new
  115. if @from.nil?
  116. invalid_properties.push('invalid value for "from", from cannot be nil.')
  117. end
  118. if @application_id.nil?
  119. invalid_properties.push('invalid value for "application_id", application_id cannot be nil.')
  120. end
  121. if @channel.nil?
  122. invalid_properties.push('invalid value for "channel", channel cannot be nil.')
  123. end
  124. if @content.nil?
  125. invalid_properties.push('invalid value for "content", content cannot be nil.')
  126. end
  127. invalid_properties
  128. end
  129. # Check to see if the all the properties in the model are valid
  130. # @return true if the model is valid
  131. 1 def valid?
  132. warn '[DEPRECATED] the `valid?` method is obsolete'
  133. return false if @from.nil?
  134. return false if @application_id.nil?
  135. return false if @channel.nil?
  136. return false if @content.nil?
  137. true
  138. end
  139. # Custom attribute writer method with validation
  140. # @param [Object] from Value to be assigned
  141. 1 def from=(from)
  142. 10 if from.nil?
  143. 1 fail ArgumentError, 'from cannot be nil'
  144. end
  145. 9 @from = from
  146. end
  147. # Custom attribute writer method with validation
  148. # @param [Object] application_id Value to be assigned
  149. 1 def application_id=(application_id)
  150. 9 if application_id.nil?
  151. 1 fail ArgumentError, 'application_id cannot be nil'
  152. end
  153. 8 @application_id = application_id
  154. end
  155. # Custom attribute writer method with validation
  156. # @param [Object] channel Value to be assigned
  157. 1 def channel=(channel)
  158. 8 if channel.nil?
  159. 1 fail ArgumentError, 'channel cannot be nil'
  160. end
  161. 7 @channel = channel
  162. end
  163. # Custom attribute writer method with validation
  164. # @param [Object] content Value to be assigned
  165. 1 def content=(content)
  166. 7 if content.nil?
  167. 1 fail ArgumentError, 'content cannot be nil'
  168. end
  169. 6 @content = content
  170. end
  171. # Checks equality by comparing each attribute.
  172. # @param [Object] Object to be compared
  173. 1 def ==(o)
  174. 2 return true if self.equal?(o)
  175. 2 self.class == o.class &&
  176. from == o.from &&
  177. application_id == o.application_id &&
  178. channel == o.channel &&
  179. content == o.content
  180. end
  181. # @see the `==` method
  182. # @param [Object] Object to be compared
  183. 1 def eql?(o)
  184. 2 self == o
  185. end
  186. # Calculates hash code according to all attributes.
  187. # @return [Integer] Hash code
  188. 1 def hash
  189. [from, application_id, channel, content].hash
  190. end
  191. # Builds the object from hash
  192. # @param [Hash] attributes Model attributes in the form of hash
  193. # @return [Object] Returns the model itself
  194. 1 def self.build_from_hash(attributes)
  195. 1 return nil unless attributes.is_a?(Hash)
  196. 1 attributes = attributes.transform_keys(&:to_sym)
  197. 1 transformed_hash = {}
  198. 1 openapi_types.each_pair do |key, type|
  199. 4 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  200. transformed_hash["#{key}"] = nil
  201. 4 elsif type =~ /\AArray<(.*)>/i
  202. # check to ensure the input is an array given that the attribute
  203. # is documented as an array but the input is not
  204. if attributes[attribute_map[key]].is_a?(Array)
  205. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  206. end
  207. 4 elsif !attributes[attribute_map[key]].nil?
  208. 4 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  209. end
  210. end
  211. 1 new(transformed_hash)
  212. end
  213. # Returns the object in the form of hash
  214. # @return [Hash] Returns the object in the form of hash
  215. 1 def to_hash
  216. 2 hash = {}
  217. 2 self.class.attribute_map.each_pair do |attr, param|
  218. 8 value = self.send(attr)
  219. 8 if value.nil?
  220. is_nullable = self.class.openapi_nullable.include?(attr)
  221. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  222. end
  223. 8 hash[param] = _to_hash(value)
  224. end
  225. 2 hash
  226. end
  227. end
  228. end

lib/bandwidth-sdk/models/multi_channel_channel_list_mms_response_object.rb

69.84% lines covered

126 relevant lines. 88 lines covered and 38 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MultiChannelChannelListMMSResponseObject < ApiModelBase
  13. # The sender ID of the message. This could be an alphanumeric sender ID.
  14. 1 attr_accessor :from
  15. # The ID of the Application your from number or senderId is associated with in the Bandwidth App.
  16. 1 attr_accessor :application_id
  17. 1 attr_accessor :channel
  18. 1 attr_accessor :content
  19. # The Bandwidth senderId associated with the message. Identical to 'from'.
  20. 1 attr_accessor :owner
  21. 1 class EnumAttributeValidator
  22. 1 attr_reader :datatype
  23. 1 attr_reader :allowable_values
  24. 1 def initialize(datatype, allowable_values)
  25. @allowable_values = allowable_values.map do |value|
  26. case datatype.to_s
  27. when /Integer/i
  28. value.to_i
  29. when /Float/i
  30. value.to_f
  31. else
  32. value
  33. end
  34. end
  35. end
  36. 1 def valid?(value)
  37. !value || allowable_values.include?(value)
  38. end
  39. end
  40. # Attribute mapping from ruby-style variable name to JSON key.
  41. 1 def self.attribute_map
  42. 36 {
  43. :'from' => :'from',
  44. :'application_id' => :'applicationId',
  45. :'channel' => :'channel',
  46. :'content' => :'content',
  47. :'owner' => :'owner'
  48. }
  49. end
  50. # Returns attribute mapping this model knows about
  51. 1 def self.acceptable_attribute_map
  52. 13 attribute_map
  53. end
  54. # Returns all the JSON keys this model knows about
  55. 1 def self.acceptable_attributes
  56. 1 acceptable_attribute_map.values
  57. end
  58. # Attribute type mapping.
  59. 1 def self.openapi_types
  60. 1 {
  61. :'from' => :'String',
  62. :'application_id' => :'String',
  63. :'channel' => :'MultiChannelMessageChannelEnum',
  64. :'content' => :'MmsMessageContent',
  65. :'owner' => :'String'
  66. }
  67. end
  68. # List of attributes with nullable: true
  69. 1 def self.openapi_nullable
  70. 1 Set.new([
  71. ])
  72. end
  73. # List of class defined in allOf (OpenAPI v3)
  74. 1 def self.openapi_all_of
  75. [
  76. :'MultiChannelChannelListMMSObject',
  77. :'MultiChannelChannelListOwnerObject'
  78. ]
  79. end
  80. # Initializes the object
  81. # @param [Hash] attributes Model attributes in the form of hash
  82. 1 def initialize(attributes = {})
  83. 13 if (!attributes.is_a?(Hash))
  84. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelChannelListMMSResponseObject` initialize method'
  85. end
  86. # check to see if the attribute exists and convert string to symbol for hash key
  87. 12 acceptable_attribute_map = self.class.acceptable_attribute_map
  88. 12 attributes = attributes.each_with_object({}) { |(k, v), h|
  89. 46 if (!acceptable_attribute_map.key?(k.to_sym))
  90. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelChannelListMMSResponseObject`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  91. end
  92. 45 h[k.to_sym] = v
  93. }
  94. 11 if attributes.key?(:'from')
  95. 11 self.from = attributes[:'from']
  96. else
  97. self.from = nil
  98. end
  99. 10 if attributes.key?(:'application_id')
  100. 10 self.application_id = attributes[:'application_id']
  101. else
  102. self.application_id = nil
  103. end
  104. 9 if attributes.key?(:'channel')
  105. 9 self.channel = attributes[:'channel']
  106. else
  107. self.channel = nil
  108. end
  109. 8 if attributes.key?(:'content')
  110. 8 self.content = attributes[:'content']
  111. else
  112. self.content = nil
  113. end
  114. 7 if attributes.key?(:'owner')
  115. 7 self.owner = attributes[:'owner']
  116. else
  117. self.owner = nil
  118. end
  119. end
  120. # Show invalid properties with the reasons. Usually used together with valid?
  121. # @return Array for valid properties with the reasons
  122. 1 def list_invalid_properties
  123. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  124. invalid_properties = Array.new
  125. if @from.nil?
  126. invalid_properties.push('invalid value for "from", from cannot be nil.')
  127. end
  128. if @application_id.nil?
  129. invalid_properties.push('invalid value for "application_id", application_id cannot be nil.')
  130. end
  131. if @channel.nil?
  132. invalid_properties.push('invalid value for "channel", channel cannot be nil.')
  133. end
  134. if @content.nil?
  135. invalid_properties.push('invalid value for "content", content cannot be nil.')
  136. end
  137. if @owner.nil?
  138. invalid_properties.push('invalid value for "owner", owner cannot be nil.')
  139. end
  140. invalid_properties
  141. end
  142. # Check to see if the all the properties in the model are valid
  143. # @return true if the model is valid
  144. 1 def valid?
  145. warn '[DEPRECATED] the `valid?` method is obsolete'
  146. return false if @from.nil?
  147. return false if @application_id.nil?
  148. return false if @channel.nil?
  149. return false if @content.nil?
  150. return false if @owner.nil?
  151. true
  152. end
  153. # Custom attribute writer method with validation
  154. # @param [Object] from Value to be assigned
  155. 1 def from=(from)
  156. 11 if from.nil?
  157. 1 fail ArgumentError, 'from cannot be nil'
  158. end
  159. 10 @from = from
  160. end
  161. # Custom attribute writer method with validation
  162. # @param [Object] application_id Value to be assigned
  163. 1 def application_id=(application_id)
  164. 10 if application_id.nil?
  165. 1 fail ArgumentError, 'application_id cannot be nil'
  166. end
  167. 9 @application_id = application_id
  168. end
  169. # Custom attribute writer method with validation
  170. # @param [Object] channel Value to be assigned
  171. 1 def channel=(channel)
  172. 9 if channel.nil?
  173. 1 fail ArgumentError, 'channel cannot be nil'
  174. end
  175. 8 @channel = channel
  176. end
  177. # Custom attribute writer method with validation
  178. # @param [Object] content Value to be assigned
  179. 1 def content=(content)
  180. 8 if content.nil?
  181. 1 fail ArgumentError, 'content cannot be nil'
  182. end
  183. 7 @content = content
  184. end
  185. # Custom attribute writer method with validation
  186. # @param [Object] owner Value to be assigned
  187. 1 def owner=(owner)
  188. 7 if owner.nil?
  189. 1 fail ArgumentError, 'owner cannot be nil'
  190. end
  191. 6 @owner = owner
  192. end
  193. # Checks equality by comparing each attribute.
  194. # @param [Object] Object to be compared
  195. 1 def ==(o)
  196. 2 return true if self.equal?(o)
  197. 2 self.class == o.class &&
  198. from == o.from &&
  199. application_id == o.application_id &&
  200. channel == o.channel &&
  201. content == o.content &&
  202. owner == o.owner
  203. end
  204. # @see the `==` method
  205. # @param [Object] Object to be compared
  206. 1 def eql?(o)
  207. 2 self == o
  208. end
  209. # Calculates hash code according to all attributes.
  210. # @return [Integer] Hash code
  211. 1 def hash
  212. [from, application_id, channel, content, owner].hash
  213. end
  214. # Builds the object from hash
  215. # @param [Hash] attributes Model attributes in the form of hash
  216. # @return [Object] Returns the model itself
  217. 1 def self.build_from_hash(attributes)
  218. 1 return nil unless attributes.is_a?(Hash)
  219. 1 attributes = attributes.transform_keys(&:to_sym)
  220. 1 transformed_hash = {}
  221. 1 openapi_types.each_pair do |key, type|
  222. 5 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  223. transformed_hash["#{key}"] = nil
  224. 5 elsif type =~ /\AArray<(.*)>/i
  225. # check to ensure the input is an array given that the attribute
  226. # is documented as an array but the input is not
  227. if attributes[attribute_map[key]].is_a?(Array)
  228. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  229. end
  230. 5 elsif !attributes[attribute_map[key]].nil?
  231. 5 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  232. end
  233. end
  234. 1 new(transformed_hash)
  235. end
  236. # Returns the object in the form of hash
  237. # @return [Hash] Returns the object in the form of hash
  238. 1 def to_hash
  239. 2 hash = {}
  240. 2 self.class.attribute_map.each_pair do |attr, param|
  241. 10 value = self.send(attr)
  242. 10 if value.nil?
  243. is_nullable = self.class.openapi_nullable.include?(attr)
  244. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  245. end
  246. 10 hash[param] = _to_hash(value)
  247. end
  248. 2 hash
  249. end
  250. end
  251. end

lib/bandwidth-sdk/models/multi_channel_channel_list_object_base.rb

71.57% lines covered

102 relevant lines. 73 lines covered and 29 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MultiChannelChannelListObjectBase < ApiModelBase
  13. # The sender ID of the message. This could be an alphanumeric sender ID.
  14. 1 attr_accessor :from
  15. # The ID of the Application your from number or senderId is associated with in the Bandwidth App.
  16. 1 attr_accessor :application_id
  17. 1 attr_accessor :channel
  18. 1 class EnumAttributeValidator
  19. 1 attr_reader :datatype
  20. 1 attr_reader :allowable_values
  21. 1 def initialize(datatype, allowable_values)
  22. @allowable_values = allowable_values.map do |value|
  23. case datatype.to_s
  24. when /Integer/i
  25. value.to_i
  26. when /Float/i
  27. value.to_f
  28. else
  29. value
  30. end
  31. end
  32. end
  33. 1 def valid?(value)
  34. !value || allowable_values.include?(value)
  35. end
  36. end
  37. # Attribute mapping from ruby-style variable name to JSON key.
  38. 1 def self.attribute_map
  39. 26 {
  40. :'from' => :'from',
  41. :'application_id' => :'applicationId',
  42. :'channel' => :'channel'
  43. }
  44. end
  45. # Returns attribute mapping this model knows about
  46. 1 def self.acceptable_attribute_map
  47. 11 attribute_map
  48. end
  49. # Returns all the JSON keys this model knows about
  50. 1 def self.acceptable_attributes
  51. 1 acceptable_attribute_map.values
  52. end
  53. # Attribute type mapping.
  54. 1 def self.openapi_types
  55. 1 {
  56. :'from' => :'String',
  57. :'application_id' => :'String',
  58. :'channel' => :'MultiChannelMessageChannelEnum'
  59. }
  60. end
  61. # List of attributes with nullable: true
  62. 1 def self.openapi_nullable
  63. 1 Set.new([
  64. ])
  65. end
  66. # Initializes the object
  67. # @param [Hash] attributes Model attributes in the form of hash
  68. 1 def initialize(attributes = {})
  69. 11 if (!attributes.is_a?(Hash))
  70. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelChannelListObjectBase` initialize method'
  71. end
  72. # check to see if the attribute exists and convert string to symbol for hash key
  73. 10 acceptable_attribute_map = self.class.acceptable_attribute_map
  74. 10 attributes = attributes.each_with_object({}) { |(k, v), h|
  75. 25 if (!acceptable_attribute_map.key?(k.to_sym))
  76. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelChannelListObjectBase`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  77. end
  78. 24 h[k.to_sym] = v
  79. }
  80. 9 if attributes.key?(:'from')
  81. 9 self.from = attributes[:'from']
  82. else
  83. self.from = nil
  84. end
  85. 8 if attributes.key?(:'application_id')
  86. 8 self.application_id = attributes[:'application_id']
  87. else
  88. self.application_id = nil
  89. end
  90. 7 if attributes.key?(:'channel')
  91. 7 self.channel = attributes[:'channel']
  92. else
  93. self.channel = nil
  94. end
  95. end
  96. # Show invalid properties with the reasons. Usually used together with valid?
  97. # @return Array for valid properties with the reasons
  98. 1 def list_invalid_properties
  99. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  100. invalid_properties = Array.new
  101. if @from.nil?
  102. invalid_properties.push('invalid value for "from", from cannot be nil.')
  103. end
  104. if @application_id.nil?
  105. invalid_properties.push('invalid value for "application_id", application_id cannot be nil.')
  106. end
  107. if @channel.nil?
  108. invalid_properties.push('invalid value for "channel", channel cannot be nil.')
  109. end
  110. invalid_properties
  111. end
  112. # Check to see if the all the properties in the model are valid
  113. # @return true if the model is valid
  114. 1 def valid?
  115. warn '[DEPRECATED] the `valid?` method is obsolete'
  116. return false if @from.nil?
  117. return false if @application_id.nil?
  118. return false if @channel.nil?
  119. true
  120. end
  121. # Custom attribute writer method with validation
  122. # @param [Object] from Value to be assigned
  123. 1 def from=(from)
  124. 9 if from.nil?
  125. 1 fail ArgumentError, 'from cannot be nil'
  126. end
  127. 8 @from = from
  128. end
  129. # Custom attribute writer method with validation
  130. # @param [Object] application_id Value to be assigned
  131. 1 def application_id=(application_id)
  132. 8 if application_id.nil?
  133. 1 fail ArgumentError, 'application_id cannot be nil'
  134. end
  135. 7 @application_id = application_id
  136. end
  137. # Custom attribute writer method with validation
  138. # @param [Object] channel Value to be assigned
  139. 1 def channel=(channel)
  140. 7 if channel.nil?
  141. 1 fail ArgumentError, 'channel cannot be nil'
  142. end
  143. 6 @channel = channel
  144. end
  145. # Checks equality by comparing each attribute.
  146. # @param [Object] Object to be compared
  147. 1 def ==(o)
  148. 2 return true if self.equal?(o)
  149. 2 self.class == o.class &&
  150. from == o.from &&
  151. application_id == o.application_id &&
  152. channel == o.channel
  153. end
  154. # @see the `==` method
  155. # @param [Object] Object to be compared
  156. 1 def eql?(o)
  157. 2 self == o
  158. end
  159. # Calculates hash code according to all attributes.
  160. # @return [Integer] Hash code
  161. 1 def hash
  162. [from, application_id, channel].hash
  163. end
  164. # Builds the object from hash
  165. # @param [Hash] attributes Model attributes in the form of hash
  166. # @return [Object] Returns the model itself
  167. 1 def self.build_from_hash(attributes)
  168. 1 return nil unless attributes.is_a?(Hash)
  169. 1 attributes = attributes.transform_keys(&:to_sym)
  170. 1 transformed_hash = {}
  171. 1 openapi_types.each_pair do |key, type|
  172. 3 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  173. transformed_hash["#{key}"] = nil
  174. 3 elsif type =~ /\AArray<(.*)>/i
  175. # check to ensure the input is an array given that the attribute
  176. # is documented as an array but the input is not
  177. if attributes[attribute_map[key]].is_a?(Array)
  178. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  179. end
  180. 3 elsif !attributes[attribute_map[key]].nil?
  181. 3 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  182. end
  183. end
  184. 1 new(transformed_hash)
  185. end
  186. # Returns the object in the form of hash
  187. # @return [Hash] Returns the object in the form of hash
  188. 1 def to_hash
  189. 2 hash = {}
  190. 2 self.class.attribute_map.each_pair do |attr, param|
  191. 6 value = self.send(attr)
  192. 6 if value.nil?
  193. is_nullable = self.class.openapi_nullable.include?(attr)
  194. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  195. end
  196. 6 hash[param] = _to_hash(value)
  197. end
  198. 2 hash
  199. end
  200. end
  201. end

lib/bandwidth-sdk/models/multi_channel_channel_list_owner_object.rb

78.26% lines covered

69 relevant lines. 54 lines covered and 15 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MultiChannelChannelListOwnerObject < ApiModelBase
  13. # The Bandwidth senderId associated with the message. Identical to 'from'.
  14. 1 attr_accessor :owner
  15. # Attribute mapping from ruby-style variable name to JSON key.
  16. 1 def self.attribute_map
  17. 16 {
  18. :'owner' => :'owner'
  19. }
  20. end
  21. # Returns attribute mapping this model knows about
  22. 1 def self.acceptable_attribute_map
  23. 9 attribute_map
  24. end
  25. # Returns all the JSON keys this model knows about
  26. 1 def self.acceptable_attributes
  27. 1 acceptable_attribute_map.values
  28. end
  29. # Attribute type mapping.
  30. 1 def self.openapi_types
  31. 1 {
  32. :'owner' => :'String'
  33. }
  34. end
  35. # List of attributes with nullable: true
  36. 1 def self.openapi_nullable
  37. 1 Set.new([
  38. ])
  39. end
  40. # Initializes the object
  41. # @param [Hash] attributes Model attributes in the form of hash
  42. 1 def initialize(attributes = {})
  43. 9 if (!attributes.is_a?(Hash))
  44. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelChannelListOwnerObject` initialize method'
  45. end
  46. # check to see if the attribute exists and convert string to symbol for hash key
  47. 8 acceptable_attribute_map = self.class.acceptable_attribute_map
  48. 8 attributes = attributes.each_with_object({}) { |(k, v), h|
  49. 8 if (!acceptable_attribute_map.key?(k.to_sym))
  50. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelChannelListOwnerObject`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  51. end
  52. 7 h[k.to_sym] = v
  53. }
  54. 7 if attributes.key?(:'owner')
  55. 7 self.owner = attributes[:'owner']
  56. else
  57. self.owner = nil
  58. end
  59. end
  60. # Show invalid properties with the reasons. Usually used together with valid?
  61. # @return Array for valid properties with the reasons
  62. 1 def list_invalid_properties
  63. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  64. invalid_properties = Array.new
  65. if @owner.nil?
  66. invalid_properties.push('invalid value for "owner", owner cannot be nil.')
  67. end
  68. invalid_properties
  69. end
  70. # Check to see if the all the properties in the model are valid
  71. # @return true if the model is valid
  72. 1 def valid?
  73. warn '[DEPRECATED] the `valid?` method is obsolete'
  74. return false if @owner.nil?
  75. true
  76. end
  77. # Custom attribute writer method with validation
  78. # @param [Object] owner Value to be assigned
  79. 1 def owner=(owner)
  80. 7 if owner.nil?
  81. 1 fail ArgumentError, 'owner cannot be nil'
  82. end
  83. 6 @owner = owner
  84. end
  85. # Checks equality by comparing each attribute.
  86. # @param [Object] Object to be compared
  87. 1 def ==(o)
  88. 2 return true if self.equal?(o)
  89. 2 self.class == o.class &&
  90. owner == o.owner
  91. end
  92. # @see the `==` method
  93. # @param [Object] Object to be compared
  94. 1 def eql?(o)
  95. 2 self == o
  96. end
  97. # Calculates hash code according to all attributes.
  98. # @return [Integer] Hash code
  99. 1 def hash
  100. [owner].hash
  101. end
  102. # Builds the object from hash
  103. # @param [Hash] attributes Model attributes in the form of hash
  104. # @return [Object] Returns the model itself
  105. 1 def self.build_from_hash(attributes)
  106. 1 return nil unless attributes.is_a?(Hash)
  107. 1 attributes = attributes.transform_keys(&:to_sym)
  108. 1 transformed_hash = {}
  109. 1 openapi_types.each_pair do |key, type|
  110. 1 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  111. transformed_hash["#{key}"] = nil
  112. 1 elsif type =~ /\AArray<(.*)>/i
  113. # check to ensure the input is an array given that the attribute
  114. # is documented as an array but the input is not
  115. if attributes[attribute_map[key]].is_a?(Array)
  116. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  117. end
  118. 1 elsif !attributes[attribute_map[key]].nil?
  119. 1 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  120. end
  121. end
  122. 1 new(transformed_hash)
  123. end
  124. # Returns the object in the form of hash
  125. # @return [Hash] Returns the object in the form of hash
  126. 1 def to_hash
  127. 2 hash = {}
  128. 2 self.class.attribute_map.each_pair do |attr, param|
  129. 2 value = self.send(attr)
  130. 2 if value.nil?
  131. is_nullable = self.class.openapi_nullable.include?(attr)
  132. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  133. end
  134. 2 hash[param] = _to_hash(value)
  135. end
  136. 2 hash
  137. end
  138. end
  139. end

lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_object.rb

70.43% lines covered

115 relevant lines. 81 lines covered and 34 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MultiChannelChannelListRBMObject < ApiModelBase
  13. # The sender ID of the message. This could be an alphanumeric sender ID.
  14. 1 attr_accessor :from
  15. # The ID of the Application your from number or senderId is associated with in the Bandwidth App.
  16. 1 attr_accessor :application_id
  17. 1 attr_accessor :channel
  18. 1 attr_accessor :content
  19. 1 class EnumAttributeValidator
  20. 1 attr_reader :datatype
  21. 1 attr_reader :allowable_values
  22. 1 def initialize(datatype, allowable_values)
  23. @allowable_values = allowable_values.map do |value|
  24. case datatype.to_s
  25. when /Integer/i
  26. value.to_i
  27. when /Float/i
  28. value.to_f
  29. else
  30. value
  31. end
  32. end
  33. end
  34. 1 def valid?(value)
  35. !value || allowable_values.include?(value)
  36. end
  37. end
  38. # Attribute mapping from ruby-style variable name to JSON key.
  39. 1 def self.attribute_map
  40. 31 {
  41. :'from' => :'from',
  42. :'application_id' => :'applicationId',
  43. :'channel' => :'channel',
  44. :'content' => :'content'
  45. }
  46. end
  47. # Returns attribute mapping this model knows about
  48. 1 def self.acceptable_attribute_map
  49. 12 attribute_map
  50. end
  51. # Returns all the JSON keys this model knows about
  52. 1 def self.acceptable_attributes
  53. 1 acceptable_attribute_map.values
  54. end
  55. # Attribute type mapping.
  56. 1 def self.openapi_types
  57. 1 {
  58. :'from' => :'String',
  59. :'application_id' => :'String',
  60. :'channel' => :'MultiChannelMessageChannelEnum',
  61. :'content' => :'MultiChannelChannelListRBMObjectAllOfContent'
  62. }
  63. end
  64. # List of attributes with nullable: true
  65. 1 def self.openapi_nullable
  66. 1 Set.new([
  67. ])
  68. end
  69. # List of class defined in allOf (OpenAPI v3)
  70. 1 def self.openapi_all_of
  71. [
  72. :'MultiChannelChannelListObjectBase'
  73. ]
  74. end
  75. # Initializes the object
  76. # @param [Hash] attributes Model attributes in the form of hash
  77. 1 def initialize(attributes = {})
  78. 12 if (!attributes.is_a?(Hash))
  79. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelChannelListRBMObject` initialize method'
  80. end
  81. # check to see if the attribute exists and convert string to symbol for hash key
  82. 11 acceptable_attribute_map = self.class.acceptable_attribute_map
  83. 11 attributes = attributes.each_with_object({}) { |(k, v), h|
  84. 35 if (!acceptable_attribute_map.key?(k.to_sym))
  85. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelChannelListRBMObject`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  86. end
  87. 34 h[k.to_sym] = v
  88. }
  89. 10 if attributes.key?(:'from')
  90. 10 self.from = attributes[:'from']
  91. else
  92. self.from = nil
  93. end
  94. 9 if attributes.key?(:'application_id')
  95. 9 self.application_id = attributes[:'application_id']
  96. else
  97. self.application_id = nil
  98. end
  99. 8 if attributes.key?(:'channel')
  100. 8 self.channel = attributes[:'channel']
  101. else
  102. self.channel = nil
  103. end
  104. 7 if attributes.key?(:'content')
  105. 7 self.content = attributes[:'content']
  106. else
  107. self.content = nil
  108. end
  109. end
  110. # Show invalid properties with the reasons. Usually used together with valid?
  111. # @return Array for valid properties with the reasons
  112. 1 def list_invalid_properties
  113. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  114. invalid_properties = Array.new
  115. if @from.nil?
  116. invalid_properties.push('invalid value for "from", from cannot be nil.')
  117. end
  118. if @application_id.nil?
  119. invalid_properties.push('invalid value for "application_id", application_id cannot be nil.')
  120. end
  121. if @channel.nil?
  122. invalid_properties.push('invalid value for "channel", channel cannot be nil.')
  123. end
  124. if @content.nil?
  125. invalid_properties.push('invalid value for "content", content cannot be nil.')
  126. end
  127. invalid_properties
  128. end
  129. # Check to see if the all the properties in the model are valid
  130. # @return true if the model is valid
  131. 1 def valid?
  132. warn '[DEPRECATED] the `valid?` method is obsolete'
  133. return false if @from.nil?
  134. return false if @application_id.nil?
  135. return false if @channel.nil?
  136. return false if @content.nil?
  137. true
  138. end
  139. # Custom attribute writer method with validation
  140. # @param [Object] from Value to be assigned
  141. 1 def from=(from)
  142. 10 if from.nil?
  143. 1 fail ArgumentError, 'from cannot be nil'
  144. end
  145. 9 @from = from
  146. end
  147. # Custom attribute writer method with validation
  148. # @param [Object] application_id Value to be assigned
  149. 1 def application_id=(application_id)
  150. 9 if application_id.nil?
  151. 1 fail ArgumentError, 'application_id cannot be nil'
  152. end
  153. 8 @application_id = application_id
  154. end
  155. # Custom attribute writer method with validation
  156. # @param [Object] channel Value to be assigned
  157. 1 def channel=(channel)
  158. 8 if channel.nil?
  159. 1 fail ArgumentError, 'channel cannot be nil'
  160. end
  161. 7 @channel = channel
  162. end
  163. # Custom attribute writer method with validation
  164. # @param [Object] content Value to be assigned
  165. 1 def content=(content)
  166. 7 if content.nil?
  167. 1 fail ArgumentError, 'content cannot be nil'
  168. end
  169. 6 @content = content
  170. end
  171. # Checks equality by comparing each attribute.
  172. # @param [Object] Object to be compared
  173. 1 def ==(o)
  174. 2 return true if self.equal?(o)
  175. 2 self.class == o.class &&
  176. from == o.from &&
  177. application_id == o.application_id &&
  178. channel == o.channel &&
  179. content == o.content
  180. end
  181. # @see the `==` method
  182. # @param [Object] Object to be compared
  183. 1 def eql?(o)
  184. 2 self == o
  185. end
  186. # Calculates hash code according to all attributes.
  187. # @return [Integer] Hash code
  188. 1 def hash
  189. [from, application_id, channel, content].hash
  190. end
  191. # Builds the object from hash
  192. # @param [Hash] attributes Model attributes in the form of hash
  193. # @return [Object] Returns the model itself
  194. 1 def self.build_from_hash(attributes)
  195. 1 return nil unless attributes.is_a?(Hash)
  196. 1 attributes = attributes.transform_keys(&:to_sym)
  197. 1 transformed_hash = {}
  198. 1 openapi_types.each_pair do |key, type|
  199. 4 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  200. transformed_hash["#{key}"] = nil
  201. 4 elsif type =~ /\AArray<(.*)>/i
  202. # check to ensure the input is an array given that the attribute
  203. # is documented as an array but the input is not
  204. if attributes[attribute_map[key]].is_a?(Array)
  205. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  206. end
  207. 4 elsif !attributes[attribute_map[key]].nil?
  208. 4 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  209. end
  210. end
  211. 1 new(transformed_hash)
  212. end
  213. # Returns the object in the form of hash
  214. # @return [Hash] Returns the object in the form of hash
  215. 1 def to_hash
  216. 2 hash = {}
  217. 2 self.class.attribute_map.each_pair do |attr, param|
  218. 8 value = self.send(attr)
  219. 8 if value.nil?
  220. is_nullable = self.class.openapi_nullable.include?(attr)
  221. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  222. end
  223. 8 hash[param] = _to_hash(value)
  224. end
  225. 2 hash
  226. end
  227. end
  228. end

lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_object_all_of_content.rb

67.5% lines covered

40 relevant lines. 27 lines covered and 13 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The content of the message.
  13. 1 module MultiChannelChannelListRBMObjectAllOfContent
  14. 1 class << self
  15. # List of class defined in oneOf (OpenAPI v3)
  16. 1 def openapi_one_of
  17. 8 [
  18. :'RbmMessageContentRichCard',
  19. :'RbmMessageContentText',
  20. :'RbmMessageMedia'
  21. ]
  22. end
  23. # Builds the object
  24. # @param [Mixed] Data to be matched against the list of oneOf items
  25. # @return [Object] Returns the model or the data itself
  26. 1 def build(data)
  27. # Go through the list of oneOf items and attempt to identify the appropriate one.
  28. # Note:
  29. # - We do not attempt to check whether exactly one item matches.
  30. # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
  31. # due to the way the deserialization is made in the base_object template (it just casts without verifying).
  32. # - TODO: scalar values are de facto behaving as if they were nullable.
  33. # - TODO: logging when debugging is set.
  34. 6 openapi_one_of.each do |klass|
  35. begin
  36. 14 next if klass == :AnyType # "nullable: true"
  37. 14 return find_and_cast_into_type(klass, data)
  38. rescue # rescue all errors so we keep iterating even if the current item lookup raises
  39. end
  40. end
  41. 1 openapi_one_of.include?(:AnyType) ? data : nil
  42. end
  43. 1 private
  44. 1 SchemaMismatchError = Class.new(StandardError)
  45. # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
  46. 1 def find_and_cast_into_type(klass, data)
  47. 14 return if data.nil?
  48. 14 case klass.to_s
  49. when 'Boolean'
  50. return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
  51. when 'Float'
  52. return data if data.instance_of?(Float)
  53. when 'Integer'
  54. return data if data.instance_of?(Integer)
  55. when 'Time'
  56. return Time.parse(data)
  57. when 'Date'
  58. return Date.iso8601(data)
  59. when 'String'
  60. return data if data.instance_of?(String)
  61. when 'Object' # "type: object"
  62. return data if data.instance_of?(Hash)
  63. when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
  64. if data.instance_of?(Array)
  65. sub_type = Regexp.last_match[:sub_type]
  66. return data.map { |item| find_and_cast_into_type(sub_type, item) }
  67. end
  68. when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
  69. if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
  70. sub_type = Regexp.last_match[:sub_type]
  71. return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
  72. end
  73. else # model
  74. 14 const = Bandwidth.const_get(klass)
  75. 14 if const
  76. 14 if const.respond_to?(:openapi_one_of) # nested oneOf model
  77. 6 model = const.build(data)
  78. 6 return model if model
  79. else
  80. # raise if data contains keys that are not known to the model
  81. 8 raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
  82. 5 model = const.build_from_hash(data)
  83. 5 return model if model
  84. end
  85. end
  86. end
  87. 6 raise # if no match by now, raise
  88. rescue
  89. 9 raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
  90. end
  91. end
  92. end
  93. end

lib/bandwidth-sdk/models/multi_channel_channel_list_rbm_response_object.rb

69.84% lines covered

126 relevant lines. 88 lines covered and 38 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MultiChannelChannelListRBMResponseObject < ApiModelBase
  13. # The sender ID of the message. This could be an alphanumeric sender ID.
  14. 1 attr_accessor :from
  15. # The ID of the Application your from number or senderId is associated with in the Bandwidth App.
  16. 1 attr_accessor :application_id
  17. 1 attr_accessor :channel
  18. 1 attr_accessor :content
  19. # The Bandwidth senderId associated with the message. Identical to 'from'.
  20. 1 attr_accessor :owner
  21. 1 class EnumAttributeValidator
  22. 1 attr_reader :datatype
  23. 1 attr_reader :allowable_values
  24. 1 def initialize(datatype, allowable_values)
  25. @allowable_values = allowable_values.map do |value|
  26. case datatype.to_s
  27. when /Integer/i
  28. value.to_i
  29. when /Float/i
  30. value.to_f
  31. else
  32. value
  33. end
  34. end
  35. end
  36. 1 def valid?(value)
  37. !value || allowable_values.include?(value)
  38. end
  39. end
  40. # Attribute mapping from ruby-style variable name to JSON key.
  41. 1 def self.attribute_map
  42. 57 {
  43. :'from' => :'from',
  44. :'application_id' => :'applicationId',
  45. :'channel' => :'channel',
  46. :'content' => :'content',
  47. :'owner' => :'owner'
  48. }
  49. end
  50. # Returns attribute mapping this model knows about
  51. 1 def self.acceptable_attribute_map
  52. 14 attribute_map
  53. end
  54. # Returns all the JSON keys this model knows about
  55. 1 def self.acceptable_attributes
  56. 1 acceptable_attribute_map.values
  57. end
  58. # Attribute type mapping.
  59. 1 def self.openapi_types
  60. 2 {
  61. :'from' => :'String',
  62. :'application_id' => :'String',
  63. :'channel' => :'MultiChannelMessageChannelEnum',
  64. :'content' => :'MultiChannelChannelListRBMObjectAllOfContent',
  65. :'owner' => :'String'
  66. }
  67. end
  68. # List of attributes with nullable: true
  69. 1 def self.openapi_nullable
  70. 1 Set.new([
  71. ])
  72. end
  73. # List of class defined in allOf (OpenAPI v3)
  74. 1 def self.openapi_all_of
  75. [
  76. :'MultiChannelChannelListOwnerObject',
  77. :'MultiChannelChannelListRBMObject'
  78. ]
  79. end
  80. # Initializes the object
  81. # @param [Hash] attributes Model attributes in the form of hash
  82. 1 def initialize(attributes = {})
  83. 14 if (!attributes.is_a?(Hash))
  84. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelChannelListRBMResponseObject` initialize method'
  85. end
  86. # check to see if the attribute exists and convert string to symbol for hash key
  87. 13 acceptable_attribute_map = self.class.acceptable_attribute_map
  88. 13 attributes = attributes.each_with_object({}) { |(k, v), h|
  89. 51 if (!acceptable_attribute_map.key?(k.to_sym))
  90. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelChannelListRBMResponseObject`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  91. end
  92. 50 h[k.to_sym] = v
  93. }
  94. 12 if attributes.key?(:'from')
  95. 12 self.from = attributes[:'from']
  96. else
  97. self.from = nil
  98. end
  99. 11 if attributes.key?(:'application_id')
  100. 11 self.application_id = attributes[:'application_id']
  101. else
  102. self.application_id = nil
  103. end
  104. 10 if attributes.key?(:'channel')
  105. 10 self.channel = attributes[:'channel']
  106. else
  107. self.channel = nil
  108. end
  109. 9 if attributes.key?(:'content')
  110. 9 self.content = attributes[:'content']
  111. else
  112. self.content = nil
  113. end
  114. 8 if attributes.key?(:'owner')
  115. 8 self.owner = attributes[:'owner']
  116. else
  117. self.owner = nil
  118. end
  119. end
  120. # Show invalid properties with the reasons. Usually used together with valid?
  121. # @return Array for valid properties with the reasons
  122. 1 def list_invalid_properties
  123. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  124. invalid_properties = Array.new
  125. if @from.nil?
  126. invalid_properties.push('invalid value for "from", from cannot be nil.')
  127. end
  128. if @application_id.nil?
  129. invalid_properties.push('invalid value for "application_id", application_id cannot be nil.')
  130. end
  131. if @channel.nil?
  132. invalid_properties.push('invalid value for "channel", channel cannot be nil.')
  133. end
  134. if @content.nil?
  135. invalid_properties.push('invalid value for "content", content cannot be nil.')
  136. end
  137. if @owner.nil?
  138. invalid_properties.push('invalid value for "owner", owner cannot be nil.')
  139. end
  140. invalid_properties
  141. end
  142. # Check to see if the all the properties in the model are valid
  143. # @return true if the model is valid
  144. 1 def valid?
  145. warn '[DEPRECATED] the `valid?` method is obsolete'
  146. return false if @from.nil?
  147. return false if @application_id.nil?
  148. return false if @channel.nil?
  149. return false if @content.nil?
  150. return false if @owner.nil?
  151. true
  152. end
  153. # Custom attribute writer method with validation
  154. # @param [Object] from Value to be assigned
  155. 1 def from=(from)
  156. 12 if from.nil?
  157. 1 fail ArgumentError, 'from cannot be nil'
  158. end
  159. 11 @from = from
  160. end
  161. # Custom attribute writer method with validation
  162. # @param [Object] application_id Value to be assigned
  163. 1 def application_id=(application_id)
  164. 11 if application_id.nil?
  165. 1 fail ArgumentError, 'application_id cannot be nil'
  166. end
  167. 10 @application_id = application_id
  168. end
  169. # Custom attribute writer method with validation
  170. # @param [Object] channel Value to be assigned
  171. 1 def channel=(channel)
  172. 10 if channel.nil?
  173. 1 fail ArgumentError, 'channel cannot be nil'
  174. end
  175. 9 @channel = channel
  176. end
  177. # Custom attribute writer method with validation
  178. # @param [Object] content Value to be assigned
  179. 1 def content=(content)
  180. 9 if content.nil?
  181. 1 fail ArgumentError, 'content cannot be nil'
  182. end
  183. 8 @content = content
  184. end
  185. # Custom attribute writer method with validation
  186. # @param [Object] owner Value to be assigned
  187. 1 def owner=(owner)
  188. 8 if owner.nil?
  189. 1 fail ArgumentError, 'owner cannot be nil'
  190. end
  191. 7 @owner = owner
  192. end
  193. # Checks equality by comparing each attribute.
  194. # @param [Object] Object to be compared
  195. 1 def ==(o)
  196. 2 return true if self.equal?(o)
  197. 2 self.class == o.class &&
  198. from == o.from &&
  199. application_id == o.application_id &&
  200. channel == o.channel &&
  201. content == o.content &&
  202. owner == o.owner
  203. end
  204. # @see the `==` method
  205. # @param [Object] Object to be compared
  206. 1 def eql?(o)
  207. 2 self == o
  208. end
  209. # Calculates hash code according to all attributes.
  210. # @return [Integer] Hash code
  211. 1 def hash
  212. [from, application_id, channel, content, owner].hash
  213. end
  214. # Builds the object from hash
  215. # @param [Hash] attributes Model attributes in the form of hash
  216. # @return [Object] Returns the model itself
  217. 1 def self.build_from_hash(attributes)
  218. 2 return nil unless attributes.is_a?(Hash)
  219. 2 attributes = attributes.transform_keys(&:to_sym)
  220. 2 transformed_hash = {}
  221. 2 openapi_types.each_pair do |key, type|
  222. 10 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  223. transformed_hash["#{key}"] = nil
  224. 10 elsif type =~ /\AArray<(.*)>/i
  225. # check to ensure the input is an array given that the attribute
  226. # is documented as an array but the input is not
  227. if attributes[attribute_map[key]].is_a?(Array)
  228. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  229. end
  230. 10 elsif !attributes[attribute_map[key]].nil?
  231. 10 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  232. end
  233. end
  234. 2 new(transformed_hash)
  235. end
  236. # Returns the object in the form of hash
  237. # @return [Hash] Returns the object in the form of hash
  238. 1 def to_hash
  239. 2 hash = {}
  240. 2 self.class.attribute_map.each_pair do |attr, param|
  241. 10 value = self.send(attr)
  242. 10 if value.nil?
  243. is_nullable = self.class.openapi_nullable.include?(attr)
  244. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  245. end
  246. 10 hash[param] = _to_hash(value)
  247. end
  248. 2 hash
  249. end
  250. end
  251. end

lib/bandwidth-sdk/models/multi_channel_channel_list_request_object.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 module MultiChannelChannelListRequestObject
  13. 1 class << self
  14. # List of class defined in anyOf (OpenAPI v3)
  15. 1 def openapi_any_of
  16. 2 [
  17. :'MultiChannelChannelListMMSObject',
  18. :'MultiChannelChannelListRBMObject',
  19. :'MultiChannelChannelListSMSObject'
  20. ]
  21. end
  22. # Discriminator's property name (OpenAPI v3)
  23. 1 def openapi_discriminator_name
  24. 7 :'channel'
  25. end
  26. # Discriminator's mapping (OpenAPI v3)
  27. 1 def openapi_discriminator_mapping
  28. 10 {
  29. :'MMS' => :'MultiChannelChannelListMMSObject',
  30. :'RBM' => :'MultiChannelChannelListRBMObject',
  31. :'SMS' => :'MultiChannelChannelListSMSObject'
  32. }
  33. end
  34. # Builds the object
  35. # @param [Mixed] Data to be matched against the list of anyOf items
  36. # @return [Object] Returns the model or the data itself
  37. 1 def build(data)
  38. 6 discriminator_value = data[openapi_discriminator_name]
  39. 6 return nil if discriminator_value.nil?
  40. 5 klass = openapi_discriminator_mapping[discriminator_value.to_s.to_sym]
  41. 5 return nil unless klass
  42. 4 Bandwidth.const_get(klass).build_from_hash(data)
  43. end
  44. end
  45. end
  46. end

lib/bandwidth-sdk/models/multi_channel_channel_list_response_object.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 module MultiChannelChannelListResponseObject
  13. 1 class << self
  14. # List of class defined in anyOf (OpenAPI v3)
  15. 1 def openapi_any_of
  16. 2 [
  17. :'MultiChannelChannelListMMSResponseObject',
  18. :'MultiChannelChannelListRBMResponseObject',
  19. :'MultiChannelChannelListSMSResponseObject'
  20. ]
  21. end
  22. # Discriminator's property name (OpenAPI v3)
  23. 1 def openapi_discriminator_name
  24. 8 :'channel'
  25. end
  26. # Discriminator's mapping (OpenAPI v3)
  27. 1 def openapi_discriminator_mapping
  28. 11 {
  29. :'MMS' => :'MultiChannelChannelListMMSResponseObject',
  30. :'RBM' => :'MultiChannelChannelListRBMResponseObject',
  31. :'SMS' => :'MultiChannelChannelListSMSResponseObject'
  32. }
  33. end
  34. # Builds the object
  35. # @param [Mixed] Data to be matched against the list of anyOf items
  36. # @return [Object] Returns the model or the data itself
  37. 1 def build(data)
  38. 7 discriminator_value = data[openapi_discriminator_name]
  39. 7 return nil if discriminator_value.nil?
  40. 6 klass = openapi_discriminator_mapping[discriminator_value.to_s.to_sym]
  41. 6 return nil unless klass
  42. 5 Bandwidth.const_get(klass).build_from_hash(data)
  43. end
  44. end
  45. end
  46. end

lib/bandwidth-sdk/models/multi_channel_channel_list_sms_object.rb

70.43% lines covered

115 relevant lines. 81 lines covered and 34 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MultiChannelChannelListSMSObject < ApiModelBase
  13. # The sender ID of the message. This could be an alphanumeric sender ID.
  14. 1 attr_accessor :from
  15. # The ID of the Application your from number or senderId is associated with in the Bandwidth App.
  16. 1 attr_accessor :application_id
  17. 1 attr_accessor :channel
  18. 1 attr_accessor :content
  19. 1 class EnumAttributeValidator
  20. 1 attr_reader :datatype
  21. 1 attr_reader :allowable_values
  22. 1 def initialize(datatype, allowable_values)
  23. @allowable_values = allowable_values.map do |value|
  24. case datatype.to_s
  25. when /Integer/i
  26. value.to_i
  27. when /Float/i
  28. value.to_f
  29. else
  30. value
  31. end
  32. end
  33. end
  34. 1 def valid?(value)
  35. !value || allowable_values.include?(value)
  36. end
  37. end
  38. # Attribute mapping from ruby-style variable name to JSON key.
  39. 1 def self.attribute_map
  40. 56 {
  41. :'from' => :'from',
  42. :'application_id' => :'applicationId',
  43. :'channel' => :'channel',
  44. :'content' => :'content'
  45. }
  46. end
  47. # Returns attribute mapping this model knows about
  48. 1 def self.acceptable_attribute_map
  49. 18 attribute_map
  50. end
  51. # Returns all the JSON keys this model knows about
  52. 1 def self.acceptable_attributes
  53. 1 acceptable_attribute_map.values
  54. end
  55. # Attribute type mapping.
  56. 1 def self.openapi_types
  57. 2 {
  58. :'from' => :'String',
  59. :'application_id' => :'String',
  60. :'channel' => :'MultiChannelMessageChannelEnum',
  61. :'content' => :'SmsMessageContent'
  62. }
  63. end
  64. # List of attributes with nullable: true
  65. 1 def self.openapi_nullable
  66. 1 Set.new([
  67. ])
  68. end
  69. # List of class defined in allOf (OpenAPI v3)
  70. 1 def self.openapi_all_of
  71. [
  72. :'MultiChannelChannelListObjectBase'
  73. ]
  74. end
  75. # Initializes the object
  76. # @param [Hash] attributes Model attributes in the form of hash
  77. 1 def initialize(attributes = {})
  78. 18 if (!attributes.is_a?(Hash))
  79. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelChannelListSMSObject` initialize method'
  80. end
  81. # check to see if the attribute exists and convert string to symbol for hash key
  82. 17 acceptable_attribute_map = self.class.acceptable_attribute_map
  83. 17 attributes = attributes.each_with_object({}) { |(k, v), h|
  84. 59 if (!acceptable_attribute_map.key?(k.to_sym))
  85. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelChannelListSMSObject`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  86. end
  87. 58 h[k.to_sym] = v
  88. }
  89. 16 if attributes.key?(:'from')
  90. 16 self.from = attributes[:'from']
  91. else
  92. self.from = nil
  93. end
  94. 15 if attributes.key?(:'application_id')
  95. 15 self.application_id = attributes[:'application_id']
  96. else
  97. self.application_id = nil
  98. end
  99. 14 if attributes.key?(:'channel')
  100. 14 self.channel = attributes[:'channel']
  101. else
  102. self.channel = nil
  103. end
  104. 13 if attributes.key?(:'content')
  105. 13 self.content = attributes[:'content']
  106. else
  107. self.content = nil
  108. end
  109. end
  110. # Show invalid properties with the reasons. Usually used together with valid?
  111. # @return Array for valid properties with the reasons
  112. 1 def list_invalid_properties
  113. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  114. invalid_properties = Array.new
  115. if @from.nil?
  116. invalid_properties.push('invalid value for "from", from cannot be nil.')
  117. end
  118. if @application_id.nil?
  119. invalid_properties.push('invalid value for "application_id", application_id cannot be nil.')
  120. end
  121. if @channel.nil?
  122. invalid_properties.push('invalid value for "channel", channel cannot be nil.')
  123. end
  124. if @content.nil?
  125. invalid_properties.push('invalid value for "content", content cannot be nil.')
  126. end
  127. invalid_properties
  128. end
  129. # Check to see if the all the properties in the model are valid
  130. # @return true if the model is valid
  131. 1 def valid?
  132. warn '[DEPRECATED] the `valid?` method is obsolete'
  133. return false if @from.nil?
  134. return false if @application_id.nil?
  135. return false if @channel.nil?
  136. return false if @content.nil?
  137. true
  138. end
  139. # Custom attribute writer method with validation
  140. # @param [Object] from Value to be assigned
  141. 1 def from=(from)
  142. 16 if from.nil?
  143. 1 fail ArgumentError, 'from cannot be nil'
  144. end
  145. 15 @from = from
  146. end
  147. # Custom attribute writer method with validation
  148. # @param [Object] application_id Value to be assigned
  149. 1 def application_id=(application_id)
  150. 15 if application_id.nil?
  151. 1 fail ArgumentError, 'application_id cannot be nil'
  152. end
  153. 14 @application_id = application_id
  154. end
  155. # Custom attribute writer method with validation
  156. # @param [Object] channel Value to be assigned
  157. 1 def channel=(channel)
  158. 14 if channel.nil?
  159. 1 fail ArgumentError, 'channel cannot be nil'
  160. end
  161. 13 @channel = channel
  162. end
  163. # Custom attribute writer method with validation
  164. # @param [Object] content Value to be assigned
  165. 1 def content=(content)
  166. 13 if content.nil?
  167. 1 fail ArgumentError, 'content cannot be nil'
  168. end
  169. 12 @content = content
  170. end
  171. # Checks equality by comparing each attribute.
  172. # @param [Object] Object to be compared
  173. 1 def ==(o)
  174. 2 return true if self.equal?(o)
  175. 2 self.class == o.class &&
  176. from == o.from &&
  177. application_id == o.application_id &&
  178. channel == o.channel &&
  179. content == o.content
  180. end
  181. # @see the `==` method
  182. # @param [Object] Object to be compared
  183. 1 def eql?(o)
  184. 2 self == o
  185. end
  186. # Calculates hash code according to all attributes.
  187. # @return [Integer] Hash code
  188. 1 def hash
  189. [from, application_id, channel, content].hash
  190. end
  191. # Builds the object from hash
  192. # @param [Hash] attributes Model attributes in the form of hash
  193. # @return [Object] Returns the model itself
  194. 1 def self.build_from_hash(attributes)
  195. 2 return nil unless attributes.is_a?(Hash)
  196. 2 attributes = attributes.transform_keys(&:to_sym)
  197. 2 transformed_hash = {}
  198. 2 openapi_types.each_pair do |key, type|
  199. 8 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  200. transformed_hash["#{key}"] = nil
  201. 8 elsif type =~ /\AArray<(.*)>/i
  202. # check to ensure the input is an array given that the attribute
  203. # is documented as an array but the input is not
  204. if attributes[attribute_map[key]].is_a?(Array)
  205. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  206. end
  207. 8 elsif !attributes[attribute_map[key]].nil?
  208. 8 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  209. end
  210. end
  211. 2 new(transformed_hash)
  212. end
  213. # Returns the object in the form of hash
  214. # @return [Hash] Returns the object in the form of hash
  215. 1 def to_hash
  216. 5 hash = {}
  217. 5 self.class.attribute_map.each_pair do |attr, param|
  218. 20 value = self.send(attr)
  219. 20 if value.nil?
  220. is_nullable = self.class.openapi_nullable.include?(attr)
  221. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  222. end
  223. 20 hash[param] = _to_hash(value)
  224. end
  225. 5 hash
  226. end
  227. end
  228. end

lib/bandwidth-sdk/models/multi_channel_channel_list_sms_response_object.rb

69.84% lines covered

126 relevant lines. 88 lines covered and 38 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MultiChannelChannelListSMSResponseObject < ApiModelBase
  13. # The sender ID of the message. This could be an alphanumeric sender ID.
  14. 1 attr_accessor :from
  15. # The ID of the Application your from number or senderId is associated with in the Bandwidth App.
  16. 1 attr_accessor :application_id
  17. 1 attr_accessor :channel
  18. 1 attr_accessor :content
  19. # The Bandwidth senderId associated with the message. Identical to 'from'.
  20. 1 attr_accessor :owner
  21. 1 class EnumAttributeValidator
  22. 1 attr_reader :datatype
  23. 1 attr_reader :allowable_values
  24. 1 def initialize(datatype, allowable_values)
  25. @allowable_values = allowable_values.map do |value|
  26. case datatype.to_s
  27. when /Integer/i
  28. value.to_i
  29. when /Float/i
  30. value.to_f
  31. else
  32. value
  33. end
  34. end
  35. end
  36. 1 def valid?(value)
  37. !value || allowable_values.include?(value)
  38. end
  39. end
  40. # Attribute mapping from ruby-style variable name to JSON key.
  41. 1 def self.attribute_map
  42. 64 {
  43. :'from' => :'from',
  44. :'application_id' => :'applicationId',
  45. :'channel' => :'channel',
  46. :'content' => :'content',
  47. :'owner' => :'owner'
  48. }
  49. end
  50. # Returns attribute mapping this model knows about
  51. 1 def self.acceptable_attribute_map
  52. 19 attribute_map
  53. end
  54. # Returns all the JSON keys this model knows about
  55. 1 def self.acceptable_attributes
  56. 1 acceptable_attribute_map.values
  57. end
  58. # Attribute type mapping.
  59. 1 def self.openapi_types
  60. 2 {
  61. :'from' => :'String',
  62. :'application_id' => :'String',
  63. :'channel' => :'MultiChannelMessageChannelEnum',
  64. :'content' => :'SmsMessageContent',
  65. :'owner' => :'String'
  66. }
  67. end
  68. # List of attributes with nullable: true
  69. 1 def self.openapi_nullable
  70. 1 Set.new([
  71. ])
  72. end
  73. # List of class defined in allOf (OpenAPI v3)
  74. 1 def self.openapi_all_of
  75. [
  76. :'MultiChannelChannelListOwnerObject',
  77. :'MultiChannelChannelListSMSObject'
  78. ]
  79. end
  80. # Initializes the object
  81. # @param [Hash] attributes Model attributes in the form of hash
  82. 1 def initialize(attributes = {})
  83. 19 if (!attributes.is_a?(Hash))
  84. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelChannelListSMSResponseObject` initialize method'
  85. end
  86. # check to see if the attribute exists and convert string to symbol for hash key
  87. 18 acceptable_attribute_map = self.class.acceptable_attribute_map
  88. 18 attributes = attributes.each_with_object({}) { |(k, v), h|
  89. 76 if (!acceptable_attribute_map.key?(k.to_sym))
  90. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelChannelListSMSResponseObject`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  91. end
  92. 75 h[k.to_sym] = v
  93. }
  94. 17 if attributes.key?(:'from')
  95. 17 self.from = attributes[:'from']
  96. else
  97. self.from = nil
  98. end
  99. 16 if attributes.key?(:'application_id')
  100. 16 self.application_id = attributes[:'application_id']
  101. else
  102. self.application_id = nil
  103. end
  104. 15 if attributes.key?(:'channel')
  105. 15 self.channel = attributes[:'channel']
  106. else
  107. self.channel = nil
  108. end
  109. 14 if attributes.key?(:'content')
  110. 14 self.content = attributes[:'content']
  111. else
  112. self.content = nil
  113. end
  114. 13 if attributes.key?(:'owner')
  115. 13 self.owner = attributes[:'owner']
  116. else
  117. self.owner = nil
  118. end
  119. end
  120. # Show invalid properties with the reasons. Usually used together with valid?
  121. # @return Array for valid properties with the reasons
  122. 1 def list_invalid_properties
  123. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  124. invalid_properties = Array.new
  125. if @from.nil?
  126. invalid_properties.push('invalid value for "from", from cannot be nil.')
  127. end
  128. if @application_id.nil?
  129. invalid_properties.push('invalid value for "application_id", application_id cannot be nil.')
  130. end
  131. if @channel.nil?
  132. invalid_properties.push('invalid value for "channel", channel cannot be nil.')
  133. end
  134. if @content.nil?
  135. invalid_properties.push('invalid value for "content", content cannot be nil.')
  136. end
  137. if @owner.nil?
  138. invalid_properties.push('invalid value for "owner", owner cannot be nil.')
  139. end
  140. invalid_properties
  141. end
  142. # Check to see if the all the properties in the model are valid
  143. # @return true if the model is valid
  144. 1 def valid?
  145. warn '[DEPRECATED] the `valid?` method is obsolete'
  146. return false if @from.nil?
  147. return false if @application_id.nil?
  148. return false if @channel.nil?
  149. return false if @content.nil?
  150. return false if @owner.nil?
  151. true
  152. end
  153. # Custom attribute writer method with validation
  154. # @param [Object] from Value to be assigned
  155. 1 def from=(from)
  156. 17 if from.nil?
  157. 1 fail ArgumentError, 'from cannot be nil'
  158. end
  159. 16 @from = from
  160. end
  161. # Custom attribute writer method with validation
  162. # @param [Object] application_id Value to be assigned
  163. 1 def application_id=(application_id)
  164. 16 if application_id.nil?
  165. 1 fail ArgumentError, 'application_id cannot be nil'
  166. end
  167. 15 @application_id = application_id
  168. end
  169. # Custom attribute writer method with validation
  170. # @param [Object] channel Value to be assigned
  171. 1 def channel=(channel)
  172. 15 if channel.nil?
  173. 1 fail ArgumentError, 'channel cannot be nil'
  174. end
  175. 14 @channel = channel
  176. end
  177. # Custom attribute writer method with validation
  178. # @param [Object] content Value to be assigned
  179. 1 def content=(content)
  180. 14 if content.nil?
  181. 1 fail ArgumentError, 'content cannot be nil'
  182. end
  183. 13 @content = content
  184. end
  185. # Custom attribute writer method with validation
  186. # @param [Object] owner Value to be assigned
  187. 1 def owner=(owner)
  188. 13 if owner.nil?
  189. 1 fail ArgumentError, 'owner cannot be nil'
  190. end
  191. 12 @owner = owner
  192. end
  193. # Checks equality by comparing each attribute.
  194. # @param [Object] Object to be compared
  195. 1 def ==(o)
  196. 2 return true if self.equal?(o)
  197. 2 self.class == o.class &&
  198. from == o.from &&
  199. application_id == o.application_id &&
  200. channel == o.channel &&
  201. content == o.content &&
  202. owner == o.owner
  203. end
  204. # @see the `==` method
  205. # @param [Object] Object to be compared
  206. 1 def eql?(o)
  207. 2 self == o
  208. end
  209. # Calculates hash code according to all attributes.
  210. # @return [Integer] Hash code
  211. 1 def hash
  212. [from, application_id, channel, content, owner].hash
  213. end
  214. # Builds the object from hash
  215. # @param [Hash] attributes Model attributes in the form of hash
  216. # @return [Object] Returns the model itself
  217. 1 def self.build_from_hash(attributes)
  218. 2 return nil unless attributes.is_a?(Hash)
  219. 2 attributes = attributes.transform_keys(&:to_sym)
  220. 2 transformed_hash = {}
  221. 2 openapi_types.each_pair do |key, type|
  222. 10 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  223. transformed_hash["#{key}"] = nil
  224. 10 elsif type =~ /\AArray<(.*)>/i
  225. # check to ensure the input is an array given that the attribute
  226. # is documented as an array but the input is not
  227. if attributes[attribute_map[key]].is_a?(Array)
  228. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  229. end
  230. 10 elsif !attributes[attribute_map[key]].nil?
  231. 10 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  232. end
  233. end
  234. 2 new(transformed_hash)
  235. end
  236. # Returns the object in the form of hash
  237. # @return [Hash] Returns the object in the form of hash
  238. 1 def to_hash
  239. 4 hash = {}
  240. 4 self.class.attribute_map.each_pair do |attr, param|
  241. 20 value = self.send(attr)
  242. 20 if value.nil?
  243. is_nullable = self.class.openapi_nullable.include?(attr)
  244. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  245. end
  246. 20 hash[param] = _to_hash(value)
  247. end
  248. 4 hash
  249. end
  250. end
  251. end

lib/bandwidth-sdk/models/multi_channel_error.rb

86.96% lines covered

69 relevant lines. 60 lines covered and 9 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MultiChannelError < ApiModelBase
  13. 1 attr_accessor :links
  14. 1 attr_accessor :data
  15. 1 attr_accessor :errors
  16. # Attribute mapping from ruby-style variable name to JSON key.
  17. 1 def self.attribute_map
  18. 23 {
  19. :'links' => :'links',
  20. :'data' => :'data',
  21. :'errors' => :'errors'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 8 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 1 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 1 {
  35. :'links' => :'Array<Link>',
  36. :'data' => :'Object',
  37. :'errors' => :'Array<ErrorObject>'
  38. }
  39. end
  40. # List of attributes with nullable: true
  41. 1 def self.openapi_nullable
  42. 1 Set.new([
  43. :'data',
  44. ])
  45. end
  46. # Initializes the object
  47. # @param [Hash] attributes Model attributes in the form of hash
  48. 1 def initialize(attributes = {})
  49. 8 if (!attributes.is_a?(Hash))
  50. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelError` initialize method'
  51. end
  52. # check to see if the attribute exists and convert string to symbol for hash key
  53. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  54. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  55. 13 if (!acceptable_attribute_map.key?(k.to_sym))
  56. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelError`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  57. end
  58. 12 h[k.to_sym] = v
  59. }
  60. 6 if attributes.key?(:'links')
  61. 4 if (value = attributes[:'links']).is_a?(Array)
  62. 4 self.links = value
  63. end
  64. end
  65. 6 if attributes.key?(:'data')
  66. 4 self.data = attributes[:'data']
  67. end
  68. 6 if attributes.key?(:'errors')
  69. 4 if (value = attributes[:'errors']).is_a?(Array)
  70. 4 self.errors = value
  71. end
  72. end
  73. end
  74. # Show invalid properties with the reasons. Usually used together with valid?
  75. # @return Array for valid properties with the reasons
  76. 1 def list_invalid_properties
  77. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  78. invalid_properties = Array.new
  79. invalid_properties
  80. end
  81. # Check to see if the all the properties in the model are valid
  82. # @return true if the model is valid
  83. 1 def valid?
  84. warn '[DEPRECATED] the `valid?` method is obsolete'
  85. true
  86. end
  87. # Checks equality by comparing each attribute.
  88. # @param [Object] Object to be compared
  89. 1 def ==(o)
  90. 2 return true if self.equal?(o)
  91. 2 self.class == o.class &&
  92. links == o.links &&
  93. data == o.data &&
  94. errors == o.errors
  95. end
  96. # @see the `==` method
  97. # @param [Object] Object to be compared
  98. 1 def eql?(o)
  99. 2 self == o
  100. end
  101. # Calculates hash code according to all attributes.
  102. # @return [Integer] Hash code
  103. 1 def hash
  104. [links, data, errors].hash
  105. end
  106. # Builds the object from hash
  107. # @param [Hash] attributes Model attributes in the form of hash
  108. # @return [Object] Returns the model itself
  109. 1 def self.build_from_hash(attributes)
  110. 1 return nil unless attributes.is_a?(Hash)
  111. 1 attributes = attributes.transform_keys(&:to_sym)
  112. 1 transformed_hash = {}
  113. 1 openapi_types.each_pair do |key, type|
  114. 3 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  115. transformed_hash["#{key}"] = nil
  116. 3 elsif type =~ /\AArray<(.*)>/i
  117. # check to ensure the input is an array given that the attribute
  118. # is documented as an array but the input is not
  119. 2 if attributes[attribute_map[key]].is_a?(Array)
  120. 4 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  121. end
  122. 1 elsif !attributes[attribute_map[key]].nil?
  123. 1 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  124. end
  125. end
  126. 1 new(transformed_hash)
  127. end
  128. # Returns the object in the form of hash
  129. # @return [Hash] Returns the object in the form of hash
  130. 1 def to_hash
  131. 2 hash = {}
  132. 2 self.class.attribute_map.each_pair do |attr, param|
  133. 6 value = self.send(attr)
  134. 6 if value.nil?
  135. is_nullable = self.class.openapi_nullable.include?(attr)
  136. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  137. end
  138. 6 hash[param] = _to_hash(value)
  139. end
  140. 2 hash
  141. end
  142. end
  143. end

lib/bandwidth-sdk/models/multi_channel_message_channel_enum.rb

100.0% lines covered

14 relevant lines. 14 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class MultiChannelMessageChannelEnum
  13. 1 RBM = 'RBM'.freeze
  14. 1 SMS = 'SMS'.freeze
  15. 1 MMS = 'MMS'.freeze
  16. 1 def self.all_vars
  17. 17 @all_vars ||= [RBM, SMS, MMS].freeze
  18. end
  19. # Builds the enum from string
  20. # @param [String] The enum value in the form of the string
  21. # @return [String] The enum value
  22. 1 def self.build_from_hash(value)
  23. 16 new.build_from_hash(value)
  24. end
  25. # Builds the enum from string
  26. # @param [String] The enum value in the form of the string
  27. # @return [String] The enum value
  28. 1 def build_from_hash(value)
  29. 16 return value if MultiChannelMessageChannelEnum.all_vars.include?(value)
  30. 1 raise "Invalid ENUM value #{value} for class #MultiChannelMessageChannelEnum"
  31. end
  32. end
  33. end

lib/bandwidth-sdk/models/multi_channel_message_content.rb

82.81% lines covered

64 relevant lines. 53 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The structure of the content field of a multichannel message.
  13. 1 class MultiChannelMessageContent < ApiModelBase
  14. 1 attr_accessor :text
  15. 1 attr_accessor :media
  16. # Attribute mapping from ruby-style variable name to JSON key.
  17. 1 def self.attribute_map
  18. 19 {
  19. :'text' => :'text',
  20. :'media' => :'media'
  21. }
  22. end
  23. # Returns attribute mapping this model knows about
  24. 1 def self.acceptable_attribute_map
  25. 8 attribute_map
  26. end
  27. # Returns all the JSON keys this model knows about
  28. 1 def self.acceptable_attributes
  29. 1 acceptable_attribute_map.values
  30. end
  31. # Attribute type mapping.
  32. 1 def self.openapi_types
  33. 1 {
  34. :'text' => :'String',
  35. :'media' => :'RbmMessageContentFile'
  36. }
  37. end
  38. # List of attributes with nullable: true
  39. 1 def self.openapi_nullable
  40. 1 Set.new([
  41. ])
  42. end
  43. # Initializes the object
  44. # @param [Hash] attributes Model attributes in the form of hash
  45. 1 def initialize(attributes = {})
  46. 8 if (!attributes.is_a?(Hash))
  47. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelMessageContent` initialize method'
  48. end
  49. # check to see if the attribute exists and convert string to symbol for hash key
  50. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  51. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  52. 9 if (!acceptable_attribute_map.key?(k.to_sym))
  53. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelMessageContent`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  54. end
  55. 8 h[k.to_sym] = v
  56. }
  57. 6 if attributes.key?(:'text')
  58. 4 self.text = attributes[:'text']
  59. end
  60. 6 if attributes.key?(:'media')
  61. 4 self.media = attributes[:'media']
  62. end
  63. end
  64. # Show invalid properties with the reasons. Usually used together with valid?
  65. # @return Array for valid properties with the reasons
  66. 1 def list_invalid_properties
  67. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  68. invalid_properties = Array.new
  69. invalid_properties
  70. end
  71. # Check to see if the all the properties in the model are valid
  72. # @return true if the model is valid
  73. 1 def valid?
  74. warn '[DEPRECATED] the `valid?` method is obsolete'
  75. true
  76. end
  77. # Checks equality by comparing each attribute.
  78. # @param [Object] Object to be compared
  79. 1 def ==(o)
  80. 2 return true if self.equal?(o)
  81. 2 self.class == o.class &&
  82. text == o.text &&
  83. media == o.media
  84. end
  85. # @see the `==` method
  86. # @param [Object] Object to be compared
  87. 1 def eql?(o)
  88. 2 self == o
  89. end
  90. # Calculates hash code according to all attributes.
  91. # @return [Integer] Hash code
  92. 1 def hash
  93. [text, media].hash
  94. end
  95. # Builds the object from hash
  96. # @param [Hash] attributes Model attributes in the form of hash
  97. # @return [Object] Returns the model itself
  98. 1 def self.build_from_hash(attributes)
  99. 1 return nil unless attributes.is_a?(Hash)
  100. 1 attributes = attributes.transform_keys(&:to_sym)
  101. 1 transformed_hash = {}
  102. 1 openapi_types.each_pair do |key, type|
  103. 2 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  104. transformed_hash["#{key}"] = nil
  105. 2 elsif type =~ /\AArray<(.*)>/i
  106. # check to ensure the input is an array given that the attribute
  107. # is documented as an array but the input is not
  108. if attributes[attribute_map[key]].is_a?(Array)
  109. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  110. end
  111. 2 elsif !attributes[attribute_map[key]].nil?
  112. 2 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  113. end
  114. end
  115. 1 new(transformed_hash)
  116. end
  117. # Returns the object in the form of hash
  118. # @return [Hash] Returns the object in the form of hash
  119. 1 def to_hash
  120. 2 hash = {}
  121. 2 self.class.attribute_map.each_pair do |attr, param|
  122. 4 value = self.send(attr)
  123. 4 if value.nil?
  124. is_nullable = self.class.openapi_nullable.include?(attr)
  125. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  126. end
  127. 4 hash[param] = _to_hash(value)
  128. end
  129. 2 hash
  130. end
  131. end
  132. end

lib/bandwidth-sdk/models/multi_channel_message_request.rb

77.36% lines covered

106 relevant lines. 82 lines covered and 24 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # Multi-Channel Message Request
  13. 1 class MultiChannelMessageRequest < ApiModelBase
  14. # The phone number the message should be sent to in E164 format.
  15. 1 attr_accessor :to
  16. # A list of message bodies. The messages will be attempted in the order they are listed. Once a message sends successfully, the others will be ignored.
  17. 1 attr_accessor :channel_list
  18. # A custom string that will be included in callback events of the message. Max 1024 characters.
  19. 1 attr_accessor :tag
  20. 1 attr_accessor :priority
  21. # A string with the date/time value that the message will automatically expire by. This must be a valid RFC-3339 value, e.g., 2021-03-14T01:59:26Z or 2021-03-13T20:59:26-05:00. Must be a date-time in the future.
  22. 1 attr_accessor :expiration
  23. 1 class EnumAttributeValidator
  24. 1 attr_reader :datatype
  25. 1 attr_reader :allowable_values
  26. 1 def initialize(datatype, allowable_values)
  27. @allowable_values = allowable_values.map do |value|
  28. case datatype.to_s
  29. when /Integer/i
  30. value.to_i
  31. when /Float/i
  32. value.to_f
  33. else
  34. value
  35. end
  36. end
  37. end
  38. 1 def valid?(value)
  39. !value || allowable_values.include?(value)
  40. end
  41. end
  42. # Attribute mapping from ruby-style variable name to JSON key.
  43. 1 def self.attribute_map
  44. 36 {
  45. :'to' => :'to',
  46. :'channel_list' => :'channelList',
  47. :'tag' => :'tag',
  48. :'priority' => :'priority',
  49. :'expiration' => :'expiration'
  50. }
  51. end
  52. # Returns attribute mapping this model knows about
  53. 1 def self.acceptable_attribute_map
  54. 12 attribute_map
  55. end
  56. # Returns all the JSON keys this model knows about
  57. 1 def self.acceptable_attributes
  58. 1 acceptable_attribute_map.values
  59. end
  60. # Attribute type mapping.
  61. 1 def self.openapi_types
  62. 1 {
  63. :'to' => :'String',
  64. :'channel_list' => :'Array<MultiChannelChannelListRequestObject>',
  65. :'tag' => :'String',
  66. :'priority' => :'PriorityEnum',
  67. :'expiration' => :'Time'
  68. }
  69. end
  70. # List of attributes with nullable: true
  71. 1 def self.openapi_nullable
  72. 1 Set.new([
  73. ])
  74. end
  75. # Initializes the object
  76. # @param [Hash] attributes Model attributes in the form of hash
  77. 1 def initialize(attributes = {})
  78. 12 if (!attributes.is_a?(Hash))
  79. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelMessageRequest` initialize method'
  80. end
  81. # check to see if the attribute exists and convert string to symbol for hash key
  82. 11 acceptable_attribute_map = self.class.acceptable_attribute_map
  83. 11 attributes = attributes.each_with_object({}) { |(k, v), h|
  84. 36 if (!acceptable_attribute_map.key?(k.to_sym))
  85. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelMessageRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  86. end
  87. 35 h[k.to_sym] = v
  88. }
  89. 10 if attributes.key?(:'to')
  90. 9 self.to = attributes[:'to']
  91. else
  92. 1 self.to = nil
  93. end
  94. 9 if attributes.key?(:'channel_list')
  95. 8 if (value = attributes[:'channel_list']).is_a?(Array)
  96. 8 self.channel_list = value
  97. end
  98. else
  99. 1 self.channel_list = nil
  100. end
  101. 8 if attributes.key?(:'tag')
  102. 6 self.tag = attributes[:'tag']
  103. end
  104. 8 if attributes.key?(:'priority')
  105. 6 self.priority = attributes[:'priority']
  106. end
  107. 8 if attributes.key?(:'expiration')
  108. 6 self.expiration = attributes[:'expiration']
  109. end
  110. end
  111. # Show invalid properties with the reasons. Usually used together with valid?
  112. # @return Array for valid properties with the reasons
  113. 1 def list_invalid_properties
  114. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  115. invalid_properties = Array.new
  116. if @to.nil?
  117. invalid_properties.push('invalid value for "to", to cannot be nil.')
  118. end
  119. if @channel_list.nil?
  120. invalid_properties.push('invalid value for "channel_list", channel_list cannot be nil.')
  121. end
  122. if @channel_list.length > 4
  123. invalid_properties.push('invalid value for "channel_list", number of items must be less than or equal to 4.')
  124. end
  125. invalid_properties
  126. end
  127. # Check to see if the all the properties in the model are valid
  128. # @return true if the model is valid
  129. 1 def valid?
  130. warn '[DEPRECATED] the `valid?` method is obsolete'
  131. return false if @to.nil?
  132. return false if @channel_list.nil?
  133. return false if @channel_list.length > 4
  134. true
  135. end
  136. # Custom attribute writer method with validation
  137. # @param [Object] to Value to be assigned
  138. 1 def to=(to)
  139. 10 if to.nil?
  140. 1 fail ArgumentError, 'to cannot be nil'
  141. end
  142. 9 @to = to
  143. end
  144. # Custom attribute writer method with validation
  145. # @param [Object] channel_list Value to be assigned
  146. 1 def channel_list=(channel_list)
  147. 11 if channel_list.nil?
  148. 2 fail ArgumentError, 'channel_list cannot be nil'
  149. end
  150. 9 if channel_list.length > 4
  151. 1 fail ArgumentError, 'invalid value for "channel_list", number of items must be less than or equal to 4.'
  152. end
  153. 8 @channel_list = channel_list
  154. end
  155. # Checks equality by comparing each attribute.
  156. # @param [Object] Object to be compared
  157. 1 def ==(o)
  158. 2 return true if self.equal?(o)
  159. 2 self.class == o.class &&
  160. to == o.to &&
  161. channel_list == o.channel_list &&
  162. tag == o.tag &&
  163. priority == o.priority &&
  164. expiration == o.expiration
  165. end
  166. # @see the `==` method
  167. # @param [Object] Object to be compared
  168. 1 def eql?(o)
  169. 2 self == o
  170. end
  171. # Calculates hash code according to all attributes.
  172. # @return [Integer] Hash code
  173. 1 def hash
  174. [to, channel_list, tag, priority, expiration].hash
  175. end
  176. # Builds the object from hash
  177. # @param [Hash] attributes Model attributes in the form of hash
  178. # @return [Object] Returns the model itself
  179. 1 def self.build_from_hash(attributes)
  180. 1 return nil unless attributes.is_a?(Hash)
  181. 1 attributes = attributes.transform_keys(&:to_sym)
  182. 1 transformed_hash = {}
  183. 1 openapi_types.each_pair do |key, type|
  184. 5 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  185. transformed_hash["#{key}"] = nil
  186. 5 elsif type =~ /\AArray<(.*)>/i
  187. # check to ensure the input is an array given that the attribute
  188. # is documented as an array but the input is not
  189. 1 if attributes[attribute_map[key]].is_a?(Array)
  190. 2 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  191. end
  192. 4 elsif !attributes[attribute_map[key]].nil?
  193. 4 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  194. end
  195. end
  196. 1 new(transformed_hash)
  197. end
  198. # Returns the object in the form of hash
  199. # @return [Hash] Returns the object in the form of hash
  200. 1 def to_hash
  201. 3 hash = {}
  202. 3 self.class.attribute_map.each_pair do |attr, param|
  203. 15 value = self.send(attr)
  204. 15 if value.nil?
  205. is_nullable = self.class.openapi_nullable.include?(attr)
  206. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  207. end
  208. 15 hash[param] = _to_hash(value)
  209. end
  210. 3 hash
  211. end
  212. end
  213. end

lib/bandwidth-sdk/models/multi_channel_message_response_data.rb

74.29% lines covered

140 relevant lines. 104 lines covered and 36 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The data returned in a multichannel message response.
  13. 1 class MultiChannelMessageResponseData < ApiModelBase
  14. # The ID of the message.
  15. 1 attr_accessor :id
  16. # The time the message was received by the Bandwidth API.
  17. 1 attr_accessor :time
  18. 1 attr_accessor :direction
  19. # The destination phone number(s) of the message, in E164 format.
  20. 1 attr_accessor :to
  21. # A list of message bodies. The messages will be attempted in the order they are listed. Once a message sends successfully, the others will be ignored.
  22. 1 attr_accessor :channel_list
  23. # A custom string that will be included in callback events of the message. Max 1024 characters.
  24. 1 attr_accessor :tag
  25. 1 attr_accessor :priority
  26. # A string with the date/time value that the message will automatically expire by. This must be a valid RFC-3339 value, e.g., 2021-03-14T01:59:26Z or 2021-03-13T20:59:26-05:00. Must be a date-time in the future.
  27. 1 attr_accessor :expiration
  28. 1 class EnumAttributeValidator
  29. 1 attr_reader :datatype
  30. 1 attr_reader :allowable_values
  31. 1 def initialize(datatype, allowable_values)
  32. @allowable_values = allowable_values.map do |value|
  33. case datatype.to_s
  34. when /Integer/i
  35. value.to_i
  36. when /Float/i
  37. value.to_f
  38. else
  39. value
  40. end
  41. end
  42. end
  43. 1 def valid?(value)
  44. !value || allowable_values.include?(value)
  45. end
  46. end
  47. # Attribute mapping from ruby-style variable name to JSON key.
  48. 1 def self.attribute_map
  49. 83 {
  50. :'id' => :'id',
  51. :'time' => :'time',
  52. :'direction' => :'direction',
  53. :'to' => :'to',
  54. :'channel_list' => :'channelList',
  55. :'tag' => :'tag',
  56. :'priority' => :'priority',
  57. :'expiration' => :'expiration'
  58. }
  59. end
  60. # Returns attribute mapping this model knows about
  61. 1 def self.acceptable_attribute_map
  62. 16 attribute_map
  63. end
  64. # Returns all the JSON keys this model knows about
  65. 1 def self.acceptable_attributes
  66. 1 acceptable_attribute_map.values
  67. end
  68. # Attribute type mapping.
  69. 1 def self.openapi_types
  70. 2 {
  71. :'id' => :'String',
  72. :'time' => :'Time',
  73. :'direction' => :'MessageDirectionEnum',
  74. :'to' => :'Array<String>',
  75. :'channel_list' => :'Array<MultiChannelChannelListResponseObject>',
  76. :'tag' => :'String',
  77. :'priority' => :'PriorityEnum',
  78. :'expiration' => :'Time'
  79. }
  80. end
  81. # List of attributes with nullable: true
  82. 1 def self.openapi_nullable
  83. 1 Set.new([
  84. ])
  85. end
  86. # Initializes the object
  87. # @param [Hash] attributes Model attributes in the form of hash
  88. 1 def initialize(attributes = {})
  89. 16 if (!attributes.is_a?(Hash))
  90. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MultiChannelMessageResponseData` initialize method'
  91. end
  92. # check to see if the attribute exists and convert string to symbol for hash key
  93. 15 acceptable_attribute_map = self.class.acceptable_attribute_map
  94. 15 attributes = attributes.each_with_object({}) { |(k, v), h|
  95. 80 if (!acceptable_attribute_map.key?(k.to_sym))
  96. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MultiChannelMessageResponseData`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  97. end
  98. 79 h[k.to_sym] = v
  99. }
  100. 14 if attributes.key?(:'id')
  101. 14 self.id = attributes[:'id']
  102. else
  103. self.id = nil
  104. end
  105. 13 if attributes.key?(:'time')
  106. 13 self.time = attributes[:'time']
  107. else
  108. self.time = nil
  109. end
  110. 12 if attributes.key?(:'direction')
  111. 12 self.direction = attributes[:'direction']
  112. else
  113. self.direction = nil
  114. end
  115. 11 if attributes.key?(:'to')
  116. 10 if (value = attributes[:'to']).is_a?(Array)
  117. 10 self.to = value
  118. end
  119. else
  120. 1 self.to = nil
  121. end
  122. 10 if attributes.key?(:'channel_list')
  123. 9 if (value = attributes[:'channel_list']).is_a?(Array)
  124. 9 self.channel_list = value
  125. end
  126. else
  127. 1 self.channel_list = nil
  128. end
  129. 9 if attributes.key?(:'tag')
  130. 7 self.tag = attributes[:'tag']
  131. end
  132. 9 if attributes.key?(:'priority')
  133. 7 self.priority = attributes[:'priority']
  134. end
  135. 9 if attributes.key?(:'expiration')
  136. 7 self.expiration = attributes[:'expiration']
  137. end
  138. end
  139. # Show invalid properties with the reasons. Usually used together with valid?
  140. # @return Array for valid properties with the reasons
  141. 1 def list_invalid_properties
  142. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  143. invalid_properties = Array.new
  144. if @id.nil?
  145. invalid_properties.push('invalid value for "id", id cannot be nil.')
  146. end
  147. if @time.nil?
  148. invalid_properties.push('invalid value for "time", time cannot be nil.')
  149. end
  150. if @direction.nil?
  151. invalid_properties.push('invalid value for "direction", direction cannot be nil.')
  152. end
  153. if @to.nil?
  154. invalid_properties.push('invalid value for "to", to cannot be nil.')
  155. end
  156. if @channel_list.nil?
  157. invalid_properties.push('invalid value for "channel_list", channel_list cannot be nil.')
  158. end
  159. if @channel_list.length > 4
  160. invalid_properties.push('invalid value for "channel_list", number of items must be less than or equal to 4.')
  161. end
  162. invalid_properties
  163. end
  164. # Check to see if the all the properties in the model are valid
  165. # @return true if the model is valid
  166. 1 def valid?
  167. warn '[DEPRECATED] the `valid?` method is obsolete'
  168. return false if @id.nil?
  169. return false if @time.nil?
  170. return false if @direction.nil?
  171. return false if @to.nil?
  172. return false if @channel_list.nil?
  173. return false if @channel_list.length > 4
  174. true
  175. end
  176. # Custom attribute writer method with validation
  177. # @param [Object] id Value to be assigned
  178. 1 def id=(id)
  179. 14 if id.nil?
  180. 1 fail ArgumentError, 'id cannot be nil'
  181. end
  182. 13 @id = id
  183. end
  184. # Custom attribute writer method with validation
  185. # @param [Object] time Value to be assigned
  186. 1 def time=(time)
  187. 13 if time.nil?
  188. 1 fail ArgumentError, 'time cannot be nil'
  189. end
  190. 12 @time = time
  191. end
  192. # Custom attribute writer method with validation
  193. # @param [Object] direction Value to be assigned
  194. 1 def direction=(direction)
  195. 12 if direction.nil?
  196. 1 fail ArgumentError, 'direction cannot be nil'
  197. end
  198. 11 @direction = direction
  199. end
  200. # Custom attribute writer method with validation
  201. # @param [Object] to Value to be assigned
  202. 1 def to=(to)
  203. 12 if to.nil?
  204. 2 fail ArgumentError, 'to cannot be nil'
  205. end
  206. 10 @to = to
  207. end
  208. # Custom attribute writer method with validation
  209. # @param [Object] channel_list Value to be assigned
  210. 1 def channel_list=(channel_list)
  211. 12 if channel_list.nil?
  212. 2 fail ArgumentError, 'channel_list cannot be nil'
  213. end
  214. 10 if channel_list.length > 4
  215. 1 fail ArgumentError, 'invalid value for "channel_list", number of items must be less than or equal to 4.'
  216. end
  217. 9 @channel_list = channel_list
  218. end
  219. # Checks equality by comparing each attribute.
  220. # @param [Object] Object to be compared
  221. 1 def ==(o)
  222. 2 return true if self.equal?(o)
  223. 2 self.class == o.class &&
  224. id == o.id &&
  225. time == o.time &&
  226. direction == o.direction &&
  227. to == o.to &&
  228. channel_list == o.channel_list &&
  229. tag == o.tag &&
  230. priority == o.priority &&
  231. expiration == o.expiration
  232. end
  233. # @see the `==` method
  234. # @param [Object] Object to be compared
  235. 1 def eql?(o)
  236. 2 self == o
  237. end
  238. # Calculates hash code according to all attributes.
  239. # @return [Integer] Hash code
  240. 1 def hash
  241. [id, time, direction, to, channel_list, tag, priority, expiration].hash
  242. end
  243. # Builds the object from hash
  244. # @param [Hash] attributes Model attributes in the form of hash
  245. # @return [Object] Returns the model itself
  246. 1 def self.build_from_hash(attributes)
  247. 2 return nil unless attributes.is_a?(Hash)
  248. 2 attributes = attributes.transform_keys(&:to_sym)
  249. 2 transformed_hash = {}
  250. 2 openapi_types.each_pair do |key, type|
  251. 16 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  252. transformed_hash["#{key}"] = nil
  253. 16 elsif type =~ /\AArray<(.*)>/i
  254. # check to ensure the input is an array given that the attribute
  255. # is documented as an array but the input is not
  256. 4 if attributes[attribute_map[key]].is_a?(Array)
  257. 8 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  258. end
  259. 12 elsif !attributes[attribute_map[key]].nil?
  260. 12 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  261. end
  262. end
  263. 2 new(transformed_hash)
  264. end
  265. # Returns the object in the form of hash
  266. # @return [Hash] Returns the object in the form of hash
  267. 1 def to_hash
  268. 2 hash = {}
  269. 2 self.class.attribute_map.each_pair do |attr, param|
  270. 16 value = self.send(attr)
  271. 16 if value.nil?
  272. is_nullable = self.class.openapi_nullable.include?(attr)
  273. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  274. end
  275. 16 hash[param] = _to_hash(value)
  276. end
  277. 2 hash
  278. end
  279. end
  280. end

lib/bandwidth-sdk/models/opt_in_workflow.rb

74.53% lines covered

106 relevant lines. 79 lines covered and 27 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class OptInWorkflow < ApiModelBase
  13. 1 attr_accessor :description
  14. 1 attr_accessor :image_urls
  15. 1 attr_accessor :confirmation_response
  16. # Attribute mapping from ruby-style variable name to JSON key.
  17. 1 def self.attribute_map
  18. 90 {
  19. :'description' => :'description',
  20. :'image_urls' => :'imageUrls',
  21. :'confirmation_response' => :'confirmationResponse'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 21 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 1 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 6 {
  35. :'description' => :'String',
  36. :'image_urls' => :'Array<String>',
  37. :'confirmation_response' => :'String'
  38. }
  39. end
  40. # List of attributes with nullable: true
  41. 1 def self.openapi_nullable
  42. 3 Set.new([
  43. :'confirmation_response'
  44. ])
  45. end
  46. # Initializes the object
  47. # @param [Hash] attributes Model attributes in the form of hash
  48. 1 def initialize(attributes = {})
  49. 21 if (!attributes.is_a?(Hash))
  50. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::OptInWorkflow` initialize method'
  51. end
  52. # check to see if the attribute exists and convert string to symbol for hash key
  53. 20 acceptable_attribute_map = self.class.acceptable_attribute_map
  54. 20 attributes = attributes.each_with_object({}) { |(k, v), h|
  55. 42 if (!acceptable_attribute_map.key?(k.to_sym))
  56. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::OptInWorkflow`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  57. end
  58. 41 h[k.to_sym] = v
  59. }
  60. 19 if attributes.key?(:'description')
  61. 19 self.description = attributes[:'description']
  62. else
  63. self.description = nil
  64. end
  65. 16 if attributes.key?(:'image_urls')
  66. 15 if (value = attributes[:'image_urls']).is_a?(Array)
  67. 15 self.image_urls = value
  68. end
  69. else
  70. 1 self.image_urls = nil
  71. end
  72. 15 if attributes.key?(:'confirmation_response')
  73. 7 self.confirmation_response = attributes[:'confirmation_response']
  74. end
  75. end
  76. # Show invalid properties with the reasons. Usually used together with valid?
  77. # @return Array for valid properties with the reasons
  78. 1 def list_invalid_properties
  79. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  80. invalid_properties = Array.new
  81. if @description.nil?
  82. invalid_properties.push('invalid value for "description", description cannot be nil.')
  83. end
  84. if @description.to_s.length > 500
  85. invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 500.')
  86. end
  87. if @description.to_s.length < 1
  88. invalid_properties.push('invalid value for "description", the character length must be greater than or equal to 1.')
  89. end
  90. if @image_urls.nil?
  91. invalid_properties.push('invalid value for "image_urls", image_urls cannot be nil.')
  92. end
  93. if !@confirmation_response.nil? && @confirmation_response.to_s.length > 500
  94. invalid_properties.push('invalid value for "confirmation_response", the character length must be smaller than or equal to 500.')
  95. end
  96. if !@confirmation_response.nil? && @confirmation_response.to_s.length < 0
  97. invalid_properties.push('invalid value for "confirmation_response", the character length must be greater than or equal to 0.')
  98. end
  99. invalid_properties
  100. end
  101. # Check to see if the all the properties in the model are valid
  102. # @return true if the model is valid
  103. 1 def valid?
  104. warn '[DEPRECATED] the `valid?` method is obsolete'
  105. return false if @description.nil?
  106. return false if @description.to_s.length > 500
  107. return false if @description.to_s.length < 1
  108. return false if @image_urls.nil?
  109. return false if !@confirmation_response.nil? && @confirmation_response.to_s.length > 500
  110. return false if !@confirmation_response.nil? && @confirmation_response.to_s.length < 0
  111. true
  112. end
  113. # Custom attribute writer method with validation
  114. # @param [Object] description Value to be assigned
  115. 1 def description=(description)
  116. 19 if description.nil?
  117. 1 fail ArgumentError, 'description cannot be nil'
  118. end
  119. 18 if description.to_s.length > 500
  120. 1 fail ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 500.'
  121. end
  122. 17 if description.to_s.length < 1
  123. 1 fail ArgumentError, 'invalid value for "description", the character length must be greater than or equal to 1.'
  124. end
  125. 16 @description = description
  126. end
  127. # Custom attribute writer method with validation
  128. # @param [Object] image_urls Value to be assigned
  129. 1 def image_urls=(image_urls)
  130. 17 if image_urls.nil?
  131. 2 fail ArgumentError, 'image_urls cannot be nil'
  132. end
  133. 15 @image_urls = image_urls
  134. end
  135. # Custom attribute writer method with validation
  136. # @param [Object] confirmation_response Value to be assigned
  137. 1 def confirmation_response=(confirmation_response)
  138. 8 if !confirmation_response.nil? && confirmation_response.to_s.length > 500
  139. 1 fail ArgumentError, 'invalid value for "confirmation_response", the character length must be smaller than or equal to 500.'
  140. end
  141. 7 if !confirmation_response.nil? && confirmation_response.to_s.length < 0
  142. fail ArgumentError, 'invalid value for "confirmation_response", the character length must be greater than or equal to 0.'
  143. end
  144. 7 @confirmation_response = confirmation_response
  145. end
  146. # Checks equality by comparing each attribute.
  147. # @param [Object] Object to be compared
  148. 1 def ==(o)
  149. 2 return true if self.equal?(o)
  150. 2 self.class == o.class &&
  151. description == o.description &&
  152. image_urls == o.image_urls &&
  153. confirmation_response == o.confirmation_response
  154. end
  155. # @see the `==` method
  156. # @param [Object] Object to be compared
  157. 1 def eql?(o)
  158. 2 self == o
  159. end
  160. # Calculates hash code according to all attributes.
  161. # @return [Integer] Hash code
  162. 1 def hash
  163. [description, image_urls, confirmation_response].hash
  164. end
  165. # Builds the object from hash
  166. # @param [Hash] attributes Model attributes in the form of hash
  167. # @return [Object] Returns the model itself
  168. 1 def self.build_from_hash(attributes)
  169. 6 return nil unless attributes.is_a?(Hash)
  170. 6 attributes = attributes.transform_keys(&:to_sym)
  171. 6 transformed_hash = {}
  172. 6 openapi_types.each_pair do |key, type|
  173. 18 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  174. transformed_hash["#{key}"] = nil
  175. 18 elsif type =~ /\AArray<(.*)>/i
  176. # check to ensure the input is an array given that the attribute
  177. # is documented as an array but the input is not
  178. 6 if attributes[attribute_map[key]].is_a?(Array)
  179. 13 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  180. end
  181. 12 elsif !attributes[attribute_map[key]].nil?
  182. 8 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  183. end
  184. end
  185. 6 new(transformed_hash)
  186. end
  187. # Returns the object in the form of hash
  188. # @return [Hash] Returns the object in the form of hash
  189. 1 def to_hash
  190. 4 hash = {}
  191. 4 self.class.attribute_map.each_pair do |attr, param|
  192. 12 value = self.send(attr)
  193. 12 if value.nil?
  194. 2 is_nullable = self.class.openapi_nullable.include?(attr)
  195. 2 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  196. end
  197. 10 hash[param] = _to_hash(value)
  198. end
  199. 4 hash
  200. end
  201. end
  202. end

lib/bandwidth-sdk/models/page.rb

75.45% lines covered

110 relevant lines. 83 lines covered and 27 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class Page < ApiModelBase
  13. # The number of items per page.
  14. 1 attr_accessor :page_size
  15. # The total number of items.
  16. 1 attr_accessor :total_elements
  17. # The total number of pages.
  18. 1 attr_accessor :total_pages
  19. # The current page number.
  20. 1 attr_accessor :page_number
  21. # Attribute mapping from ruby-style variable name to JSON key.
  22. 1 def self.attribute_map
  23. 74 {
  24. :'page_size' => :'pageSize',
  25. :'total_elements' => :'totalElements',
  26. :'total_pages' => :'totalPages',
  27. :'page_number' => :'pageNumber'
  28. }
  29. end
  30. # Returns attribute mapping this model knows about
  31. 1 def self.acceptable_attribute_map
  32. 21 attribute_map
  33. end
  34. # Returns all the JSON keys this model knows about
  35. 1 def self.acceptable_attributes
  36. 1 acceptable_attribute_map.values
  37. end
  38. # Attribute type mapping.
  39. 1 def self.openapi_types
  40. 3 {
  41. :'page_size' => :'Integer',
  42. :'total_elements' => :'Integer',
  43. :'total_pages' => :'Integer',
  44. :'page_number' => :'Integer'
  45. }
  46. end
  47. # List of attributes with nullable: true
  48. 1 def self.openapi_nullable
  49. 1 Set.new([
  50. ])
  51. end
  52. # Initializes the object
  53. # @param [Hash] attributes Model attributes in the form of hash
  54. 1 def initialize(attributes = {})
  55. 21 if (!attributes.is_a?(Hash))
  56. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::Page` initialize method'
  57. end
  58. # check to see if the attribute exists and convert string to symbol for hash key
  59. 20 acceptable_attribute_map = self.class.acceptable_attribute_map
  60. 20 attributes = attributes.each_with_object({}) { |(k, v), h|
  61. 65 if (!acceptable_attribute_map.key?(k.to_sym))
  62. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::Page`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  63. end
  64. 64 h[k.to_sym] = v
  65. }
  66. 19 if attributes.key?(:'page_size')
  67. 19 self.page_size = attributes[:'page_size']
  68. else
  69. self.page_size = nil
  70. end
  71. 17 if attributes.key?(:'total_elements')
  72. 15 self.total_elements = attributes[:'total_elements']
  73. end
  74. 17 if attributes.key?(:'total_pages')
  75. 15 self.total_pages = attributes[:'total_pages']
  76. end
  77. 17 if attributes.key?(:'page_number')
  78. 15 self.page_number = attributes[:'page_number']
  79. end
  80. end
  81. # Show invalid properties with the reasons. Usually used together with valid?
  82. # @return Array for valid properties with the reasons
  83. 1 def list_invalid_properties
  84. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  85. invalid_properties = Array.new
  86. if @page_size.nil?
  87. invalid_properties.push('invalid value for "page_size", page_size cannot be nil.')
  88. end
  89. if @page_size < 0
  90. invalid_properties.push('invalid value for "page_size", must be greater than or equal to 0.')
  91. end
  92. if !@total_elements.nil? && @total_elements < 0
  93. invalid_properties.push('invalid value for "total_elements", must be greater than or equal to 0.')
  94. end
  95. if !@total_pages.nil? && @total_pages < 0
  96. invalid_properties.push('invalid value for "total_pages", must be greater than or equal to 0.')
  97. end
  98. if !@page_number.nil? && @page_number < 0
  99. invalid_properties.push('invalid value for "page_number", must be greater than or equal to 0.')
  100. end
  101. invalid_properties
  102. end
  103. # Check to see if the all the properties in the model are valid
  104. # @return true if the model is valid
  105. 1 def valid?
  106. warn '[DEPRECATED] the `valid?` method is obsolete'
  107. return false if @page_size.nil?
  108. return false if @page_size < 0
  109. return false if !@total_elements.nil? && @total_elements < 0
  110. return false if !@total_pages.nil? && @total_pages < 0
  111. return false if !@page_number.nil? && @page_number < 0
  112. true
  113. end
  114. # Custom attribute writer method with validation
  115. # @param [Object] page_size Value to be assigned
  116. 1 def page_size=(page_size)
  117. 19 if page_size.nil?
  118. 1 fail ArgumentError, 'page_size cannot be nil'
  119. end
  120. 18 if page_size < 0
  121. 1 fail ArgumentError, 'invalid value for "page_size", must be greater than or equal to 0.'
  122. end
  123. 17 @page_size = page_size
  124. end
  125. # Custom attribute writer method with validation
  126. # @param [Object] total_elements Value to be assigned
  127. 1 def total_elements=(total_elements)
  128. 17 if total_elements.nil?
  129. 1 fail ArgumentError, 'total_elements cannot be nil'
  130. end
  131. 16 if total_elements < 0
  132. 1 fail ArgumentError, 'invalid value for "total_elements", must be greater than or equal to 0.'
  133. end
  134. 15 @total_elements = total_elements
  135. end
  136. # Custom attribute writer method with validation
  137. # @param [Object] total_pages Value to be assigned
  138. 1 def total_pages=(total_pages)
  139. 17 if total_pages.nil?
  140. 1 fail ArgumentError, 'total_pages cannot be nil'
  141. end
  142. 16 if total_pages < 0
  143. 1 fail ArgumentError, 'invalid value for "total_pages", must be greater than or equal to 0.'
  144. end
  145. 15 @total_pages = total_pages
  146. end
  147. # Custom attribute writer method with validation
  148. # @param [Object] page_number Value to be assigned
  149. 1 def page_number=(page_number)
  150. 17 if page_number.nil?
  151. 1 fail ArgumentError, 'page_number cannot be nil'
  152. end
  153. 16 if page_number < 0
  154. 1 fail ArgumentError, 'invalid value for "page_number", must be greater than or equal to 0.'
  155. end
  156. 15 @page_number = page_number
  157. end
  158. # Checks equality by comparing each attribute.
  159. # @param [Object] Object to be compared
  160. 1 def ==(o)
  161. 2 return true if self.equal?(o)
  162. 2 self.class == o.class &&
  163. page_size == o.page_size &&
  164. total_elements == o.total_elements &&
  165. total_pages == o.total_pages &&
  166. page_number == o.page_number
  167. end
  168. # @see the `==` method
  169. # @param [Object] Object to be compared
  170. 1 def eql?(o)
  171. 2 self == o
  172. end
  173. # Calculates hash code according to all attributes.
  174. # @return [Integer] Hash code
  175. 1 def hash
  176. [page_size, total_elements, total_pages, page_number].hash
  177. end
  178. # Builds the object from hash
  179. # @param [Hash] attributes Model attributes in the form of hash
  180. # @return [Object] Returns the model itself
  181. 1 def self.build_from_hash(attributes)
  182. 3 return nil unless attributes.is_a?(Hash)
  183. 3 attributes = attributes.transform_keys(&:to_sym)
  184. 3 transformed_hash = {}
  185. 3 openapi_types.each_pair do |key, type|
  186. 12 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  187. transformed_hash["#{key}"] = nil
  188. 12 elsif type =~ /\AArray<(.*)>/i
  189. # check to ensure the input is an array given that the attribute
  190. # is documented as an array but the input is not
  191. if attributes[attribute_map[key]].is_a?(Array)
  192. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  193. end
  194. 12 elsif !attributes[attribute_map[key]].nil?
  195. 12 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  196. end
  197. end
  198. 3 new(transformed_hash)
  199. end
  200. # Returns the object in the form of hash
  201. # @return [Hash] Returns the object in the form of hash
  202. 1 def to_hash
  203. 4 hash = {}
  204. 4 self.class.attribute_map.each_pair do |attr, param|
  205. 16 value = self.send(attr)
  206. 16 if value.nil?
  207. is_nullable = self.class.openapi_nullable.include?(attr)
  208. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  209. end
  210. 16 hash[param] = _to_hash(value)
  211. end
  212. 4 hash
  213. end
  214. end
  215. end

lib/bandwidth-sdk/models/page_info.rb

84.29% lines covered

70 relevant lines. 59 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class PageInfo < ApiModelBase
  13. # The link to the previous page for pagination.
  14. 1 attr_accessor :prev_page
  15. # The link to the next page for pagination.
  16. 1 attr_accessor :next_page
  17. # The isolated pagination token for the previous page.
  18. 1 attr_accessor :prev_page_token
  19. # The isolated pagination token for the next page.
  20. 1 attr_accessor :next_page_token
  21. # Attribute mapping from ruby-style variable name to JSON key.
  22. 1 def self.attribute_map
  23. 66 {
  24. :'prev_page' => :'prevPage',
  25. :'next_page' => :'nextPage',
  26. :'prev_page_token' => :'prevPageToken',
  27. :'next_page_token' => :'nextPageToken'
  28. }
  29. end
  30. # Returns attribute mapping this model knows about
  31. 1 def self.acceptable_attribute_map
  32. 13 attribute_map
  33. end
  34. # Returns all the JSON keys this model knows about
  35. 1 def self.acceptable_attributes
  36. 1 acceptable_attribute_map.values
  37. end
  38. # Attribute type mapping.
  39. 1 def self.openapi_types
  40. 3 {
  41. :'prev_page' => :'String',
  42. :'next_page' => :'String',
  43. :'prev_page_token' => :'String',
  44. :'next_page_token' => :'String'
  45. }
  46. end
  47. # List of attributes with nullable: true
  48. 1 def self.openapi_nullable
  49. 1 Set.new([
  50. ])
  51. end
  52. # Initializes the object
  53. # @param [Hash] attributes Model attributes in the form of hash
  54. 1 def initialize(attributes = {})
  55. 13 if (!attributes.is_a?(Hash))
  56. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::PageInfo` initialize method'
  57. end
  58. # check to see if the attribute exists and convert string to symbol for hash key
  59. 12 acceptable_attribute_map = self.class.acceptable_attribute_map
  60. 12 attributes = attributes.each_with_object({}) { |(k, v), h|
  61. 37 if (!acceptable_attribute_map.key?(k.to_sym))
  62. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::PageInfo`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  63. end
  64. 36 h[k.to_sym] = v
  65. }
  66. 11 if attributes.key?(:'prev_page')
  67. 9 self.prev_page = attributes[:'prev_page']
  68. end
  69. 11 if attributes.key?(:'next_page')
  70. 9 self.next_page = attributes[:'next_page']
  71. end
  72. 11 if attributes.key?(:'prev_page_token')
  73. 9 self.prev_page_token = attributes[:'prev_page_token']
  74. end
  75. 11 if attributes.key?(:'next_page_token')
  76. 9 self.next_page_token = attributes[:'next_page_token']
  77. end
  78. end
  79. # Show invalid properties with the reasons. Usually used together with valid?
  80. # @return Array for valid properties with the reasons
  81. 1 def list_invalid_properties
  82. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  83. invalid_properties = Array.new
  84. invalid_properties
  85. end
  86. # Check to see if the all the properties in the model are valid
  87. # @return true if the model is valid
  88. 1 def valid?
  89. warn '[DEPRECATED] the `valid?` method is obsolete'
  90. true
  91. end
  92. # Checks equality by comparing each attribute.
  93. # @param [Object] Object to be compared
  94. 1 def ==(o)
  95. 2 return true if self.equal?(o)
  96. 2 self.class == o.class &&
  97. prev_page == o.prev_page &&
  98. next_page == o.next_page &&
  99. prev_page_token == o.prev_page_token &&
  100. next_page_token == o.next_page_token
  101. end
  102. # @see the `==` method
  103. # @param [Object] Object to be compared
  104. 1 def eql?(o)
  105. 2 self == o
  106. end
  107. # Calculates hash code according to all attributes.
  108. # @return [Integer] Hash code
  109. 1 def hash
  110. [prev_page, next_page, prev_page_token, next_page_token].hash
  111. end
  112. # Builds the object from hash
  113. # @param [Hash] attributes Model attributes in the form of hash
  114. # @return [Object] Returns the model itself
  115. 1 def self.build_from_hash(attributes)
  116. 3 return nil unless attributes.is_a?(Hash)
  117. 3 attributes = attributes.transform_keys(&:to_sym)
  118. 3 transformed_hash = {}
  119. 3 openapi_types.each_pair do |key, type|
  120. 12 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  121. transformed_hash["#{key}"] = nil
  122. 12 elsif type =~ /\AArray<(.*)>/i
  123. # check to ensure the input is an array given that the attribute
  124. # is documented as an array but the input is not
  125. if attributes[attribute_map[key]].is_a?(Array)
  126. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  127. end
  128. 12 elsif !attributes[attribute_map[key]].nil?
  129. 12 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  130. end
  131. end
  132. 3 new(transformed_hash)
  133. end
  134. # Returns the object in the form of hash
  135. # @return [Hash] Returns the object in the form of hash
  136. 1 def to_hash
  137. 4 hash = {}
  138. 4 self.class.attribute_map.each_pair do |attr, param|
  139. 16 value = self.send(attr)
  140. 16 if value.nil?
  141. is_nullable = self.class.openapi_nullable.include?(attr)
  142. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  143. end
  144. 16 hash[param] = _to_hash(value)
  145. end
  146. 4 hash
  147. end
  148. end
  149. end

lib/bandwidth-sdk/models/priority_enum.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class PriorityEnum
  13. 1 DEFAULT = 'default'.freeze
  14. 1 HIGH = 'high'.freeze
  15. 1 def self.all_vars
  16. 14 @all_vars ||= [DEFAULT, HIGH].freeze
  17. end
  18. # Builds the enum from string
  19. # @param [String] The enum value in the form of the string
  20. # @return [String] The enum value
  21. 1 def self.build_from_hash(value)
  22. 11 new.build_from_hash(value)
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def build_from_hash(value)
  28. 11 return value if PriorityEnum.all_vars.include?(value)
  29. 1 raise "Invalid ENUM value #{value} for class #PriorityEnum"
  30. end
  31. end
  32. end

lib/bandwidth-sdk/models/product_type_enum.rb

100.0% lines covered

20 relevant lines. 20 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class ProductTypeEnum
  13. 1 LOCAL_A2_P = 'LOCAL_A2P'.freeze
  14. 1 P2_P = 'P2P'.freeze
  15. 1 SHORT_CODE_REACH = 'SHORT_CODE_REACH'.freeze
  16. 1 TOLL_FREE = 'TOLL_FREE'.freeze
  17. 1 HOSTED_SHORT_CODE = 'HOSTED_SHORT_CODE'.freeze
  18. 1 ALPHA_NUMERIC = 'ALPHA_NUMERIC'.freeze
  19. 1 RBM_MEDIA = 'RBM_MEDIA'.freeze
  20. 1 RBM_RICH = 'RBM_RICH'.freeze
  21. 1 RBM_CONVERSATIONAL = 'RBM_CONVERSATIONAL'.freeze
  22. 1 def self.all_vars
  23. 12 @all_vars ||= [LOCAL_A2_P, P2_P, SHORT_CODE_REACH, TOLL_FREE, HOSTED_SHORT_CODE, ALPHA_NUMERIC, RBM_MEDIA, RBM_RICH, RBM_CONVERSATIONAL].freeze
  24. end
  25. # Builds the enum from string
  26. # @param [String] The enum value in the form of the string
  27. # @return [String] The enum value
  28. 1 def self.build_from_hash(value)
  29. 10 new.build_from_hash(value)
  30. end
  31. # Builds the enum from string
  32. # @param [String] The enum value in the form of the string
  33. # @return [String] The enum value
  34. 1 def build_from_hash(value)
  35. 10 return value if ProductTypeEnum.all_vars.include?(value)
  36. 1 raise "Invalid ENUM value #{value} for class #ProductTypeEnum"
  37. end
  38. end
  39. end

lib/bandwidth-sdk/models/rbm_action_base.rb

68.75% lines covered

112 relevant lines. 77 lines covered and 35 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class RbmActionBase < ApiModelBase
  13. 1 attr_accessor :type
  14. # Displayed text for user to click
  15. 1 attr_accessor :text
  16. # Base64 payload the customer receives when the reply is clicked.
  17. 1 attr_accessor :postback_data
  18. 1 class EnumAttributeValidator
  19. 1 attr_reader :datatype
  20. 1 attr_reader :allowable_values
  21. 1 def initialize(datatype, allowable_values)
  22. @allowable_values = allowable_values.map do |value|
  23. case datatype.to_s
  24. when /Integer/i
  25. value.to_i
  26. when /Float/i
  27. value.to_f
  28. else
  29. value
  30. end
  31. end
  32. end
  33. 1 def valid?(value)
  34. !value || allowable_values.include?(value)
  35. end
  36. end
  37. # Attribute mapping from ruby-style variable name to JSON key.
  38. 1 def self.attribute_map
  39. 138 {
  40. :'type' => :'type',
  41. :'text' => :'text',
  42. :'postback_data' => :'postbackData'
  43. }
  44. end
  45. # Returns attribute mapping this model knows about
  46. 1 def self.acceptable_attribute_map
  47. 41 attribute_map
  48. end
  49. # Returns all the JSON keys this model knows about
  50. 1 def self.acceptable_attributes
  51. 1 acceptable_attribute_map.values
  52. end
  53. # Attribute type mapping.
  54. 1 def self.openapi_types
  55. 7 {
  56. :'type' => :'RbmActionTypeEnum',
  57. :'text' => :'String',
  58. :'postback_data' => :'String'
  59. }
  60. end
  61. # List of attributes with nullable: true
  62. 1 def self.openapi_nullable
  63. 1 Set.new([
  64. ])
  65. end
  66. # Initializes the object
  67. # @param [Hash] attributes Model attributes in the form of hash
  68. 1 def initialize(attributes = {})
  69. 41 if (!attributes.is_a?(Hash))
  70. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RbmActionBase` initialize method'
  71. end
  72. # check to see if the attribute exists and convert string to symbol for hash key
  73. 40 acceptable_attribute_map = self.class.acceptable_attribute_map
  74. 40 attributes = attributes.each_with_object({}) { |(k, v), h|
  75. 114 if (!acceptable_attribute_map.key?(k.to_sym))
  76. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RbmActionBase`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  77. end
  78. 113 h[k.to_sym] = v
  79. }
  80. 39 if attributes.key?(:'type')
  81. 39 self.type = attributes[:'type']
  82. else
  83. self.type = nil
  84. end
  85. 38 if attributes.key?(:'text')
  86. 38 self.text = attributes[:'text']
  87. else
  88. self.text = nil
  89. end
  90. 36 if attributes.key?(:'postback_data')
  91. 36 self.postback_data = attributes[:'postback_data']
  92. else
  93. self.postback_data = nil
  94. end
  95. end
  96. # Show invalid properties with the reasons. Usually used together with valid?
  97. # @return Array for valid properties with the reasons
  98. 1 def list_invalid_properties
  99. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  100. invalid_properties = Array.new
  101. if @type.nil?
  102. invalid_properties.push('invalid value for "type", type cannot be nil.')
  103. end
  104. if @text.nil?
  105. invalid_properties.push('invalid value for "text", text cannot be nil.')
  106. end
  107. if @text.to_s.length > 25
  108. invalid_properties.push('invalid value for "text", the character length must be smaller than or equal to 25.')
  109. end
  110. if @postback_data.nil?
  111. invalid_properties.push('invalid value for "postback_data", postback_data cannot be nil.')
  112. end
  113. if @postback_data.to_s.length > 2048
  114. invalid_properties.push('invalid value for "postback_data", the character length must be smaller than or equal to 2048.')
  115. end
  116. invalid_properties
  117. end
  118. # Check to see if the all the properties in the model are valid
  119. # @return true if the model is valid
  120. 1 def valid?
  121. warn '[DEPRECATED] the `valid?` method is obsolete'
  122. return false if @type.nil?
  123. return false if @text.nil?
  124. return false if @text.to_s.length > 25
  125. return false if @postback_data.nil?
  126. return false if @postback_data.to_s.length > 2048
  127. true
  128. end
  129. # Custom attribute writer method with validation
  130. # @param [Object] type Value to be assigned
  131. 1 def type=(type)
  132. 39 if type.nil?
  133. 1 fail ArgumentError, 'type cannot be nil'
  134. end
  135. 38 @type = type
  136. end
  137. # Custom attribute writer method with validation
  138. # @param [Object] text Value to be assigned
  139. 1 def text=(text)
  140. 38 if text.nil?
  141. 1 fail ArgumentError, 'text cannot be nil'
  142. end
  143. 37 if text.to_s.length > 25
  144. 1 fail ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 25.'
  145. end
  146. 36 @text = text
  147. end
  148. # Custom attribute writer method with validation
  149. # @param [Object] postback_data Value to be assigned
  150. 1 def postback_data=(postback_data)
  151. 36 if postback_data.nil?
  152. 1 fail ArgumentError, 'postback_data cannot be nil'
  153. end
  154. 35 if postback_data.to_s.length > 2048
  155. 1 fail ArgumentError, 'invalid value for "postback_data", the character length must be smaller than or equal to 2048.'
  156. end
  157. 34 @postback_data = postback_data
  158. end
  159. # Checks equality by comparing each attribute.
  160. # @param [Object] Object to be compared
  161. 1 def ==(o)
  162. 2 return true if self.equal?(o)
  163. 2 self.class == o.class &&
  164. type == o.type &&
  165. text == o.text &&
  166. postback_data == o.postback_data
  167. end
  168. # @see the `==` method
  169. # @param [Object] Object to be compared
  170. 1 def eql?(o)
  171. 2 self == o
  172. end
  173. # Calculates hash code according to all attributes.
  174. # @return [Integer] Hash code
  175. 1 def hash
  176. [type, text, postback_data].hash
  177. end
  178. # Builds the object from hash
  179. # @param [Hash] attributes Model attributes in the form of hash
  180. # @return [Object] Returns the model itself
  181. 1 def self.build_from_hash(attributes)
  182. 7 return nil unless attributes.is_a?(Hash)
  183. 7 attributes = attributes.transform_keys(&:to_sym)
  184. 7 transformed_hash = {}
  185. 7 openapi_types.each_pair do |key, type|
  186. 21 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  187. transformed_hash["#{key}"] = nil
  188. 21 elsif type =~ /\AArray<(.*)>/i
  189. # check to ensure the input is an array given that the attribute
  190. # is documented as an array but the input is not
  191. if attributes[attribute_map[key]].is_a?(Array)
  192. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  193. end
  194. 21 elsif !attributes[attribute_map[key]].nil?
  195. 21 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  196. end
  197. end
  198. 7 new(transformed_hash)
  199. end
  200. # Returns the object in the form of hash
  201. # @return [Hash] Returns the object in the form of hash
  202. 1 def to_hash
  203. 12 hash = {}
  204. 12 self.class.attribute_map.each_pair do |attr, param|
  205. 36 value = self.send(attr)
  206. 36 if value.nil?
  207. is_nullable = self.class.openapi_nullable.include?(attr)
  208. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  209. end
  210. 36 hash[param] = _to_hash(value)
  211. end
  212. 12 hash
  213. end
  214. end
  215. end

lib/bandwidth-sdk/models/rbm_action_dial.rb

68.0% lines covered

125 relevant lines. 85 lines covered and 40 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class RbmActionDial < ApiModelBase
  13. 1 attr_accessor :type
  14. # Displayed text for user to click
  15. 1 attr_accessor :text
  16. # Base64 payload the customer receives when the reply is clicked.
  17. 1 attr_accessor :postback_data
  18. # The phone number to dial. Must be E164 format.
  19. 1 attr_accessor :phone_number
  20. 1 class EnumAttributeValidator
  21. 1 attr_reader :datatype
  22. 1 attr_reader :allowable_values
  23. 1 def initialize(datatype, allowable_values)
  24. @allowable_values = allowable_values.map do |value|
  25. case datatype.to_s
  26. when /Integer/i
  27. value.to_i
  28. when /Float/i
  29. value.to_f
  30. else
  31. value
  32. end
  33. end
  34. end
  35. 1 def valid?(value)
  36. !value || allowable_values.include?(value)
  37. end
  38. end
  39. # Attribute mapping from ruby-style variable name to JSON key.
  40. 1 def self.attribute_map
  41. 33 {
  42. :'type' => :'type',
  43. :'text' => :'text',
  44. :'postback_data' => :'postbackData',
  45. :'phone_number' => :'phoneNumber'
  46. }
  47. end
  48. # Returns attribute mapping this model knows about
  49. 1 def self.acceptable_attribute_map
  50. 14 attribute_map
  51. end
  52. # Returns all the JSON keys this model knows about
  53. 1 def self.acceptable_attributes
  54. 1 acceptable_attribute_map.values
  55. end
  56. # Attribute type mapping.
  57. 1 def self.openapi_types
  58. 1 {
  59. :'type' => :'RbmActionTypeEnum',
  60. :'text' => :'String',
  61. :'postback_data' => :'String',
  62. :'phone_number' => :'String'
  63. }
  64. end
  65. # List of attributes with nullable: true
  66. 1 def self.openapi_nullable
  67. 1 Set.new([
  68. ])
  69. end
  70. # List of class defined in allOf (OpenAPI v3)
  71. 1 def self.openapi_all_of
  72. [
  73. :'RbmActionBase'
  74. ]
  75. end
  76. # Initializes the object
  77. # @param [Hash] attributes Model attributes in the form of hash
  78. 1 def initialize(attributes = {})
  79. 14 if (!attributes.is_a?(Hash))
  80. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RbmActionDial` initialize method'
  81. end
  82. # check to see if the attribute exists and convert string to symbol for hash key
  83. 13 acceptable_attribute_map = self.class.acceptable_attribute_map
  84. 13 attributes = attributes.each_with_object({}) { |(k, v), h|
  85. 40 if (!acceptable_attribute_map.key?(k.to_sym))
  86. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RbmActionDial`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  87. end
  88. 39 h[k.to_sym] = v
  89. }
  90. 12 if attributes.key?(:'type')
  91. 12 self.type = attributes[:'type']
  92. else
  93. self.type = nil
  94. end
  95. 11 if attributes.key?(:'text')
  96. 11 self.text = attributes[:'text']
  97. else
  98. self.text = nil
  99. end
  100. 9 if attributes.key?(:'postback_data')
  101. 9 self.postback_data = attributes[:'postback_data']
  102. else
  103. self.postback_data = nil
  104. end
  105. 7 if attributes.key?(:'phone_number')
  106. 7 self.phone_number = attributes[:'phone_number']
  107. else
  108. self.phone_number = nil
  109. end
  110. end
  111. # Show invalid properties with the reasons. Usually used together with valid?
  112. # @return Array for valid properties with the reasons
  113. 1 def list_invalid_properties
  114. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  115. invalid_properties = Array.new
  116. if @type.nil?
  117. invalid_properties.push('invalid value for "type", type cannot be nil.')
  118. end
  119. if @text.nil?
  120. invalid_properties.push('invalid value for "text", text cannot be nil.')
  121. end
  122. if @text.to_s.length > 25
  123. invalid_properties.push('invalid value for "text", the character length must be smaller than or equal to 25.')
  124. end
  125. if @postback_data.nil?
  126. invalid_properties.push('invalid value for "postback_data", postback_data cannot be nil.')
  127. end
  128. if @postback_data.to_s.length > 2048
  129. invalid_properties.push('invalid value for "postback_data", the character length must be smaller than or equal to 2048.')
  130. end
  131. if @phone_number.nil?
  132. invalid_properties.push('invalid value for "phone_number", phone_number cannot be nil.')
  133. end
  134. invalid_properties
  135. end
  136. # Check to see if the all the properties in the model are valid
  137. # @return true if the model is valid
  138. 1 def valid?
  139. warn '[DEPRECATED] the `valid?` method is obsolete'
  140. return false if @type.nil?
  141. return false if @text.nil?
  142. return false if @text.to_s.length > 25
  143. return false if @postback_data.nil?
  144. return false if @postback_data.to_s.length > 2048
  145. return false if @phone_number.nil?
  146. true
  147. end
  148. # Custom attribute writer method with validation
  149. # @param [Object] type Value to be assigned
  150. 1 def type=(type)
  151. 12 if type.nil?
  152. 1 fail ArgumentError, 'type cannot be nil'
  153. end
  154. 11 @type = type
  155. end
  156. # Custom attribute writer method with validation
  157. # @param [Object] text Value to be assigned
  158. 1 def text=(text)
  159. 11 if text.nil?
  160. 1 fail ArgumentError, 'text cannot be nil'
  161. end
  162. 10 if text.to_s.length > 25
  163. 1 fail ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 25.'
  164. end
  165. 9 @text = text
  166. end
  167. # Custom attribute writer method with validation
  168. # @param [Object] postback_data Value to be assigned
  169. 1 def postback_data=(postback_data)
  170. 9 if postback_data.nil?
  171. 1 fail ArgumentError, 'postback_data cannot be nil'
  172. end
  173. 8 if postback_data.to_s.length > 2048
  174. 1 fail ArgumentError, 'invalid value for "postback_data", the character length must be smaller than or equal to 2048.'
  175. end
  176. 7 @postback_data = postback_data
  177. end
  178. # Custom attribute writer method with validation
  179. # @param [Object] phone_number Value to be assigned
  180. 1 def phone_number=(phone_number)
  181. 7 if phone_number.nil?
  182. 1 fail ArgumentError, 'phone_number cannot be nil'
  183. end
  184. 6 @phone_number = phone_number
  185. end
  186. # Checks equality by comparing each attribute.
  187. # @param [Object] Object to be compared
  188. 1 def ==(o)
  189. 2 return true if self.equal?(o)
  190. 2 self.class == o.class &&
  191. type == o.type &&
  192. text == o.text &&
  193. postback_data == o.postback_data &&
  194. phone_number == o.phone_number
  195. end
  196. # @see the `==` method
  197. # @param [Object] Object to be compared
  198. 1 def eql?(o)
  199. 2 self == o
  200. end
  201. # Calculates hash code according to all attributes.
  202. # @return [Integer] Hash code
  203. 1 def hash
  204. [type, text, postback_data, phone_number].hash
  205. end
  206. # Builds the object from hash
  207. # @param [Hash] attributes Model attributes in the form of hash
  208. # @return [Object] Returns the model itself
  209. 1 def self.build_from_hash(attributes)
  210. 1 return nil unless attributes.is_a?(Hash)
  211. 1 attributes = attributes.transform_keys(&:to_sym)
  212. 1 transformed_hash = {}
  213. 1 openapi_types.each_pair do |key, type|
  214. 4 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  215. transformed_hash["#{key}"] = nil
  216. 4 elsif type =~ /\AArray<(.*)>/i
  217. # check to ensure the input is an array given that the attribute
  218. # is documented as an array but the input is not
  219. if attributes[attribute_map[key]].is_a?(Array)
  220. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  221. end
  222. 4 elsif !attributes[attribute_map[key]].nil?
  223. 4 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  224. end
  225. end
  226. 1 new(transformed_hash)
  227. end
  228. # Returns the object in the form of hash
  229. # @return [Hash] Returns the object in the form of hash
  230. 1 def to_hash
  231. 2 hash = {}
  232. 2 self.class.attribute_map.each_pair do |attr, param|
  233. 8 value = self.send(attr)
  234. 8 if value.nil?
  235. is_nullable = self.class.openapi_nullable.include?(attr)
  236. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  237. end
  238. 8 hash[param] = _to_hash(value)
  239. end
  240. 2 hash
  241. end
  242. end
  243. end

lib/bandwidth-sdk/models/rbm_action_open_url.rb

68.38% lines covered

136 relevant lines. 93 lines covered and 43 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class RbmActionOpenUrl < ApiModelBase
  13. 1 attr_accessor :type
  14. # Displayed text for user to click
  15. 1 attr_accessor :text
  16. # Base64 payload the customer receives when the reply is clicked.
  17. 1 attr_accessor :postback_data
  18. # The URL to open in browser. Must use http:// or https:// scheme.
  19. 1 attr_accessor :url
  20. 1 attr_accessor :application
  21. 1 attr_accessor :webview_view_mode
  22. 1 class EnumAttributeValidator
  23. 1 attr_reader :datatype
  24. 1 attr_reader :allowable_values
  25. 1 def initialize(datatype, allowable_values)
  26. @allowable_values = allowable_values.map do |value|
  27. case datatype.to_s
  28. when /Integer/i
  29. value.to_i
  30. when /Float/i
  31. value.to_f
  32. else
  33. value
  34. end
  35. end
  36. end
  37. 1 def valid?(value)
  38. !value || allowable_values.include?(value)
  39. end
  40. end
  41. # Attribute mapping from ruby-style variable name to JSON key.
  42. 1 def self.attribute_map
  43. 42 {
  44. :'type' => :'type',
  45. :'text' => :'text',
  46. :'postback_data' => :'postbackData',
  47. :'url' => :'url',
  48. :'application' => :'application',
  49. :'webview_view_mode' => :'webviewViewMode'
  50. }
  51. end
  52. # Returns attribute mapping this model knows about
  53. 1 def self.acceptable_attribute_map
  54. 15 attribute_map
  55. end
  56. # Returns all the JSON keys this model knows about
  57. 1 def self.acceptable_attributes
  58. 1 acceptable_attribute_map.values
  59. end
  60. # Attribute type mapping.
  61. 1 def self.openapi_types
  62. 1 {
  63. :'type' => :'RbmActionTypeEnum',
  64. :'text' => :'String',
  65. :'postback_data' => :'String',
  66. :'url' => :'String',
  67. :'application' => :'RbmOpenUrlEnum',
  68. :'webview_view_mode' => :'RbmWebViewEnum'
  69. }
  70. end
  71. # List of attributes with nullable: true
  72. 1 def self.openapi_nullable
  73. 1 Set.new([
  74. ])
  75. end
  76. # List of class defined in allOf (OpenAPI v3)
  77. 1 def self.openapi_all_of
  78. [
  79. :'RbmActionBase'
  80. ]
  81. end
  82. # Initializes the object
  83. # @param [Hash] attributes Model attributes in the form of hash
  84. 1 def initialize(attributes = {})
  85. 15 if (!attributes.is_a?(Hash))
  86. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RbmActionOpenUrl` initialize method'
  87. end
  88. # check to see if the attribute exists and convert string to symbol for hash key
  89. 14 acceptable_attribute_map = self.class.acceptable_attribute_map
  90. 14 attributes = attributes.each_with_object({}) { |(k, v), h|
  91. 52 if (!acceptable_attribute_map.key?(k.to_sym))
  92. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RbmActionOpenUrl`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  93. end
  94. 51 h[k.to_sym] = v
  95. }
  96. 13 if attributes.key?(:'type')
  97. 13 self.type = attributes[:'type']
  98. else
  99. self.type = nil
  100. end
  101. 12 if attributes.key?(:'text')
  102. 12 self.text = attributes[:'text']
  103. else
  104. self.text = nil
  105. end
  106. 10 if attributes.key?(:'postback_data')
  107. 10 self.postback_data = attributes[:'postback_data']
  108. else
  109. self.postback_data = nil
  110. end
  111. 8 if attributes.key?(:'url')
  112. 8 self.url = attributes[:'url']
  113. else
  114. self.url = nil
  115. end
  116. 6 if attributes.key?(:'application')
  117. 4 self.application = attributes[:'application']
  118. end
  119. 6 if attributes.key?(:'webview_view_mode')
  120. 4 self.webview_view_mode = attributes[:'webview_view_mode']
  121. end
  122. end
  123. # Show invalid properties with the reasons. Usually used together with valid?
  124. # @return Array for valid properties with the reasons
  125. 1 def list_invalid_properties
  126. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  127. invalid_properties = Array.new
  128. if @type.nil?
  129. invalid_properties.push('invalid value for "type", type cannot be nil.')
  130. end
  131. if @text.nil?
  132. invalid_properties.push('invalid value for "text", text cannot be nil.')
  133. end
  134. if @text.to_s.length > 25
  135. invalid_properties.push('invalid value for "text", the character length must be smaller than or equal to 25.')
  136. end
  137. if @postback_data.nil?
  138. invalid_properties.push('invalid value for "postback_data", postback_data cannot be nil.')
  139. end
  140. if @postback_data.to_s.length > 2048
  141. invalid_properties.push('invalid value for "postback_data", the character length must be smaller than or equal to 2048.')
  142. end
  143. if @url.nil?
  144. invalid_properties.push('invalid value for "url", url cannot be nil.')
  145. end
  146. if @url.to_s.length > 2048
  147. invalid_properties.push('invalid value for "url", the character length must be smaller than or equal to 2048.')
  148. end
  149. invalid_properties
  150. end
  151. # Check to see if the all the properties in the model are valid
  152. # @return true if the model is valid
  153. 1 def valid?
  154. warn '[DEPRECATED] the `valid?` method is obsolete'
  155. return false if @type.nil?
  156. return false if @text.nil?
  157. return false if @text.to_s.length > 25
  158. return false if @postback_data.nil?
  159. return false if @postback_data.to_s.length > 2048
  160. return false if @url.nil?
  161. return false if @url.to_s.length > 2048
  162. true
  163. end
  164. # Custom attribute writer method with validation
  165. # @param [Object] type Value to be assigned
  166. 1 def type=(type)
  167. 13 if type.nil?
  168. 1 fail ArgumentError, 'type cannot be nil'
  169. end
  170. 12 @type = type
  171. end
  172. # Custom attribute writer method with validation
  173. # @param [Object] text Value to be assigned
  174. 1 def text=(text)
  175. 12 if text.nil?
  176. 1 fail ArgumentError, 'text cannot be nil'
  177. end
  178. 11 if text.to_s.length > 25
  179. 1 fail ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 25.'
  180. end
  181. 10 @text = text
  182. end
  183. # Custom attribute writer method with validation
  184. # @param [Object] postback_data Value to be assigned
  185. 1 def postback_data=(postback_data)
  186. 10 if postback_data.nil?
  187. 1 fail ArgumentError, 'postback_data cannot be nil'
  188. end
  189. 9 if postback_data.to_s.length > 2048
  190. 1 fail ArgumentError, 'invalid value for "postback_data", the character length must be smaller than or equal to 2048.'
  191. end
  192. 8 @postback_data = postback_data
  193. end
  194. # Custom attribute writer method with validation
  195. # @param [Object] url Value to be assigned
  196. 1 def url=(url)
  197. 8 if url.nil?
  198. 1 fail ArgumentError, 'url cannot be nil'
  199. end
  200. 7 if url.to_s.length > 2048
  201. 1 fail ArgumentError, 'invalid value for "url", the character length must be smaller than or equal to 2048.'
  202. end
  203. 6 @url = url
  204. end
  205. # Checks equality by comparing each attribute.
  206. # @param [Object] Object to be compared
  207. 1 def ==(o)
  208. 2 return true if self.equal?(o)
  209. 2 self.class == o.class &&
  210. type == o.type &&
  211. text == o.text &&
  212. postback_data == o.postback_data &&
  213. url == o.url &&
  214. application == o.application &&
  215. webview_view_mode == o.webview_view_mode
  216. end
  217. # @see the `==` method
  218. # @param [Object] Object to be compared
  219. 1 def eql?(o)
  220. 2 self == o
  221. end
  222. # Calculates hash code according to all attributes.
  223. # @return [Integer] Hash code
  224. 1 def hash
  225. [type, text, postback_data, url, application, webview_view_mode].hash
  226. end
  227. # Builds the object from hash
  228. # @param [Hash] attributes Model attributes in the form of hash
  229. # @return [Object] Returns the model itself
  230. 1 def self.build_from_hash(attributes)
  231. 1 return nil unless attributes.is_a?(Hash)
  232. 1 attributes = attributes.transform_keys(&:to_sym)
  233. 1 transformed_hash = {}
  234. 1 openapi_types.each_pair do |key, type|
  235. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  236. transformed_hash["#{key}"] = nil
  237. 6 elsif type =~ /\AArray<(.*)>/i
  238. # check to ensure the input is an array given that the attribute
  239. # is documented as an array but the input is not
  240. if attributes[attribute_map[key]].is_a?(Array)
  241. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  242. end
  243. 6 elsif !attributes[attribute_map[key]].nil?
  244. 6 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  245. end
  246. end
  247. 1 new(transformed_hash)
  248. end
  249. # Returns the object in the form of hash
  250. # @return [Hash] Returns the object in the form of hash
  251. 1 def to_hash
  252. 2 hash = {}
  253. 2 self.class.attribute_map.each_pair do |attr, param|
  254. 12 value = self.send(attr)
  255. 12 if value.nil?
  256. is_nullable = self.class.openapi_nullable.include?(attr)
  257. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  258. end
  259. 12 hash[param] = _to_hash(value)
  260. end
  261. 2 hash
  262. end
  263. end
  264. end

lib/bandwidth-sdk/models/rbm_action_type_enum.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class RbmActionTypeEnum
  13. 1 REPLY = 'REPLY'.freeze
  14. 1 DIAL_PHONE = 'DIAL_PHONE'.freeze
  15. 1 SHOW_LOCATION = 'SHOW_LOCATION'.freeze
  16. 1 CREATE_CALENDAR_EVENT = 'CREATE_CALENDAR_EVENT'.freeze
  17. 1 OPEN_URL = 'OPEN_URL'.freeze
  18. 1 REQUEST_LOCATION = 'REQUEST_LOCATION'.freeze
  19. 1 def self.all_vars
  20. 19 @all_vars ||= [REPLY, DIAL_PHONE, SHOW_LOCATION, CREATE_CALENDAR_EVENT, OPEN_URL, REQUEST_LOCATION].freeze
  21. end
  22. # Builds the enum from string
  23. # @param [String] The enum value in the form of the string
  24. # @return [String] The enum value
  25. 1 def self.build_from_hash(value)
  26. 18 new.build_from_hash(value)
  27. end
  28. # Builds the enum from string
  29. # @param [String] The enum value in the form of the string
  30. # @return [String] The enum value
  31. 1 def build_from_hash(value)
  32. 18 return value if RbmActionTypeEnum.all_vars.include?(value)
  33. 1 raise "Invalid ENUM value #{value} for class #RbmActionTypeEnum"
  34. end
  35. end
  36. end

lib/bandwidth-sdk/models/rbm_action_view_location.rb

68.24% lines covered

148 relevant lines. 101 lines covered and 47 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class RbmActionViewLocation < ApiModelBase
  13. 1 attr_accessor :type
  14. # Displayed text for user to click
  15. 1 attr_accessor :text
  16. # Base64 payload the customer receives when the reply is clicked.
  17. 1 attr_accessor :postback_data
  18. # The latitude of the location. Must be in range [-90.000000, 90.000000].
  19. 1 attr_accessor :latitude
  20. # The longitude of the location. Must be in range [-180.000000, 180.000000].
  21. 1 attr_accessor :longitude
  22. # The label of the location.
  23. 1 attr_accessor :label
  24. 1 class EnumAttributeValidator
  25. 1 attr_reader :datatype
  26. 1 attr_reader :allowable_values
  27. 1 def initialize(datatype, allowable_values)
  28. @allowable_values = allowable_values.map do |value|
  29. case datatype.to_s
  30. when /Integer/i
  31. value.to_i
  32. when /Float/i
  33. value.to_f
  34. else
  35. value
  36. end
  37. end
  38. end
  39. 1 def valid?(value)
  40. !value || allowable_values.include?(value)
  41. end
  42. end
  43. # Attribute mapping from ruby-style variable name to JSON key.
  44. 1 def self.attribute_map
  45. 43 {
  46. :'type' => :'type',
  47. :'text' => :'text',
  48. :'postback_data' => :'postbackData',
  49. :'latitude' => :'latitude',
  50. :'longitude' => :'longitude',
  51. :'label' => :'label'
  52. }
  53. end
  54. # Returns attribute mapping this model knows about
  55. 1 def self.acceptable_attribute_map
  56. 16 attribute_map
  57. end
  58. # Returns all the JSON keys this model knows about
  59. 1 def self.acceptable_attributes
  60. 1 acceptable_attribute_map.values
  61. end
  62. # Attribute type mapping.
  63. 1 def self.openapi_types
  64. 1 {
  65. :'type' => :'RbmActionTypeEnum',
  66. :'text' => :'String',
  67. :'postback_data' => :'String',
  68. :'latitude' => :'Float',
  69. :'longitude' => :'Float',
  70. :'label' => :'String'
  71. }
  72. end
  73. # List of attributes with nullable: true
  74. 1 def self.openapi_nullable
  75. 1 Set.new([
  76. ])
  77. end
  78. # List of class defined in allOf (OpenAPI v3)
  79. 1 def self.openapi_all_of
  80. [
  81. :'RbmActionBase'
  82. ]
  83. end
  84. # Initializes the object
  85. # @param [Hash] attributes Model attributes in the form of hash
  86. 1 def initialize(attributes = {})
  87. 16 if (!attributes.is_a?(Hash))
  88. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RbmActionViewLocation` initialize method'
  89. end
  90. # check to see if the attribute exists and convert string to symbol for hash key
  91. 15 acceptable_attribute_map = self.class.acceptable_attribute_map
  92. 15 attributes = attributes.each_with_object({}) { |(k, v), h|
  93. 61 if (!acceptable_attribute_map.key?(k.to_sym))
  94. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RbmActionViewLocation`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  95. end
  96. 60 h[k.to_sym] = v
  97. }
  98. 14 if attributes.key?(:'type')
  99. 14 self.type = attributes[:'type']
  100. else
  101. self.type = nil
  102. end
  103. 13 if attributes.key?(:'text')
  104. 13 self.text = attributes[:'text']
  105. else
  106. self.text = nil
  107. end
  108. 11 if attributes.key?(:'postback_data')
  109. 11 self.postback_data = attributes[:'postback_data']
  110. else
  111. self.postback_data = nil
  112. end
  113. 9 if attributes.key?(:'latitude')
  114. 9 self.latitude = attributes[:'latitude']
  115. else
  116. self.latitude = nil
  117. end
  118. 8 if attributes.key?(:'longitude')
  119. 8 self.longitude = attributes[:'longitude']
  120. else
  121. self.longitude = nil
  122. end
  123. 7 if attributes.key?(:'label')
  124. 5 self.label = attributes[:'label']
  125. end
  126. end
  127. # Show invalid properties with the reasons. Usually used together with valid?
  128. # @return Array for valid properties with the reasons
  129. 1 def list_invalid_properties
  130. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  131. invalid_properties = Array.new
  132. if @type.nil?
  133. invalid_properties.push('invalid value for "type", type cannot be nil.')
  134. end
  135. if @text.nil?
  136. invalid_properties.push('invalid value for "text", text cannot be nil.')
  137. end
  138. if @text.to_s.length > 25
  139. invalid_properties.push('invalid value for "text", the character length must be smaller than or equal to 25.')
  140. end
  141. if @postback_data.nil?
  142. invalid_properties.push('invalid value for "postback_data", postback_data cannot be nil.')
  143. end
  144. if @postback_data.to_s.length > 2048
  145. invalid_properties.push('invalid value for "postback_data", the character length must be smaller than or equal to 2048.')
  146. end
  147. if @latitude.nil?
  148. invalid_properties.push('invalid value for "latitude", latitude cannot be nil.')
  149. end
  150. if @longitude.nil?
  151. invalid_properties.push('invalid value for "longitude", longitude cannot be nil.')
  152. end
  153. if !@label.nil? && @label.to_s.length > 100
  154. invalid_properties.push('invalid value for "label", the character length must be smaller than or equal to 100.')
  155. end
  156. invalid_properties
  157. end
  158. # Check to see if the all the properties in the model are valid
  159. # @return true if the model is valid
  160. 1 def valid?
  161. warn '[DEPRECATED] the `valid?` method is obsolete'
  162. return false if @type.nil?
  163. return false if @text.nil?
  164. return false if @text.to_s.length > 25
  165. return false if @postback_data.nil?
  166. return false if @postback_data.to_s.length > 2048
  167. return false if @latitude.nil?
  168. return false if @longitude.nil?
  169. return false if !@label.nil? && @label.to_s.length > 100
  170. true
  171. end
  172. # Custom attribute writer method with validation
  173. # @param [Object] type Value to be assigned
  174. 1 def type=(type)
  175. 14 if type.nil?
  176. 1 fail ArgumentError, 'type cannot be nil'
  177. end
  178. 13 @type = type
  179. end
  180. # Custom attribute writer method with validation
  181. # @param [Object] text Value to be assigned
  182. 1 def text=(text)
  183. 13 if text.nil?
  184. 1 fail ArgumentError, 'text cannot be nil'
  185. end
  186. 12 if text.to_s.length > 25
  187. 1 fail ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 25.'
  188. end
  189. 11 @text = text
  190. end
  191. # Custom attribute writer method with validation
  192. # @param [Object] postback_data Value to be assigned
  193. 1 def postback_data=(postback_data)
  194. 11 if postback_data.nil?
  195. 1 fail ArgumentError, 'postback_data cannot be nil'
  196. end
  197. 10 if postback_data.to_s.length > 2048
  198. 1 fail ArgumentError, 'invalid value for "postback_data", the character length must be smaller than or equal to 2048.'
  199. end
  200. 9 @postback_data = postback_data
  201. end
  202. # Custom attribute writer method with validation
  203. # @param [Object] latitude Value to be assigned
  204. 1 def latitude=(latitude)
  205. 9 if latitude.nil?
  206. 1 fail ArgumentError, 'latitude cannot be nil'
  207. end
  208. 8 @latitude = latitude
  209. end
  210. # Custom attribute writer method with validation
  211. # @param [Object] longitude Value to be assigned
  212. 1 def longitude=(longitude)
  213. 8 if longitude.nil?
  214. 1 fail ArgumentError, 'longitude cannot be nil'
  215. end
  216. 7 @longitude = longitude
  217. end
  218. # Custom attribute writer method with validation
  219. # @param [Object] label Value to be assigned
  220. 1 def label=(label)
  221. 7 if label.nil?
  222. 1 fail ArgumentError, 'label cannot be nil'
  223. end
  224. 6 if label.to_s.length > 100
  225. 1 fail ArgumentError, 'invalid value for "label", the character length must be smaller than or equal to 100.'
  226. end
  227. 5 @label = label
  228. end
  229. # Checks equality by comparing each attribute.
  230. # @param [Object] Object to be compared
  231. 1 def ==(o)
  232. 2 return true if self.equal?(o)
  233. 2 self.class == o.class &&
  234. type == o.type &&
  235. text == o.text &&
  236. postback_data == o.postback_data &&
  237. latitude == o.latitude &&
  238. longitude == o.longitude &&
  239. label == o.label
  240. end
  241. # @see the `==` method
  242. # @param [Object] Object to be compared
  243. 1 def eql?(o)
  244. 2 self == o
  245. end
  246. # Calculates hash code according to all attributes.
  247. # @return [Integer] Hash code
  248. 1 def hash
  249. [type, text, postback_data, latitude, longitude, label].hash
  250. end
  251. # Builds the object from hash
  252. # @param [Hash] attributes Model attributes in the form of hash
  253. # @return [Object] Returns the model itself
  254. 1 def self.build_from_hash(attributes)
  255. 1 return nil unless attributes.is_a?(Hash)
  256. 1 attributes = attributes.transform_keys(&:to_sym)
  257. 1 transformed_hash = {}
  258. 1 openapi_types.each_pair do |key, type|
  259. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  260. transformed_hash["#{key}"] = nil
  261. 6 elsif type =~ /\AArray<(.*)>/i
  262. # check to ensure the input is an array given that the attribute
  263. # is documented as an array but the input is not
  264. if attributes[attribute_map[key]].is_a?(Array)
  265. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  266. end
  267. 6 elsif !attributes[attribute_map[key]].nil?
  268. 6 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  269. end
  270. end
  271. 1 new(transformed_hash)
  272. end
  273. # Returns the object in the form of hash
  274. # @return [Hash] Returns the object in the form of hash
  275. 1 def to_hash
  276. 2 hash = {}
  277. 2 self.class.attribute_map.each_pair do |attr, param|
  278. 12 value = self.send(attr)
  279. 12 if value.nil?
  280. is_nullable = self.class.openapi_nullable.include?(attr)
  281. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  282. end
  283. 12 hash[param] = _to_hash(value)
  284. end
  285. 2 hash
  286. end
  287. end
  288. end

lib/bandwidth-sdk/models/rbm_card_content.rb

83.67% lines covered

98 relevant lines. 82 lines covered and 16 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # Must contain at least one of title, description, or media to be valid.
  13. 1 class RbmCardContent < ApiModelBase
  14. # The title of the card. Must be 200 characters or less.
  15. 1 attr_accessor :title
  16. # The description of the card. Must be 2000 characters or less.
  17. 1 attr_accessor :description
  18. 1 attr_accessor :media
  19. # An array of suggested actions for the recipient that will be displayed on the rich card.
  20. 1 attr_accessor :suggestions
  21. # Attribute mapping from ruby-style variable name to JSON key.
  22. 1 def self.attribute_map
  23. 98 {
  24. :'title' => :'title',
  25. :'description' => :'description',
  26. :'media' => :'media',
  27. :'suggestions' => :'suggestions'
  28. }
  29. end
  30. # Returns attribute mapping this model knows about
  31. 1 def self.acceptable_attribute_map
  32. 27 attribute_map
  33. end
  34. # Returns all the JSON keys this model knows about
  35. 1 def self.acceptable_attributes
  36. 1 acceptable_attribute_map.values
  37. end
  38. # Attribute type mapping.
  39. 1 def self.openapi_types
  40. 5 {
  41. :'title' => :'String',
  42. :'description' => :'String',
  43. :'media' => :'RbmCardContentMedia',
  44. :'suggestions' => :'Array<MultiChannelAction>'
  45. }
  46. end
  47. # List of attributes with nullable: true
  48. 1 def self.openapi_nullable
  49. 13 Set.new([
  50. ])
  51. end
  52. # Initializes the object
  53. # @param [Hash] attributes Model attributes in the form of hash
  54. 1 def initialize(attributes = {})
  55. 27 if (!attributes.is_a?(Hash))
  56. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RbmCardContent` initialize method'
  57. end
  58. # check to see if the attribute exists and convert string to symbol for hash key
  59. 26 acceptable_attribute_map = self.class.acceptable_attribute_map
  60. 26 attributes = attributes.each_with_object({}) { |(k, v), h|
  61. 52 if (!acceptable_attribute_map.key?(k.to_sym))
  62. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RbmCardContent`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  63. end
  64. 51 h[k.to_sym] = v
  65. }
  66. 25 if attributes.key?(:'title')
  67. 21 self.title = attributes[:'title']
  68. end
  69. 23 if attributes.key?(:'description')
  70. 20 self.description = attributes[:'description']
  71. end
  72. 21 if attributes.key?(:'media')
  73. 5 self.media = attributes[:'media']
  74. end
  75. 21 if attributes.key?(:'suggestions')
  76. 5 if (value = attributes[:'suggestions']).is_a?(Array)
  77. 5 self.suggestions = value
  78. end
  79. end
  80. end
  81. # Show invalid properties with the reasons. Usually used together with valid?
  82. # @return Array for valid properties with the reasons
  83. 1 def list_invalid_properties
  84. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  85. invalid_properties = Array.new
  86. if !@title.nil? && @title.to_s.length > 200
  87. invalid_properties.push('invalid value for "title", the character length must be smaller than or equal to 200.')
  88. end
  89. if !@description.nil? && @description.to_s.length > 2000
  90. invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 2000.')
  91. end
  92. if !@suggestions.nil? && @suggestions.length > 4
  93. invalid_properties.push('invalid value for "suggestions", number of items must be less than or equal to 4.')
  94. end
  95. invalid_properties
  96. end
  97. # Check to see if the all the properties in the model are valid
  98. # @return true if the model is valid
  99. 1 def valid?
  100. warn '[DEPRECATED] the `valid?` method is obsolete'
  101. return false if !@title.nil? && @title.to_s.length > 200
  102. return false if !@description.nil? && @description.to_s.length > 2000
  103. return false if !@suggestions.nil? && @suggestions.length > 4
  104. true
  105. end
  106. # Custom attribute writer method with validation
  107. # @param [Object] title Value to be assigned
  108. 1 def title=(title)
  109. 21 if title.nil?
  110. 1 fail ArgumentError, 'title cannot be nil'
  111. end
  112. 20 if title.to_s.length > 200
  113. 1 fail ArgumentError, 'invalid value for "title", the character length must be smaller than or equal to 200.'
  114. end
  115. 19 @title = title
  116. end
  117. # Custom attribute writer method with validation
  118. # @param [Object] description Value to be assigned
  119. 1 def description=(description)
  120. 20 if description.nil?
  121. 1 fail ArgumentError, 'description cannot be nil'
  122. end
  123. 19 if description.to_s.length > 2000
  124. 1 fail ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 2000.'
  125. end
  126. 18 @description = description
  127. end
  128. # Custom attribute writer method with validation
  129. # @param [Object] suggestions Value to be assigned
  130. 1 def suggestions=(suggestions)
  131. 7 if suggestions.nil?
  132. 1 fail ArgumentError, 'suggestions cannot be nil'
  133. end
  134. 6 if suggestions.length > 4
  135. 1 fail ArgumentError, 'invalid value for "suggestions", number of items must be less than or equal to 4.'
  136. end
  137. 5 @suggestions = suggestions
  138. end
  139. # Checks equality by comparing each attribute.
  140. # @param [Object] Object to be compared
  141. 1 def ==(o)
  142. 3 return true if self.equal?(o)
  143. 2 self.class == o.class &&
  144. title == o.title &&
  145. description == o.description &&
  146. media == o.media &&
  147. suggestions == o.suggestions
  148. end
  149. # @see the `==` method
  150. # @param [Object] Object to be compared
  151. 1 def eql?(o)
  152. 2 self == o
  153. end
  154. # Calculates hash code according to all attributes.
  155. # @return [Integer] Hash code
  156. 1 def hash
  157. [title, description, media, suggestions].hash
  158. end
  159. # Builds the object from hash
  160. # @param [Hash] attributes Model attributes in the form of hash
  161. # @return [Object] Returns the model itself
  162. 1 def self.build_from_hash(attributes)
  163. 7 return nil unless attributes.is_a?(Hash)
  164. 5 attributes = attributes.transform_keys(&:to_sym)
  165. 5 transformed_hash = {}
  166. 5 openapi_types.each_pair do |key, type|
  167. 20 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  168. transformed_hash["#{key}"] = nil
  169. 20 elsif type =~ /\AArray<(.*)>/i
  170. # check to ensure the input is an array given that the attribute
  171. # is documented as an array but the input is not
  172. 5 if attributes[attribute_map[key]].is_a?(Array)
  173. 2 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  174. end
  175. 15 elsif !attributes[attribute_map[key]].nil?
  176. 10 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  177. end
  178. end
  179. 5 new(transformed_hash)
  180. end
  181. # Returns the object in the form of hash
  182. # @return [Hash] Returns the object in the form of hash
  183. 1 def to_hash
  184. 8 hash = {}
  185. 8 self.class.attribute_map.each_pair do |attr, param|
  186. 32 value = self.send(attr)
  187. 32 if value.nil?
  188. 12 is_nullable = self.class.openapi_nullable.include?(attr)
  189. 12 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  190. end
  191. 20 hash[param] = _to_hash(value)
  192. end
  193. 8 hash
  194. end
  195. end
  196. end

lib/bandwidth-sdk/models/rbm_card_content_media.rb

72.73% lines covered

110 relevant lines. 80 lines covered and 30 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class RbmCardContentMedia < ApiModelBase
  13. # The URL of the media file. 100MB is the maximum file size.
  14. 1 attr_accessor :file_url
  15. # The URL of the thumbnail image. Applies only to video file media.
  16. 1 attr_accessor :thumbnail_url
  17. 1 attr_accessor :height
  18. 1 class EnumAttributeValidator
  19. 1 attr_reader :datatype
  20. 1 attr_reader :allowable_values
  21. 1 def initialize(datatype, allowable_values)
  22. @allowable_values = allowable_values.map do |value|
  23. case datatype.to_s
  24. when /Integer/i
  25. value.to_i
  26. when /Float/i
  27. value.to_f
  28. else
  29. value
  30. end
  31. end
  32. end
  33. 1 def valid?(value)
  34. !value || allowable_values.include?(value)
  35. end
  36. end
  37. # Attribute mapping from ruby-style variable name to JSON key.
  38. 1 def self.attribute_map
  39. 44 {
  40. :'file_url' => :'fileUrl',
  41. :'thumbnail_url' => :'thumbnailUrl',
  42. :'height' => :'height'
  43. }
  44. end
  45. # Returns attribute mapping this model knows about
  46. 1 def self.acceptable_attribute_map
  47. 17 attribute_map
  48. end
  49. # Returns all the JSON keys this model knows about
  50. 1 def self.acceptable_attributes
  51. 1 acceptable_attribute_map.values
  52. end
  53. # Attribute type mapping.
  54. 1 def self.openapi_types
  55. 2 {
  56. :'file_url' => :'String',
  57. :'thumbnail_url' => :'String',
  58. :'height' => :'RbmMediaHeightEnum'
  59. }
  60. end
  61. # List of attributes with nullable: true
  62. 1 def self.openapi_nullable
  63. 3 Set.new([
  64. ])
  65. end
  66. # List of class defined in allOf (OpenAPI v3)
  67. 1 def self.openapi_all_of
  68. [
  69. :'RbmMessageContentFile'
  70. ]
  71. end
  72. # Initializes the object
  73. # @param [Hash] attributes Model attributes in the form of hash
  74. 1 def initialize(attributes = {})
  75. 17 if (!attributes.is_a?(Hash))
  76. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RbmCardContentMedia` initialize method'
  77. end
  78. # check to see if the attribute exists and convert string to symbol for hash key
  79. 16 acceptable_attribute_map = self.class.acceptable_attribute_map
  80. 16 attributes = attributes.each_with_object({}) { |(k, v), h|
  81. 34 if (!acceptable_attribute_map.key?(k.to_sym))
  82. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RbmCardContentMedia`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  83. end
  84. 33 h[k.to_sym] = v
  85. }
  86. 15 if attributes.key?(:'file_url')
  87. 15 self.file_url = attributes[:'file_url']
  88. else
  89. self.file_url = nil
  90. end
  91. 13 if attributes.key?(:'thumbnail_url')
  92. 5 self.thumbnail_url = attributes[:'thumbnail_url']
  93. end
  94. 13 if attributes.key?(:'height')
  95. 13 self.height = attributes[:'height']
  96. else
  97. self.height = nil
  98. end
  99. end
  100. # Show invalid properties with the reasons. Usually used together with valid?
  101. # @return Array for valid properties with the reasons
  102. 1 def list_invalid_properties
  103. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  104. invalid_properties = Array.new
  105. if @file_url.nil?
  106. invalid_properties.push('invalid value for "file_url", file_url cannot be nil.')
  107. end
  108. if @file_url.to_s.length > 1000
  109. invalid_properties.push('invalid value for "file_url", the character length must be smaller than or equal to 1000.')
  110. end
  111. if !@thumbnail_url.nil? && @thumbnail_url.to_s.length > 1000
  112. invalid_properties.push('invalid value for "thumbnail_url", the character length must be smaller than or equal to 1000.')
  113. end
  114. if @height.nil?
  115. invalid_properties.push('invalid value for "height", height cannot be nil.')
  116. end
  117. invalid_properties
  118. end
  119. # Check to see if the all the properties in the model are valid
  120. # @return true if the model is valid
  121. 1 def valid?
  122. warn '[DEPRECATED] the `valid?` method is obsolete'
  123. return false if @file_url.nil?
  124. return false if @file_url.to_s.length > 1000
  125. return false if !@thumbnail_url.nil? && @thumbnail_url.to_s.length > 1000
  126. return false if @height.nil?
  127. true
  128. end
  129. # Custom attribute writer method with validation
  130. # @param [Object] file_url Value to be assigned
  131. 1 def file_url=(file_url)
  132. 15 if file_url.nil?
  133. 1 fail ArgumentError, 'file_url cannot be nil'
  134. end
  135. 14 if file_url.to_s.length > 1000
  136. 1 fail ArgumentError, 'invalid value for "file_url", the character length must be smaller than or equal to 1000.'
  137. end
  138. 13 @file_url = file_url
  139. end
  140. # Custom attribute writer method with validation
  141. # @param [Object] thumbnail_url Value to be assigned
  142. 1 def thumbnail_url=(thumbnail_url)
  143. 7 if thumbnail_url.nil?
  144. 1 fail ArgumentError, 'thumbnail_url cannot be nil'
  145. end
  146. 6 if thumbnail_url.to_s.length > 1000
  147. 1 fail ArgumentError, 'invalid value for "thumbnail_url", the character length must be smaller than or equal to 1000.'
  148. end
  149. 5 @thumbnail_url = thumbnail_url
  150. end
  151. # Custom attribute writer method with validation
  152. # @param [Object] height Value to be assigned
  153. 1 def height=(height)
  154. 13 if height.nil?
  155. 1 fail ArgumentError, 'height cannot be nil'
  156. end
  157. 12 @height = height
  158. end
  159. # Checks equality by comparing each attribute.
  160. # @param [Object] Object to be compared
  161. 1 def ==(o)
  162. 2 return true if self.equal?(o)
  163. 2 self.class == o.class &&
  164. file_url == o.file_url &&
  165. thumbnail_url == o.thumbnail_url &&
  166. height == o.height
  167. end
  168. # @see the `==` method
  169. # @param [Object] Object to be compared
  170. 1 def eql?(o)
  171. 2 self == o
  172. end
  173. # Calculates hash code according to all attributes.
  174. # @return [Integer] Hash code
  175. 1 def hash
  176. [file_url, thumbnail_url, height].hash
  177. end
  178. # Builds the object from hash
  179. # @param [Hash] attributes Model attributes in the form of hash
  180. # @return [Object] Returns the model itself
  181. 1 def self.build_from_hash(attributes)
  182. 2 return nil unless attributes.is_a?(Hash)
  183. 2 attributes = attributes.transform_keys(&:to_sym)
  184. 2 transformed_hash = {}
  185. 2 openapi_types.each_pair do |key, type|
  186. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  187. transformed_hash["#{key}"] = nil
  188. 6 elsif type =~ /\AArray<(.*)>/i
  189. # check to ensure the input is an array given that the attribute
  190. # is documented as an array but the input is not
  191. if attributes[attribute_map[key]].is_a?(Array)
  192. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  193. end
  194. 6 elsif !attributes[attribute_map[key]].nil?
  195. 5 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  196. end
  197. end
  198. 2 new(transformed_hash)
  199. end
  200. # Returns the object in the form of hash
  201. # @return [Hash] Returns the object in the form of hash
  202. 1 def to_hash
  203. 4 hash = {}
  204. 4 self.class.attribute_map.each_pair do |attr, param|
  205. 12 value = self.send(attr)
  206. 12 if value.nil?
  207. 2 is_nullable = self.class.openapi_nullable.include?(attr)
  208. 2 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  209. end
  210. 10 hash[param] = _to_hash(value)
  211. end
  212. 4 hash
  213. end
  214. end
  215. end

lib/bandwidth-sdk/models/rbm_location_response.rb

82.81% lines covered

64 relevant lines. 53 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class RbmLocationResponse < ApiModelBase
  13. # The latitude of the client's location.
  14. 1 attr_accessor :latitude
  15. # The longitude of the client's location.
  16. 1 attr_accessor :longitude
  17. # Attribute mapping from ruby-style variable name to JSON key.
  18. 1 def self.attribute_map
  19. 19 {
  20. :'latitude' => :'latitude',
  21. :'longitude' => :'longitude'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 8 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 1 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 1 {
  35. :'latitude' => :'Float',
  36. :'longitude' => :'Float'
  37. }
  38. end
  39. # List of attributes with nullable: true
  40. 1 def self.openapi_nullable
  41. 1 Set.new([
  42. ])
  43. end
  44. # Initializes the object
  45. # @param [Hash] attributes Model attributes in the form of hash
  46. 1 def initialize(attributes = {})
  47. 8 if (!attributes.is_a?(Hash))
  48. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RbmLocationResponse` initialize method'
  49. end
  50. # check to see if the attribute exists and convert string to symbol for hash key
  51. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  52. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  53. 9 if (!acceptable_attribute_map.key?(k.to_sym))
  54. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RbmLocationResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  55. end
  56. 8 h[k.to_sym] = v
  57. }
  58. 6 if attributes.key?(:'latitude')
  59. 4 self.latitude = attributes[:'latitude']
  60. end
  61. 6 if attributes.key?(:'longitude')
  62. 4 self.longitude = attributes[:'longitude']
  63. end
  64. end
  65. # Show invalid properties with the reasons. Usually used together with valid?
  66. # @return Array for valid properties with the reasons
  67. 1 def list_invalid_properties
  68. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  69. invalid_properties = Array.new
  70. invalid_properties
  71. end
  72. # Check to see if the all the properties in the model are valid
  73. # @return true if the model is valid
  74. 1 def valid?
  75. warn '[DEPRECATED] the `valid?` method is obsolete'
  76. true
  77. end
  78. # Checks equality by comparing each attribute.
  79. # @param [Object] Object to be compared
  80. 1 def ==(o)
  81. 2 return true if self.equal?(o)
  82. 2 self.class == o.class &&
  83. latitude == o.latitude &&
  84. longitude == o.longitude
  85. end
  86. # @see the `==` method
  87. # @param [Object] Object to be compared
  88. 1 def eql?(o)
  89. 2 self == o
  90. end
  91. # Calculates hash code according to all attributes.
  92. # @return [Integer] Hash code
  93. 1 def hash
  94. [latitude, longitude].hash
  95. end
  96. # Builds the object from hash
  97. # @param [Hash] attributes Model attributes in the form of hash
  98. # @return [Object] Returns the model itself
  99. 1 def self.build_from_hash(attributes)
  100. 1 return nil unless attributes.is_a?(Hash)
  101. 1 attributes = attributes.transform_keys(&:to_sym)
  102. 1 transformed_hash = {}
  103. 1 openapi_types.each_pair do |key, type|
  104. 2 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  105. transformed_hash["#{key}"] = nil
  106. 2 elsif type =~ /\AArray<(.*)>/i
  107. # check to ensure the input is an array given that the attribute
  108. # is documented as an array but the input is not
  109. if attributes[attribute_map[key]].is_a?(Array)
  110. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  111. end
  112. 2 elsif !attributes[attribute_map[key]].nil?
  113. 2 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  114. end
  115. end
  116. 1 new(transformed_hash)
  117. end
  118. # Returns the object in the form of hash
  119. # @return [Hash] Returns the object in the form of hash
  120. 1 def to_hash
  121. 2 hash = {}
  122. 2 self.class.attribute_map.each_pair do |attr, param|
  123. 4 value = self.send(attr)
  124. 4 if value.nil?
  125. is_nullable = self.class.openapi_nullable.include?(attr)
  126. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  127. end
  128. 4 hash[param] = _to_hash(value)
  129. end
  130. 2 hash
  131. end
  132. end
  133. end

lib/bandwidth-sdk/models/rbm_media_height_enum.rb

100.0% lines covered

14 relevant lines. 14 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class RbmMediaHeightEnum
  13. 1 SHORT = 'SHORT'.freeze
  14. 1 MEDIUM = 'MEDIUM'.freeze
  15. 1 TALL = 'TALL'.freeze
  16. 1 def self.all_vars
  17. 7 @all_vars ||= [SHORT, MEDIUM, TALL].freeze
  18. end
  19. # Builds the enum from string
  20. # @param [String] The enum value in the form of the string
  21. # @return [String] The enum value
  22. 1 def self.build_from_hash(value)
  23. 6 new.build_from_hash(value)
  24. end
  25. # Builds the enum from string
  26. # @param [String] The enum value in the form of the string
  27. # @return [String] The enum value
  28. 1 def build_from_hash(value)
  29. 6 return value if RbmMediaHeightEnum.all_vars.include?(value)
  30. 1 raise "Invalid ENUM value #{value} for class #RbmMediaHeightEnum"
  31. end
  32. end
  33. end

lib/bandwidth-sdk/models/rbm_message_carousel_card.rb

72.17% lines covered

115 relevant lines. 83 lines covered and 32 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class RbmMessageCarouselCard < ApiModelBase
  13. 1 attr_accessor :card_width
  14. 1 attr_accessor :card_contents
  15. # An array of suggested actions for the recipient.
  16. 1 attr_accessor :suggestions
  17. 1 class EnumAttributeValidator
  18. 1 attr_reader :datatype
  19. 1 attr_reader :allowable_values
  20. 1 def initialize(datatype, allowable_values)
  21. @allowable_values = allowable_values.map do |value|
  22. case datatype.to_s
  23. when /Integer/i
  24. value.to_i
  25. when /Float/i
  26. value.to_f
  27. else
  28. value
  29. end
  30. end
  31. end
  32. 1 def valid?(value)
  33. !value || allowable_values.include?(value)
  34. end
  35. end
  36. # Attribute mapping from ruby-style variable name to JSON key.
  37. 1 def self.attribute_map
  38. 47 {
  39. :'card_width' => :'cardWidth',
  40. :'card_contents' => :'cardContents',
  41. :'suggestions' => :'suggestions'
  42. }
  43. end
  44. # Returns attribute mapping this model knows about
  45. 1 def self.acceptable_attribute_map
  46. 22 attribute_map
  47. end
  48. # Returns all the JSON keys this model knows about
  49. 1 def self.acceptable_attributes
  50. 10 acceptable_attribute_map.values
  51. end
  52. # Attribute type mapping.
  53. 1 def self.openapi_types
  54. 2 {
  55. :'card_width' => :'CardWidthEnum',
  56. :'card_contents' => :'Array<RbmCardContent>',
  57. :'suggestions' => :'Array<MultiChannelAction>'
  58. }
  59. end
  60. # List of attributes with nullable: true
  61. 1 def self.openapi_nullable
  62. 1 Set.new([
  63. ])
  64. end
  65. # Initializes the object
  66. # @param [Hash] attributes Model attributes in the form of hash
  67. 1 def initialize(attributes = {})
  68. 13 if (!attributes.is_a?(Hash))
  69. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RbmMessageCarouselCard` initialize method'
  70. end
  71. # check to see if the attribute exists and convert string to symbol for hash key
  72. 12 acceptable_attribute_map = self.class.acceptable_attribute_map
  73. 12 attributes = attributes.each_with_object({}) { |(k, v), h|
  74. 27 if (!acceptable_attribute_map.key?(k.to_sym))
  75. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RbmMessageCarouselCard`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  76. end
  77. 26 h[k.to_sym] = v
  78. }
  79. 11 if attributes.key?(:'card_width')
  80. 11 self.card_width = attributes[:'card_width']
  81. else
  82. self.card_width = nil
  83. end
  84. 10 if attributes.key?(:'card_contents')
  85. 9 if (value = attributes[:'card_contents']).is_a?(Array)
  86. 9 self.card_contents = value
  87. end
  88. else
  89. 1 self.card_contents = nil
  90. end
  91. 9 if attributes.key?(:'suggestions')
  92. 6 if (value = attributes[:'suggestions']).is_a?(Array)
  93. 6 self.suggestions = value
  94. end
  95. end
  96. end
  97. # Show invalid properties with the reasons. Usually used together with valid?
  98. # @return Array for valid properties with the reasons
  99. 1 def list_invalid_properties
  100. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  101. invalid_properties = Array.new
  102. if @card_width.nil?
  103. invalid_properties.push('invalid value for "card_width", card_width cannot be nil.')
  104. end
  105. if @card_contents.nil?
  106. invalid_properties.push('invalid value for "card_contents", card_contents cannot be nil.')
  107. end
  108. if @card_contents.length > 10
  109. invalid_properties.push('invalid value for "card_contents", number of items must be less than or equal to 10.')
  110. end
  111. if @card_contents.length < 2
  112. invalid_properties.push('invalid value for "card_contents", number of items must be greater than or equal to 2.')
  113. end
  114. if !@suggestions.nil? && @suggestions.length > 11
  115. invalid_properties.push('invalid value for "suggestions", number of items must be less than or equal to 11.')
  116. end
  117. invalid_properties
  118. end
  119. # Check to see if the all the properties in the model are valid
  120. # @return true if the model is valid
  121. 1 def valid?
  122. warn '[DEPRECATED] the `valid?` method is obsolete'
  123. return false if @card_width.nil?
  124. return false if @card_contents.nil?
  125. return false if @card_contents.length > 10
  126. return false if @card_contents.length < 2
  127. return false if !@suggestions.nil? && @suggestions.length > 11
  128. true
  129. end
  130. # Custom attribute writer method with validation
  131. # @param [Object] card_width Value to be assigned
  132. 1 def card_width=(card_width)
  133. 11 if card_width.nil?
  134. 1 fail ArgumentError, 'card_width cannot be nil'
  135. end
  136. 10 @card_width = card_width
  137. end
  138. # Custom attribute writer method with validation
  139. # @param [Object] card_contents Value to be assigned
  140. 1 def card_contents=(card_contents)
  141. 12 if card_contents.nil?
  142. 2 fail ArgumentError, 'card_contents cannot be nil'
  143. end
  144. 10 if card_contents.length > 10
  145. 1 fail ArgumentError, 'invalid value for "card_contents", number of items must be less than or equal to 10.'
  146. end
  147. 9 if card_contents.length < 2
  148. fail ArgumentError, 'invalid value for "card_contents", number of items must be greater than or equal to 2.'
  149. end
  150. 9 @card_contents = card_contents
  151. end
  152. # Custom attribute writer method with validation
  153. # @param [Object] suggestions Value to be assigned
  154. 1 def suggestions=(suggestions)
  155. 8 if suggestions.nil?
  156. 1 fail ArgumentError, 'suggestions cannot be nil'
  157. end
  158. 7 if suggestions.length > 11
  159. 1 fail ArgumentError, 'invalid value for "suggestions", number of items must be less than or equal to 11.'
  160. end
  161. 6 @suggestions = suggestions
  162. end
  163. # Checks equality by comparing each attribute.
  164. # @param [Object] Object to be compared
  165. 1 def ==(o)
  166. 2 return true if self.equal?(o)
  167. 2 self.class == o.class &&
  168. card_width == o.card_width &&
  169. card_contents == o.card_contents &&
  170. suggestions == o.suggestions
  171. end
  172. # @see the `==` method
  173. # @param [Object] Object to be compared
  174. 1 def eql?(o)
  175. 2 self == o
  176. end
  177. # Calculates hash code according to all attributes.
  178. # @return [Integer] Hash code
  179. 1 def hash
  180. [card_width, card_contents, suggestions].hash
  181. end
  182. # Builds the object from hash
  183. # @param [Hash] attributes Model attributes in the form of hash
  184. # @return [Object] Returns the model itself
  185. 1 def self.build_from_hash(attributes)
  186. 2 return nil unless attributes.is_a?(Hash)
  187. 2 attributes = attributes.transform_keys(&:to_sym)
  188. 2 transformed_hash = {}
  189. 2 openapi_types.each_pair do |key, type|
  190. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  191. transformed_hash["#{key}"] = nil
  192. 6 elsif type =~ /\AArray<(.*)>/i
  193. # check to ensure the input is an array given that the attribute
  194. # is documented as an array but the input is not
  195. 4 if attributes[attribute_map[key]].is_a?(Array)
  196. 8 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  197. end
  198. 2 elsif !attributes[attribute_map[key]].nil?
  199. 2 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  200. end
  201. end
  202. 2 new(transformed_hash)
  203. end
  204. # Returns the object in the form of hash
  205. # @return [Hash] Returns the object in the form of hash
  206. 1 def to_hash
  207. 2 hash = {}
  208. 2 self.class.attribute_map.each_pair do |attr, param|
  209. 6 value = self.send(attr)
  210. 6 if value.nil?
  211. is_nullable = self.class.openapi_nullable.include?(attr)
  212. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  213. end
  214. 6 hash[param] = _to_hash(value)
  215. end
  216. 2 hash
  217. end
  218. end
  219. end

lib/bandwidth-sdk/models/rbm_message_content_file.rb

77.91% lines covered

86 relevant lines. 67 lines covered and 19 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class RbmMessageContentFile < ApiModelBase
  13. # The URL of the media file. 100MB is the maximum file size.
  14. 1 attr_accessor :file_url
  15. # The URL of the thumbnail image. Applies only to video file media.
  16. 1 attr_accessor :thumbnail_url
  17. # Attribute mapping from ruby-style variable name to JSON key.
  18. 1 def self.attribute_map
  19. 55 {
  20. :'file_url' => :'fileUrl',
  21. :'thumbnail_url' => :'thumbnailUrl'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 22 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 1 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 4 {
  35. :'file_url' => :'String',
  36. :'thumbnail_url' => :'String'
  37. }
  38. end
  39. # List of attributes with nullable: true
  40. 1 def self.openapi_nullable
  41. 5 Set.new([
  42. ])
  43. end
  44. # Initializes the object
  45. # @param [Hash] attributes Model attributes in the form of hash
  46. 1 def initialize(attributes = {})
  47. 22 if (!attributes.is_a?(Hash))
  48. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RbmMessageContentFile` initialize method'
  49. end
  50. # check to see if the attribute exists and convert string to symbol for hash key
  51. 21 acceptable_attribute_map = self.class.acceptable_attribute_map
  52. 21 attributes = attributes.each_with_object({}) { |(k, v), h|
  53. 26 if (!acceptable_attribute_map.key?(k.to_sym))
  54. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RbmMessageContentFile`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  55. end
  56. 25 h[k.to_sym] = v
  57. }
  58. 20 if attributes.key?(:'file_url')
  59. 20 self.file_url = attributes[:'file_url']
  60. else
  61. self.file_url = nil
  62. end
  63. 18 if attributes.key?(:'thumbnail_url')
  64. 5 self.thumbnail_url = attributes[:'thumbnail_url']
  65. end
  66. end
  67. # Show invalid properties with the reasons. Usually used together with valid?
  68. # @return Array for valid properties with the reasons
  69. 1 def list_invalid_properties
  70. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  71. invalid_properties = Array.new
  72. if @file_url.nil?
  73. invalid_properties.push('invalid value for "file_url", file_url cannot be nil.')
  74. end
  75. if @file_url.to_s.length > 1000
  76. invalid_properties.push('invalid value for "file_url", the character length must be smaller than or equal to 1000.')
  77. end
  78. if !@thumbnail_url.nil? && @thumbnail_url.to_s.length > 1000
  79. invalid_properties.push('invalid value for "thumbnail_url", the character length must be smaller than or equal to 1000.')
  80. end
  81. invalid_properties
  82. end
  83. # Check to see if the all the properties in the model are valid
  84. # @return true if the model is valid
  85. 1 def valid?
  86. warn '[DEPRECATED] the `valid?` method is obsolete'
  87. return false if @file_url.nil?
  88. return false if @file_url.to_s.length > 1000
  89. return false if !@thumbnail_url.nil? && @thumbnail_url.to_s.length > 1000
  90. true
  91. end
  92. # Custom attribute writer method with validation
  93. # @param [Object] file_url Value to be assigned
  94. 1 def file_url=(file_url)
  95. 20 if file_url.nil?
  96. 1 fail ArgumentError, 'file_url cannot be nil'
  97. end
  98. 19 if file_url.to_s.length > 1000
  99. 1 fail ArgumentError, 'invalid value for "file_url", the character length must be smaller than or equal to 1000.'
  100. end
  101. 18 @file_url = file_url
  102. end
  103. # Custom attribute writer method with validation
  104. # @param [Object] thumbnail_url Value to be assigned
  105. 1 def thumbnail_url=(thumbnail_url)
  106. 7 if thumbnail_url.nil?
  107. 1 fail ArgumentError, 'thumbnail_url cannot be nil'
  108. end
  109. 6 if thumbnail_url.to_s.length > 1000
  110. 1 fail ArgumentError, 'invalid value for "thumbnail_url", the character length must be smaller than or equal to 1000.'
  111. end
  112. 5 @thumbnail_url = thumbnail_url
  113. end
  114. # Checks equality by comparing each attribute.
  115. # @param [Object] Object to be compared
  116. 1 def ==(o)
  117. 2 return true if self.equal?(o)
  118. 2 self.class == o.class &&
  119. file_url == o.file_url &&
  120. thumbnail_url == o.thumbnail_url
  121. end
  122. # @see the `==` method
  123. # @param [Object] Object to be compared
  124. 1 def eql?(o)
  125. 2 self == o
  126. end
  127. # Calculates hash code according to all attributes.
  128. # @return [Integer] Hash code
  129. 1 def hash
  130. [file_url, thumbnail_url].hash
  131. end
  132. # Builds the object from hash
  133. # @param [Hash] attributes Model attributes in the form of hash
  134. # @return [Object] Returns the model itself
  135. 1 def self.build_from_hash(attributes)
  136. 4 return nil unless attributes.is_a?(Hash)
  137. 4 attributes = attributes.transform_keys(&:to_sym)
  138. 4 transformed_hash = {}
  139. 4 openapi_types.each_pair do |key, type|
  140. 8 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  141. transformed_hash["#{key}"] = nil
  142. 8 elsif type =~ /\AArray<(.*)>/i
  143. # check to ensure the input is an array given that the attribute
  144. # is documented as an array but the input is not
  145. if attributes[attribute_map[key]].is_a?(Array)
  146. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  147. end
  148. 8 elsif !attributes[attribute_map[key]].nil?
  149. 5 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  150. end
  151. end
  152. 4 new(transformed_hash)
  153. end
  154. # Returns the object in the form of hash
  155. # @return [Hash] Returns the object in the form of hash
  156. 1 def to_hash
  157. 6 hash = {}
  158. 6 self.class.attribute_map.each_pair do |attr, param|
  159. 12 value = self.send(attr)
  160. 12 if value.nil?
  161. 4 is_nullable = self.class.openapi_nullable.include?(attr)
  162. 4 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  163. end
  164. 8 hash[param] = _to_hash(value)
  165. end
  166. 6 hash
  167. end
  168. end
  169. end

lib/bandwidth-sdk/models/rbm_message_content_rich_card.rb

60.0% lines covered

40 relevant lines. 24 lines covered and 16 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 module RbmMessageContentRichCard
  13. 1 class << self
  14. # List of class defined in oneOf (OpenAPI v3)
  15. 1 def openapi_one_of
  16. 17 [
  17. :'RbmMessageCarouselCard',
  18. :'RbmStandaloneCard'
  19. ]
  20. end
  21. # Builds the object
  22. # @param [Mixed] Data to be matched against the list of oneOf items
  23. # @return [Object] Returns the model or the data itself
  24. 1 def build(data)
  25. # Go through the list of oneOf items and attempt to identify the appropriate one.
  26. # Note:
  27. # - We do not attempt to check whether exactly one item matches.
  28. # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
  29. # due to the way the deserialization is made in the base_object template (it just casts without verifying).
  30. # - TODO: scalar values are de facto behaving as if they were nullable.
  31. # - TODO: logging when debugging is set.
  32. 9 openapi_one_of.each do |klass|
  33. begin
  34. 17 next if klass == :AnyType # "nullable: true"
  35. 17 return find_and_cast_into_type(klass, data)
  36. rescue # rescue all errors so we keep iterating even if the current item lookup raises
  37. end
  38. end
  39. 7 openapi_one_of.include?(:AnyType) ? data : nil
  40. end
  41. 1 private
  42. 1 SchemaMismatchError = Class.new(StandardError)
  43. # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
  44. 1 def find_and_cast_into_type(klass, data)
  45. 17 return if data.nil?
  46. 17 case klass.to_s
  47. when 'Boolean'
  48. return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
  49. when 'Float'
  50. return data if data.instance_of?(Float)
  51. when 'Integer'
  52. return data if data.instance_of?(Integer)
  53. when 'Time'
  54. return Time.parse(data)
  55. when 'Date'
  56. return Date.iso8601(data)
  57. when 'String'
  58. return data if data.instance_of?(String)
  59. when 'Object' # "type: object"
  60. return data if data.instance_of?(Hash)
  61. when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
  62. if data.instance_of?(Array)
  63. sub_type = Regexp.last_match[:sub_type]
  64. return data.map { |item| find_and_cast_into_type(sub_type, item) }
  65. end
  66. when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
  67. if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
  68. sub_type = Regexp.last_match[:sub_type]
  69. return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
  70. end
  71. else # model
  72. 17 const = Bandwidth.const_get(klass)
  73. 17 if const
  74. 17 if const.respond_to?(:openapi_one_of) # nested oneOf model
  75. model = const.build(data)
  76. return model if model
  77. else
  78. # raise if data contains keys that are not known to the model
  79. 17 raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
  80. 2 model = const.build_from_hash(data)
  81. 2 return model if model
  82. end
  83. end
  84. end
  85. raise # if no match by now, raise
  86. rescue
  87. 15 raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
  88. end
  89. end
  90. end
  91. end

lib/bandwidth-sdk/models/rbm_message_content_text.rb

80.46% lines covered

87 relevant lines. 70 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class RbmMessageContentText < ApiModelBase
  13. # The text associated with the message. Must be 3270 characters or less
  14. 1 attr_accessor :text
  15. # An array of suggested actions for the recipient.
  16. 1 attr_accessor :suggestions
  17. # Attribute mapping from ruby-style variable name to JSON key.
  18. 1 def self.attribute_map
  19. 72 {
  20. :'text' => :'text',
  21. :'suggestions' => :'suggestions'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 31 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 7 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 5 {
  35. :'text' => :'String',
  36. :'suggestions' => :'Array<MultiChannelAction>'
  37. }
  38. end
  39. # List of attributes with nullable: true
  40. 1 def self.openapi_nullable
  41. 5 Set.new([
  42. ])
  43. end
  44. # Initializes the object
  45. # @param [Hash] attributes Model attributes in the form of hash
  46. 1 def initialize(attributes = {})
  47. 25 if (!attributes.is_a?(Hash))
  48. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RbmMessageContentText` initialize method'
  49. end
  50. # check to see if the attribute exists and convert string to symbol for hash key
  51. 24 acceptable_attribute_map = self.class.acceptable_attribute_map
  52. 24 attributes = attributes.each_with_object({}) { |(k, v), h|
  53. 30 if (!acceptable_attribute_map.key?(k.to_sym))
  54. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RbmMessageContentText`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  55. end
  56. 29 h[k.to_sym] = v
  57. }
  58. 23 if attributes.key?(:'text')
  59. 23 self.text = attributes[:'text']
  60. else
  61. self.text = nil
  62. end
  63. 21 if attributes.key?(:'suggestions')
  64. 6 if (value = attributes[:'suggestions']).is_a?(Array)
  65. 6 self.suggestions = value
  66. end
  67. end
  68. end
  69. # Show invalid properties with the reasons. Usually used together with valid?
  70. # @return Array for valid properties with the reasons
  71. 1 def list_invalid_properties
  72. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  73. invalid_properties = Array.new
  74. if @text.nil?
  75. invalid_properties.push('invalid value for "text", text cannot be nil.')
  76. end
  77. if @text.to_s.length > 3270
  78. invalid_properties.push('invalid value for "text", the character length must be smaller than or equal to 3270.')
  79. end
  80. if !@suggestions.nil? && @suggestions.length > 11
  81. invalid_properties.push('invalid value for "suggestions", number of items must be less than or equal to 11.')
  82. end
  83. invalid_properties
  84. end
  85. # Check to see if the all the properties in the model are valid
  86. # @return true if the model is valid
  87. 1 def valid?
  88. warn '[DEPRECATED] the `valid?` method is obsolete'
  89. return false if @text.nil?
  90. return false if @text.to_s.length > 3270
  91. return false if !@suggestions.nil? && @suggestions.length > 11
  92. true
  93. end
  94. # Custom attribute writer method with validation
  95. # @param [Object] text Value to be assigned
  96. 1 def text=(text)
  97. 23 if text.nil?
  98. 1 fail ArgumentError, 'text cannot be nil'
  99. end
  100. 22 if text.to_s.length > 3270
  101. 1 fail ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 3270.'
  102. end
  103. 21 @text = text
  104. end
  105. # Custom attribute writer method with validation
  106. # @param [Object] suggestions Value to be assigned
  107. 1 def suggestions=(suggestions)
  108. 8 if suggestions.nil?
  109. 1 fail ArgumentError, 'suggestions cannot be nil'
  110. end
  111. 7 if suggestions.length > 11
  112. 1 fail ArgumentError, 'invalid value for "suggestions", number of items must be less than or equal to 11.'
  113. end
  114. 6 @suggestions = suggestions
  115. end
  116. # Checks equality by comparing each attribute.
  117. # @param [Object] Object to be compared
  118. 1 def ==(o)
  119. 4 return true if self.equal?(o)
  120. 4 self.class == o.class &&
  121. text == o.text &&
  122. suggestions == o.suggestions
  123. end
  124. # @see the `==` method
  125. # @param [Object] Object to be compared
  126. 1 def eql?(o)
  127. 2 self == o
  128. end
  129. # Calculates hash code according to all attributes.
  130. # @return [Integer] Hash code
  131. 1 def hash
  132. [text, suggestions].hash
  133. end
  134. # Builds the object from hash
  135. # @param [Hash] attributes Model attributes in the form of hash
  136. # @return [Object] Returns the model itself
  137. 1 def self.build_from_hash(attributes)
  138. 5 return nil unless attributes.is_a?(Hash)
  139. 5 attributes = attributes.transform_keys(&:to_sym)
  140. 5 transformed_hash = {}
  141. 5 openapi_types.each_pair do |key, type|
  142. 10 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  143. transformed_hash["#{key}"] = nil
  144. 10 elsif type =~ /\AArray<(.*)>/i
  145. # check to ensure the input is an array given that the attribute
  146. # is documented as an array but the input is not
  147. 5 if attributes[attribute_map[key]].is_a?(Array)
  148. 4 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  149. end
  150. 5 elsif !attributes[attribute_map[key]].nil?
  151. 5 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  152. end
  153. end
  154. 5 new(transformed_hash)
  155. end
  156. # Returns the object in the form of hash
  157. # @return [Hash] Returns the object in the form of hash
  158. 1 def to_hash
  159. 6 hash = {}
  160. 6 self.class.attribute_map.each_pair do |attr, param|
  161. 12 value = self.send(attr)
  162. 12 if value.nil?
  163. 4 is_nullable = self.class.openapi_nullable.include?(attr)
  164. 4 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  165. end
  166. 8 hash[param] = _to_hash(value)
  167. end
  168. 6 hash
  169. end
  170. end
  171. end

lib/bandwidth-sdk/models/rbm_message_media.rb

79.52% lines covered

83 relevant lines. 66 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class RbmMessageMedia < ApiModelBase
  13. 1 attr_accessor :media
  14. # An array of suggested actions for the recipient.
  15. 1 attr_accessor :suggestions
  16. # Attribute mapping from ruby-style variable name to JSON key.
  17. 1 def self.attribute_map
  18. 31 {
  19. :'media' => :'media',
  20. :'suggestions' => :'suggestions'
  21. }
  22. end
  23. # Returns attribute mapping this model knows about
  24. 1 def self.acceptable_attribute_map
  25. 14 attribute_map
  26. end
  27. # Returns all the JSON keys this model knows about
  28. 1 def self.acceptable_attributes
  29. 3 acceptable_attribute_map.values
  30. end
  31. # Attribute type mapping.
  32. 1 def self.openapi_types
  33. 2 {
  34. :'media' => :'Array<RbmMessageContentFile>',
  35. :'suggestions' => :'Array<MultiChannelAction>'
  36. }
  37. end
  38. # List of attributes with nullable: true
  39. 1 def self.openapi_nullable
  40. 1 Set.new([
  41. ])
  42. end
  43. # Initializes the object
  44. # @param [Hash] attributes Model attributes in the form of hash
  45. 1 def initialize(attributes = {})
  46. 12 if (!attributes.is_a?(Hash))
  47. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RbmMessageMedia` initialize method'
  48. end
  49. # check to see if the attribute exists and convert string to symbol for hash key
  50. 11 acceptable_attribute_map = self.class.acceptable_attribute_map
  51. 11 attributes = attributes.each_with_object({}) { |(k, v), h|
  52. 16 if (!acceptable_attribute_map.key?(k.to_sym))
  53. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RbmMessageMedia`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  54. end
  55. 15 h[k.to_sym] = v
  56. }
  57. 10 if attributes.key?(:'media')
  58. 9 if (value = attributes[:'media']).is_a?(Array)
  59. 9 self.media = value
  60. end
  61. else
  62. 1 self.media = nil
  63. end
  64. 9 if attributes.key?(:'suggestions')
  65. 6 if (value = attributes[:'suggestions']).is_a?(Array)
  66. 6 self.suggestions = value
  67. end
  68. end
  69. end
  70. # Show invalid properties with the reasons. Usually used together with valid?
  71. # @return Array for valid properties with the reasons
  72. 1 def list_invalid_properties
  73. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  74. invalid_properties = Array.new
  75. if @media.nil?
  76. invalid_properties.push('invalid value for "media", media cannot be nil.')
  77. end
  78. if !@suggestions.nil? && @suggestions.length > 11
  79. invalid_properties.push('invalid value for "suggestions", number of items must be less than or equal to 11.')
  80. end
  81. invalid_properties
  82. end
  83. # Check to see if the all the properties in the model are valid
  84. # @return true if the model is valid
  85. 1 def valid?
  86. warn '[DEPRECATED] the `valid?` method is obsolete'
  87. return false if @media.nil?
  88. return false if !@suggestions.nil? && @suggestions.length > 11
  89. true
  90. end
  91. # Custom attribute writer method with validation
  92. # @param [Object] media Value to be assigned
  93. 1 def media=(media)
  94. 11 if media.nil?
  95. 2 fail ArgumentError, 'media cannot be nil'
  96. end
  97. 9 @media = media
  98. end
  99. # Custom attribute writer method with validation
  100. # @param [Object] suggestions Value to be assigned
  101. 1 def suggestions=(suggestions)
  102. 8 if suggestions.nil?
  103. 1 fail ArgumentError, 'suggestions cannot be nil'
  104. end
  105. 7 if suggestions.length > 11
  106. 1 fail ArgumentError, 'invalid value for "suggestions", number of items must be less than or equal to 11.'
  107. end
  108. 6 @suggestions = suggestions
  109. end
  110. # Checks equality by comparing each attribute.
  111. # @param [Object] Object to be compared
  112. 1 def ==(o)
  113. 2 return true if self.equal?(o)
  114. 2 self.class == o.class &&
  115. media == o.media &&
  116. suggestions == o.suggestions
  117. end
  118. # @see the `==` method
  119. # @param [Object] Object to be compared
  120. 1 def eql?(o)
  121. 2 self == o
  122. end
  123. # Calculates hash code according to all attributes.
  124. # @return [Integer] Hash code
  125. 1 def hash
  126. [media, suggestions].hash
  127. end
  128. # Builds the object from hash
  129. # @param [Hash] attributes Model attributes in the form of hash
  130. # @return [Object] Returns the model itself
  131. 1 def self.build_from_hash(attributes)
  132. 2 return nil unless attributes.is_a?(Hash)
  133. 2 attributes = attributes.transform_keys(&:to_sym)
  134. 2 transformed_hash = {}
  135. 2 openapi_types.each_pair do |key, type|
  136. 4 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  137. transformed_hash["#{key}"] = nil
  138. 4 elsif type =~ /\AArray<(.*)>/i
  139. # check to ensure the input is an array given that the attribute
  140. # is documented as an array but the input is not
  141. 4 if attributes[attribute_map[key]].is_a?(Array)
  142. 6 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  143. end
  144. elsif !attributes[attribute_map[key]].nil?
  145. transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  146. end
  147. end
  148. 2 new(transformed_hash)
  149. end
  150. # Returns the object in the form of hash
  151. # @return [Hash] Returns the object in the form of hash
  152. 1 def to_hash
  153. 2 hash = {}
  154. 2 self.class.attribute_map.each_pair do |attr, param|
  155. 4 value = self.send(attr)
  156. 4 if value.nil?
  157. is_nullable = self.class.openapi_nullable.include?(attr)
  158. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  159. end
  160. 4 hash[param] = _to_hash(value)
  161. end
  162. 2 hash
  163. end
  164. end
  165. end

lib/bandwidth-sdk/models/rbm_open_url_enum.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class RbmOpenUrlEnum
  13. 1 BROWSER = 'BROWSER'.freeze
  14. 1 WEBVIEW = 'WEBVIEW'.freeze
  15. 1 def self.all_vars
  16. 5 @all_vars ||= [BROWSER, WEBVIEW].freeze
  17. end
  18. # Builds the enum from string
  19. # @param [String] The enum value in the form of the string
  20. # @return [String] The enum value
  21. 1 def self.build_from_hash(value)
  22. 4 new.build_from_hash(value)
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def build_from_hash(value)
  28. 4 return value if RbmOpenUrlEnum.all_vars.include?(value)
  29. 1 raise "Invalid ENUM value #{value} for class #RbmOpenUrlEnum"
  30. end
  31. end
  32. end

lib/bandwidth-sdk/models/rbm_standalone_card.rb

75.7% lines covered

107 relevant lines. 81 lines covered and 26 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class RbmStandaloneCard < ApiModelBase
  13. 1 attr_accessor :orientation
  14. 1 attr_accessor :thumbnail_image_alignment
  15. 1 attr_accessor :card_content
  16. # An array of suggested actions for the recipient.
  17. 1 attr_accessor :suggestions
  18. 1 class EnumAttributeValidator
  19. 1 attr_reader :datatype
  20. 1 attr_reader :allowable_values
  21. 1 def initialize(datatype, allowable_values)
  22. @allowable_values = allowable_values.map do |value|
  23. case datatype.to_s
  24. when /Integer/i
  25. value.to_i
  26. when /Float/i
  27. value.to_f
  28. else
  29. value
  30. end
  31. end
  32. end
  33. 1 def valid?(value)
  34. !value || allowable_values.include?(value)
  35. end
  36. end
  37. # Attribute mapping from ruby-style variable name to JSON key.
  38. 1 def self.attribute_map
  39. 53 {
  40. :'orientation' => :'orientation',
  41. :'thumbnail_image_alignment' => :'thumbnailImageAlignment',
  42. :'card_content' => :'cardContent',
  43. :'suggestions' => :'suggestions'
  44. }
  45. end
  46. # Returns attribute mapping this model knows about
  47. 1 def self.acceptable_attribute_map
  48. 20 attribute_map
  49. end
  50. # Returns all the JSON keys this model knows about
  51. 1 def self.acceptable_attributes
  52. 9 acceptable_attribute_map.values
  53. end
  54. # Attribute type mapping.
  55. 1 def self.openapi_types
  56. 2 {
  57. :'orientation' => :'StandaloneCardOrientationEnum',
  58. :'thumbnail_image_alignment' => :'ThumbnailAlignmentEnum',
  59. :'card_content' => :'RbmCardContent',
  60. :'suggestions' => :'Array<MultiChannelAction>'
  61. }
  62. end
  63. # List of attributes with nullable: true
  64. 1 def self.openapi_nullable
  65. 1 Set.new([
  66. ])
  67. end
  68. # Initializes the object
  69. # @param [Hash] attributes Model attributes in the form of hash
  70. 1 def initialize(attributes = {})
  71. 12 if (!attributes.is_a?(Hash))
  72. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RbmStandaloneCard` initialize method'
  73. end
  74. # check to see if the attribute exists and convert string to symbol for hash key
  75. 11 acceptable_attribute_map = self.class.acceptable_attribute_map
  76. 11 attributes = attributes.each_with_object({}) { |(k, v), h|
  77. 34 if (!acceptable_attribute_map.key?(k.to_sym))
  78. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RbmStandaloneCard`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  79. end
  80. 33 h[k.to_sym] = v
  81. }
  82. 10 if attributes.key?(:'orientation')
  83. 10 self.orientation = attributes[:'orientation']
  84. else
  85. self.orientation = nil
  86. end
  87. 9 if attributes.key?(:'thumbnail_image_alignment')
  88. 9 self.thumbnail_image_alignment = attributes[:'thumbnail_image_alignment']
  89. end
  90. 9 if attributes.key?(:'card_content')
  91. 9 self.card_content = attributes[:'card_content']
  92. else
  93. self.card_content = nil
  94. end
  95. 8 if attributes.key?(:'suggestions')
  96. 5 if (value = attributes[:'suggestions']).is_a?(Array)
  97. 5 self.suggestions = value
  98. end
  99. end
  100. end
  101. # Show invalid properties with the reasons. Usually used together with valid?
  102. # @return Array for valid properties with the reasons
  103. 1 def list_invalid_properties
  104. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  105. invalid_properties = Array.new
  106. if @orientation.nil?
  107. invalid_properties.push('invalid value for "orientation", orientation cannot be nil.')
  108. end
  109. if @card_content.nil?
  110. invalid_properties.push('invalid value for "card_content", card_content cannot be nil.')
  111. end
  112. if !@suggestions.nil? && @suggestions.length > 11
  113. invalid_properties.push('invalid value for "suggestions", number of items must be less than or equal to 11.')
  114. end
  115. invalid_properties
  116. end
  117. # Check to see if the all the properties in the model are valid
  118. # @return true if the model is valid
  119. 1 def valid?
  120. warn '[DEPRECATED] the `valid?` method is obsolete'
  121. return false if @orientation.nil?
  122. return false if @card_content.nil?
  123. return false if !@suggestions.nil? && @suggestions.length > 11
  124. true
  125. end
  126. # Custom attribute writer method with validation
  127. # @param [Object] orientation Value to be assigned
  128. 1 def orientation=(orientation)
  129. 10 if orientation.nil?
  130. 1 fail ArgumentError, 'orientation cannot be nil'
  131. end
  132. 9 @orientation = orientation
  133. end
  134. # Custom attribute writer method with validation
  135. # @param [Object] card_content Value to be assigned
  136. 1 def card_content=(card_content)
  137. 9 if card_content.nil?
  138. 1 fail ArgumentError, 'card_content cannot be nil'
  139. end
  140. 8 @card_content = card_content
  141. end
  142. # Custom attribute writer method with validation
  143. # @param [Object] suggestions Value to be assigned
  144. 1 def suggestions=(suggestions)
  145. 7 if suggestions.nil?
  146. 1 fail ArgumentError, 'suggestions cannot be nil'
  147. end
  148. 6 if suggestions.length > 11
  149. 1 fail ArgumentError, 'invalid value for "suggestions", number of items must be less than or equal to 11.'
  150. end
  151. 5 @suggestions = suggestions
  152. end
  153. # Checks equality by comparing each attribute.
  154. # @param [Object] Object to be compared
  155. 1 def ==(o)
  156. 2 return true if self.equal?(o)
  157. 2 self.class == o.class &&
  158. orientation == o.orientation &&
  159. thumbnail_image_alignment == o.thumbnail_image_alignment &&
  160. card_content == o.card_content &&
  161. suggestions == o.suggestions
  162. end
  163. # @see the `==` method
  164. # @param [Object] Object to be compared
  165. 1 def eql?(o)
  166. 2 self == o
  167. end
  168. # Calculates hash code according to all attributes.
  169. # @return [Integer] Hash code
  170. 1 def hash
  171. [orientation, thumbnail_image_alignment, card_content, suggestions].hash
  172. end
  173. # Builds the object from hash
  174. # @param [Hash] attributes Model attributes in the form of hash
  175. # @return [Object] Returns the model itself
  176. 1 def self.build_from_hash(attributes)
  177. 2 return nil unless attributes.is_a?(Hash)
  178. 2 attributes = attributes.transform_keys(&:to_sym)
  179. 2 transformed_hash = {}
  180. 2 openapi_types.each_pair do |key, type|
  181. 8 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  182. transformed_hash["#{key}"] = nil
  183. 8 elsif type =~ /\AArray<(.*)>/i
  184. # check to ensure the input is an array given that the attribute
  185. # is documented as an array but the input is not
  186. 2 if attributes[attribute_map[key]].is_a?(Array)
  187. 2 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  188. end
  189. 6 elsif !attributes[attribute_map[key]].nil?
  190. 6 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  191. end
  192. end
  193. 2 new(transformed_hash)
  194. end
  195. # Returns the object in the form of hash
  196. # @return [Hash] Returns the object in the form of hash
  197. 1 def to_hash
  198. 2 hash = {}
  199. 2 self.class.attribute_map.each_pair do |attr, param|
  200. 8 value = self.send(attr)
  201. 8 if value.nil?
  202. is_nullable = self.class.openapi_nullable.include?(attr)
  203. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  204. end
  205. 8 hash[param] = _to_hash(value)
  206. end
  207. 2 hash
  208. end
  209. end
  210. end

lib/bandwidth-sdk/models/rbm_suggestion_response.rb

80.82% lines covered

73 relevant lines. 59 lines covered and 14 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class RbmSuggestionResponse < ApiModelBase
  13. # The text associated with the suggestion response.
  14. 1 attr_accessor :text
  15. # Base64 payload the customer receives when the reply is clicked.
  16. 1 attr_accessor :postback_data
  17. # Attribute mapping from ruby-style variable name to JSON key.
  18. 1 def self.attribute_map
  19. 20 {
  20. :'text' => :'text',
  21. :'postback_data' => :'postbackData'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 9 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 1 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 1 {
  35. :'text' => :'String',
  36. :'postback_data' => :'String'
  37. }
  38. end
  39. # List of attributes with nullable: true
  40. 1 def self.openapi_nullable
  41. 1 Set.new([
  42. ])
  43. end
  44. # Initializes the object
  45. # @param [Hash] attributes Model attributes in the form of hash
  46. 1 def initialize(attributes = {})
  47. 9 if (!attributes.is_a?(Hash))
  48. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RbmSuggestionResponse` initialize method'
  49. end
  50. # check to see if the attribute exists and convert string to symbol for hash key
  51. 8 acceptable_attribute_map = self.class.acceptable_attribute_map
  52. 8 attributes = attributes.each_with_object({}) { |(k, v), h|
  53. 11 if (!acceptable_attribute_map.key?(k.to_sym))
  54. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RbmSuggestionResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  55. end
  56. 10 h[k.to_sym] = v
  57. }
  58. 7 if attributes.key?(:'text')
  59. 5 self.text = attributes[:'text']
  60. end
  61. 7 if attributes.key?(:'postback_data')
  62. 5 self.postback_data = attributes[:'postback_data']
  63. end
  64. end
  65. # Show invalid properties with the reasons. Usually used together with valid?
  66. # @return Array for valid properties with the reasons
  67. 1 def list_invalid_properties
  68. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  69. invalid_properties = Array.new
  70. if !@postback_data.nil? && @postback_data.to_s.length > 2048
  71. invalid_properties.push('invalid value for "postback_data", the character length must be smaller than or equal to 2048.')
  72. end
  73. invalid_properties
  74. end
  75. # Check to see if the all the properties in the model are valid
  76. # @return true if the model is valid
  77. 1 def valid?
  78. warn '[DEPRECATED] the `valid?` method is obsolete'
  79. return false if !@postback_data.nil? && @postback_data.to_s.length > 2048
  80. true
  81. end
  82. # Custom attribute writer method with validation
  83. # @param [Object] postback_data Value to be assigned
  84. 1 def postback_data=(postback_data)
  85. 7 if postback_data.nil?
  86. 1 fail ArgumentError, 'postback_data cannot be nil'
  87. end
  88. 6 if postback_data.to_s.length > 2048
  89. 1 fail ArgumentError, 'invalid value for "postback_data", the character length must be smaller than or equal to 2048.'
  90. end
  91. 5 @postback_data = postback_data
  92. end
  93. # Checks equality by comparing each attribute.
  94. # @param [Object] Object to be compared
  95. 1 def ==(o)
  96. 2 return true if self.equal?(o)
  97. 2 self.class == o.class &&
  98. text == o.text &&
  99. postback_data == o.postback_data
  100. end
  101. # @see the `==` method
  102. # @param [Object] Object to be compared
  103. 1 def eql?(o)
  104. 2 self == o
  105. end
  106. # Calculates hash code according to all attributes.
  107. # @return [Integer] Hash code
  108. 1 def hash
  109. [text, postback_data].hash
  110. end
  111. # Builds the object from hash
  112. # @param [Hash] attributes Model attributes in the form of hash
  113. # @return [Object] Returns the model itself
  114. 1 def self.build_from_hash(attributes)
  115. 1 return nil unless attributes.is_a?(Hash)
  116. 1 attributes = attributes.transform_keys(&:to_sym)
  117. 1 transformed_hash = {}
  118. 1 openapi_types.each_pair do |key, type|
  119. 2 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  120. transformed_hash["#{key}"] = nil
  121. 2 elsif type =~ /\AArray<(.*)>/i
  122. # check to ensure the input is an array given that the attribute
  123. # is documented as an array but the input is not
  124. if attributes[attribute_map[key]].is_a?(Array)
  125. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  126. end
  127. 2 elsif !attributes[attribute_map[key]].nil?
  128. 2 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  129. end
  130. end
  131. 1 new(transformed_hash)
  132. end
  133. # Returns the object in the form of hash
  134. # @return [Hash] Returns the object in the form of hash
  135. 1 def to_hash
  136. 2 hash = {}
  137. 2 self.class.attribute_map.each_pair do |attr, param|
  138. 4 value = self.send(attr)
  139. 4 if value.nil?
  140. is_nullable = self.class.openapi_nullable.include?(attr)
  141. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  142. end
  143. 4 hash[param] = _to_hash(value)
  144. end
  145. 2 hash
  146. end
  147. end
  148. end

lib/bandwidth-sdk/models/rbm_web_view_enum.rb

100.0% lines covered

14 relevant lines. 14 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class RbmWebViewEnum
  13. 1 FULL = 'FULL'.freeze
  14. 1 HALF = 'HALF'.freeze
  15. 1 TALL = 'TALL'.freeze
  16. 1 def self.all_vars
  17. 6 @all_vars ||= [FULL, HALF, TALL].freeze
  18. end
  19. # Builds the enum from string
  20. # @param [String] The enum value in the form of the string
  21. # @return [String] The enum value
  22. 1 def self.build_from_hash(value)
  23. 5 new.build_from_hash(value)
  24. end
  25. # Builds the enum from string
  26. # @param [String] The enum value in the form of the string
  27. # @return [String] The enum value
  28. 1 def build_from_hash(value)
  29. 5 return value if RbmWebViewEnum.all_vars.include?(value)
  30. 1 raise "Invalid ENUM value #{value} for class #RbmWebViewEnum"
  31. end
  32. end
  33. end

lib/bandwidth-sdk/models/recording_available_callback.rb

87.41% lines covered

135 relevant lines. 118 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The Recording Available event is sent after a recording has been processed. It indicates that the recording is available for download.
  13. 1 class RecordingAvailableCallback < ApiModelBase
  14. # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect.
  15. 1 attr_accessor :event_type
  16. # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.
  17. 1 attr_accessor :event_time
  18. # The user account associated with the call.
  19. 1 attr_accessor :account_id
  20. # The id of the application associated with the call.
  21. 1 attr_accessor :application_id
  22. # The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555).
  23. 1 attr_accessor :from
  24. # The phone number that received the call, in E.164 format (e.g. +15555555555).
  25. 1 attr_accessor :to
  26. 1 attr_accessor :direction
  27. # The call id associated with the event.
  28. 1 attr_accessor :call_id
  29. # The URL of the call associated with the event.
  30. 1 attr_accessor :call_url
  31. # (optional) If the event is related to the B leg of a <Transfer>, the call id of the original call leg that executed the <Transfer>. Otherwise, this field will not be present.
  32. 1 attr_accessor :parent_call_id
  33. # The unique ID of this recording
  34. 1 attr_accessor :recording_id
  35. # The URL that can be used to download the recording. Only present if the recording is finished and may be downloaded.
  36. 1 attr_accessor :media_url
  37. # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format.
  38. 1 attr_accessor :enqueued_time
  39. # Time the call was started, in ISO 8601 format.
  40. 1 attr_accessor :start_time
  41. # The time that the recording ended in ISO-8601 format
  42. 1 attr_accessor :end_time
  43. # The duration of the recording in ISO-8601 format
  44. 1 attr_accessor :duration
  45. 1 attr_accessor :file_format
  46. # Always `1` for conference recordings; multi-channel recordings are not supported on conferences.
  47. 1 attr_accessor :channels
  48. # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.
  49. 1 attr_accessor :tag
  50. # The current status of the process. For recording, current possible values are 'processing', 'partial', 'complete', 'deleted', and 'error'. For transcriptions, current possible values are 'none', 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and 'file-size-too-small'. Additional states may be added in the future, so your application must be tolerant of unknown values.
  51. 1 attr_accessor :status
  52. # The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555).
  53. 1 attr_accessor :transfer_caller_id
  54. # The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555).
  55. 1 attr_accessor :transfer_to
  56. 1 class EnumAttributeValidator
  57. 1 attr_reader :datatype
  58. 1 attr_reader :allowable_values
  59. 1 def initialize(datatype, allowable_values)
  60. @allowable_values = allowable_values.map do |value|
  61. case datatype.to_s
  62. when /Integer/i
  63. value.to_i
  64. when /Float/i
  65. value.to_f
  66. else
  67. value
  68. end
  69. end
  70. end
  71. 1 def valid?(value)
  72. !value || allowable_values.include?(value)
  73. end
  74. end
  75. # Attribute mapping from ruby-style variable name to JSON key.
  76. 1 def self.attribute_map
  77. 99 {
  78. :'event_type' => :'eventType',
  79. :'event_time' => :'eventTime',
  80. :'account_id' => :'accountId',
  81. :'application_id' => :'applicationId',
  82. :'from' => :'from',
  83. :'to' => :'to',
  84. :'direction' => :'direction',
  85. :'call_id' => :'callId',
  86. :'call_url' => :'callUrl',
  87. :'parent_call_id' => :'parentCallId',
  88. :'recording_id' => :'recordingId',
  89. :'media_url' => :'mediaUrl',
  90. :'enqueued_time' => :'enqueuedTime',
  91. :'start_time' => :'startTime',
  92. :'end_time' => :'endTime',
  93. :'duration' => :'duration',
  94. :'file_format' => :'fileFormat',
  95. :'channels' => :'channels',
  96. :'tag' => :'tag',
  97. :'status' => :'status',
  98. :'transfer_caller_id' => :'transferCallerId',
  99. :'transfer_to' => :'transferTo'
  100. }
  101. end
  102. # Returns attribute mapping this model knows about
  103. 1 def self.acceptable_attribute_map
  104. 8 attribute_map
  105. end
  106. # Returns all the JSON keys this model knows about
  107. 1 def self.acceptable_attributes
  108. 1 acceptable_attribute_map.values
  109. end
  110. # Attribute type mapping.
  111. 1 def self.openapi_types
  112. 1 {
  113. :'event_type' => :'String',
  114. :'event_time' => :'Time',
  115. :'account_id' => :'String',
  116. :'application_id' => :'String',
  117. :'from' => :'String',
  118. :'to' => :'String',
  119. :'direction' => :'CallDirectionEnum',
  120. :'call_id' => :'String',
  121. :'call_url' => :'String',
  122. :'parent_call_id' => :'String',
  123. :'recording_id' => :'String',
  124. :'media_url' => :'String',
  125. :'enqueued_time' => :'Time',
  126. :'start_time' => :'Time',
  127. :'end_time' => :'Time',
  128. :'duration' => :'String',
  129. :'file_format' => :'FileFormatEnum',
  130. :'channels' => :'Integer',
  131. :'tag' => :'String',
  132. :'status' => :'String',
  133. :'transfer_caller_id' => :'String',
  134. :'transfer_to' => :'String'
  135. }
  136. end
  137. # List of attributes with nullable: true
  138. 1 def self.openapi_nullable
  139. 1 Set.new([
  140. :'media_url',
  141. :'enqueued_time',
  142. :'tag',
  143. ])
  144. end
  145. # Initializes the object
  146. # @param [Hash] attributes Model attributes in the form of hash
  147. 1 def initialize(attributes = {})
  148. 8 if (!attributes.is_a?(Hash))
  149. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RecordingAvailableCallback` initialize method'
  150. end
  151. # check to see if the attribute exists and convert string to symbol for hash key
  152. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  153. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  154. 89 if (!acceptable_attribute_map.key?(k.to_sym))
  155. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RecordingAvailableCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  156. end
  157. 88 h[k.to_sym] = v
  158. }
  159. 6 if attributes.key?(:'event_type')
  160. 4 self.event_type = attributes[:'event_type']
  161. end
  162. 6 if attributes.key?(:'event_time')
  163. 4 self.event_time = attributes[:'event_time']
  164. end
  165. 6 if attributes.key?(:'account_id')
  166. 4 self.account_id = attributes[:'account_id']
  167. end
  168. 6 if attributes.key?(:'application_id')
  169. 4 self.application_id = attributes[:'application_id']
  170. end
  171. 6 if attributes.key?(:'from')
  172. 4 self.from = attributes[:'from']
  173. end
  174. 6 if attributes.key?(:'to')
  175. 4 self.to = attributes[:'to']
  176. end
  177. 6 if attributes.key?(:'direction')
  178. 4 self.direction = attributes[:'direction']
  179. end
  180. 6 if attributes.key?(:'call_id')
  181. 4 self.call_id = attributes[:'call_id']
  182. end
  183. 6 if attributes.key?(:'call_url')
  184. 4 self.call_url = attributes[:'call_url']
  185. end
  186. 6 if attributes.key?(:'parent_call_id')
  187. 4 self.parent_call_id = attributes[:'parent_call_id']
  188. end
  189. 6 if attributes.key?(:'recording_id')
  190. 4 self.recording_id = attributes[:'recording_id']
  191. end
  192. 6 if attributes.key?(:'media_url')
  193. 4 self.media_url = attributes[:'media_url']
  194. end
  195. 6 if attributes.key?(:'enqueued_time')
  196. 4 self.enqueued_time = attributes[:'enqueued_time']
  197. end
  198. 6 if attributes.key?(:'start_time')
  199. 4 self.start_time = attributes[:'start_time']
  200. end
  201. 6 if attributes.key?(:'end_time')
  202. 4 self.end_time = attributes[:'end_time']
  203. end
  204. 6 if attributes.key?(:'duration')
  205. 4 self.duration = attributes[:'duration']
  206. end
  207. 6 if attributes.key?(:'file_format')
  208. 4 self.file_format = attributes[:'file_format']
  209. end
  210. 6 if attributes.key?(:'channels')
  211. 4 self.channels = attributes[:'channels']
  212. end
  213. 6 if attributes.key?(:'tag')
  214. 4 self.tag = attributes[:'tag']
  215. end
  216. 6 if attributes.key?(:'status')
  217. 4 self.status = attributes[:'status']
  218. end
  219. 6 if attributes.key?(:'transfer_caller_id')
  220. 4 self.transfer_caller_id = attributes[:'transfer_caller_id']
  221. end
  222. 6 if attributes.key?(:'transfer_to')
  223. 4 self.transfer_to = attributes[:'transfer_to']
  224. end
  225. end
  226. # Show invalid properties with the reasons. Usually used together with valid?
  227. # @return Array for valid properties with the reasons
  228. 1 def list_invalid_properties
  229. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  230. invalid_properties = Array.new
  231. invalid_properties
  232. end
  233. # Check to see if the all the properties in the model are valid
  234. # @return true if the model is valid
  235. 1 def valid?
  236. warn '[DEPRECATED] the `valid?` method is obsolete'
  237. true
  238. end
  239. # Checks equality by comparing each attribute.
  240. # @param [Object] Object to be compared
  241. 1 def ==(o)
  242. 2 return true if self.equal?(o)
  243. 2 self.class == o.class &&
  244. event_type == o.event_type &&
  245. event_time == o.event_time &&
  246. account_id == o.account_id &&
  247. application_id == o.application_id &&
  248. from == o.from &&
  249. to == o.to &&
  250. direction == o.direction &&
  251. call_id == o.call_id &&
  252. call_url == o.call_url &&
  253. parent_call_id == o.parent_call_id &&
  254. recording_id == o.recording_id &&
  255. media_url == o.media_url &&
  256. enqueued_time == o.enqueued_time &&
  257. start_time == o.start_time &&
  258. end_time == o.end_time &&
  259. duration == o.duration &&
  260. file_format == o.file_format &&
  261. channels == o.channels &&
  262. tag == o.tag &&
  263. status == o.status &&
  264. transfer_caller_id == o.transfer_caller_id &&
  265. transfer_to == o.transfer_to
  266. end
  267. # @see the `==` method
  268. # @param [Object] Object to be compared
  269. 1 def eql?(o)
  270. 2 self == o
  271. end
  272. # Calculates hash code according to all attributes.
  273. # @return [Integer] Hash code
  274. 1 def hash
  275. [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, parent_call_id, recording_id, media_url, enqueued_time, start_time, end_time, duration, file_format, channels, tag, status, transfer_caller_id, transfer_to].hash
  276. end
  277. # Builds the object from hash
  278. # @param [Hash] attributes Model attributes in the form of hash
  279. # @return [Object] Returns the model itself
  280. 1 def self.build_from_hash(attributes)
  281. 1 return nil unless attributes.is_a?(Hash)
  282. 1 attributes = attributes.transform_keys(&:to_sym)
  283. 1 transformed_hash = {}
  284. 1 openapi_types.each_pair do |key, type|
  285. 22 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  286. transformed_hash["#{key}"] = nil
  287. 22 elsif type =~ /\AArray<(.*)>/i
  288. # check to ensure the input is an array given that the attribute
  289. # is documented as an array but the input is not
  290. if attributes[attribute_map[key]].is_a?(Array)
  291. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  292. end
  293. 22 elsif !attributes[attribute_map[key]].nil?
  294. 22 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  295. end
  296. end
  297. 1 new(transformed_hash)
  298. end
  299. # Returns the object in the form of hash
  300. # @return [Hash] Returns the object in the form of hash
  301. 1 def to_hash
  302. 2 hash = {}
  303. 2 self.class.attribute_map.each_pair do |attr, param|
  304. 44 value = self.send(attr)
  305. 44 if value.nil?
  306. is_nullable = self.class.openapi_nullable.include?(attr)
  307. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  308. end
  309. 44 hash[param] = _to_hash(value)
  310. end
  311. 2 hash
  312. end
  313. end
  314. end

lib/bandwidth-sdk/models/recording_complete_callback.rb

87.41% lines covered

135 relevant lines. 118 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The Record Complete event is sent after a <Record> verb has executed if the call is still active. The BXML returned by this callback is executed next. When the recording is available for download, a Recording Available event will be sent.
  13. 1 class RecordingCompleteCallback < ApiModelBase
  14. # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect.
  15. 1 attr_accessor :event_type
  16. # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.
  17. 1 attr_accessor :event_time
  18. # The user account associated with the call.
  19. 1 attr_accessor :account_id
  20. # The id of the application associated with the call.
  21. 1 attr_accessor :application_id
  22. # The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555).
  23. 1 attr_accessor :from
  24. # The phone number that received the call, in E.164 format (e.g. +15555555555).
  25. 1 attr_accessor :to
  26. 1 attr_accessor :direction
  27. # The call id associated with the event.
  28. 1 attr_accessor :call_id
  29. # The URL of the call associated with the event.
  30. 1 attr_accessor :call_url
  31. # (optional) If the event is related to the B leg of a <Transfer>, the call id of the original call leg that executed the <Transfer>. Otherwise, this field will not be present.
  32. 1 attr_accessor :parent_call_id
  33. # The unique ID of this recording
  34. 1 attr_accessor :recording_id
  35. # The URL that can be used to download the recording. Only present if the recording is finished and may be downloaded.
  36. 1 attr_accessor :media_url
  37. # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format.
  38. 1 attr_accessor :enqueued_time
  39. # Time the call was started, in ISO 8601 format.
  40. 1 attr_accessor :start_time
  41. # Time the call was answered, in ISO 8601 format.
  42. 1 attr_accessor :answer_time
  43. # The time that the recording ended in ISO-8601 format
  44. 1 attr_accessor :end_time
  45. # The duration of the recording in ISO-8601 format
  46. 1 attr_accessor :duration
  47. 1 attr_accessor :file_format
  48. # Always `1` for conference recordings; multi-channel recordings are not supported on conferences.
  49. 1 attr_accessor :channels
  50. # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.
  51. 1 attr_accessor :tag
  52. # The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555).
  53. 1 attr_accessor :transfer_caller_id
  54. # The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555).
  55. 1 attr_accessor :transfer_to
  56. 1 class EnumAttributeValidator
  57. 1 attr_reader :datatype
  58. 1 attr_reader :allowable_values
  59. 1 def initialize(datatype, allowable_values)
  60. @allowable_values = allowable_values.map do |value|
  61. case datatype.to_s
  62. when /Integer/i
  63. value.to_i
  64. when /Float/i
  65. value.to_f
  66. else
  67. value
  68. end
  69. end
  70. end
  71. 1 def valid?(value)
  72. !value || allowable_values.include?(value)
  73. end
  74. end
  75. # Attribute mapping from ruby-style variable name to JSON key.
  76. 1 def self.attribute_map
  77. 99 {
  78. :'event_type' => :'eventType',
  79. :'event_time' => :'eventTime',
  80. :'account_id' => :'accountId',
  81. :'application_id' => :'applicationId',
  82. :'from' => :'from',
  83. :'to' => :'to',
  84. :'direction' => :'direction',
  85. :'call_id' => :'callId',
  86. :'call_url' => :'callUrl',
  87. :'parent_call_id' => :'parentCallId',
  88. :'recording_id' => :'recordingId',
  89. :'media_url' => :'mediaUrl',
  90. :'enqueued_time' => :'enqueuedTime',
  91. :'start_time' => :'startTime',
  92. :'answer_time' => :'answerTime',
  93. :'end_time' => :'endTime',
  94. :'duration' => :'duration',
  95. :'file_format' => :'fileFormat',
  96. :'channels' => :'channels',
  97. :'tag' => :'tag',
  98. :'transfer_caller_id' => :'transferCallerId',
  99. :'transfer_to' => :'transferTo'
  100. }
  101. end
  102. # Returns attribute mapping this model knows about
  103. 1 def self.acceptable_attribute_map
  104. 8 attribute_map
  105. end
  106. # Returns all the JSON keys this model knows about
  107. 1 def self.acceptable_attributes
  108. 1 acceptable_attribute_map.values
  109. end
  110. # Attribute type mapping.
  111. 1 def self.openapi_types
  112. 1 {
  113. :'event_type' => :'String',
  114. :'event_time' => :'Time',
  115. :'account_id' => :'String',
  116. :'application_id' => :'String',
  117. :'from' => :'String',
  118. :'to' => :'String',
  119. :'direction' => :'CallDirectionEnum',
  120. :'call_id' => :'String',
  121. :'call_url' => :'String',
  122. :'parent_call_id' => :'String',
  123. :'recording_id' => :'String',
  124. :'media_url' => :'String',
  125. :'enqueued_time' => :'Time',
  126. :'start_time' => :'Time',
  127. :'answer_time' => :'Time',
  128. :'end_time' => :'Time',
  129. :'duration' => :'String',
  130. :'file_format' => :'FileFormatEnum',
  131. :'channels' => :'Integer',
  132. :'tag' => :'String',
  133. :'transfer_caller_id' => :'String',
  134. :'transfer_to' => :'String'
  135. }
  136. end
  137. # List of attributes with nullable: true
  138. 1 def self.openapi_nullable
  139. 1 Set.new([
  140. :'media_url',
  141. :'enqueued_time',
  142. :'answer_time',
  143. :'tag',
  144. ])
  145. end
  146. # Initializes the object
  147. # @param [Hash] attributes Model attributes in the form of hash
  148. 1 def initialize(attributes = {})
  149. 8 if (!attributes.is_a?(Hash))
  150. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RecordingCompleteCallback` initialize method'
  151. end
  152. # check to see if the attribute exists and convert string to symbol for hash key
  153. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  154. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  155. 89 if (!acceptable_attribute_map.key?(k.to_sym))
  156. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RecordingCompleteCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  157. end
  158. 88 h[k.to_sym] = v
  159. }
  160. 6 if attributes.key?(:'event_type')
  161. 4 self.event_type = attributes[:'event_type']
  162. end
  163. 6 if attributes.key?(:'event_time')
  164. 4 self.event_time = attributes[:'event_time']
  165. end
  166. 6 if attributes.key?(:'account_id')
  167. 4 self.account_id = attributes[:'account_id']
  168. end
  169. 6 if attributes.key?(:'application_id')
  170. 4 self.application_id = attributes[:'application_id']
  171. end
  172. 6 if attributes.key?(:'from')
  173. 4 self.from = attributes[:'from']
  174. end
  175. 6 if attributes.key?(:'to')
  176. 4 self.to = attributes[:'to']
  177. end
  178. 6 if attributes.key?(:'direction')
  179. 4 self.direction = attributes[:'direction']
  180. end
  181. 6 if attributes.key?(:'call_id')
  182. 4 self.call_id = attributes[:'call_id']
  183. end
  184. 6 if attributes.key?(:'call_url')
  185. 4 self.call_url = attributes[:'call_url']
  186. end
  187. 6 if attributes.key?(:'parent_call_id')
  188. 4 self.parent_call_id = attributes[:'parent_call_id']
  189. end
  190. 6 if attributes.key?(:'recording_id')
  191. 4 self.recording_id = attributes[:'recording_id']
  192. end
  193. 6 if attributes.key?(:'media_url')
  194. 4 self.media_url = attributes[:'media_url']
  195. end
  196. 6 if attributes.key?(:'enqueued_time')
  197. 4 self.enqueued_time = attributes[:'enqueued_time']
  198. end
  199. 6 if attributes.key?(:'start_time')
  200. 4 self.start_time = attributes[:'start_time']
  201. end
  202. 6 if attributes.key?(:'answer_time')
  203. 4 self.answer_time = attributes[:'answer_time']
  204. end
  205. 6 if attributes.key?(:'end_time')
  206. 4 self.end_time = attributes[:'end_time']
  207. end
  208. 6 if attributes.key?(:'duration')
  209. 4 self.duration = attributes[:'duration']
  210. end
  211. 6 if attributes.key?(:'file_format')
  212. 4 self.file_format = attributes[:'file_format']
  213. end
  214. 6 if attributes.key?(:'channels')
  215. 4 self.channels = attributes[:'channels']
  216. end
  217. 6 if attributes.key?(:'tag')
  218. 4 self.tag = attributes[:'tag']
  219. end
  220. 6 if attributes.key?(:'transfer_caller_id')
  221. 4 self.transfer_caller_id = attributes[:'transfer_caller_id']
  222. end
  223. 6 if attributes.key?(:'transfer_to')
  224. 4 self.transfer_to = attributes[:'transfer_to']
  225. end
  226. end
  227. # Show invalid properties with the reasons. Usually used together with valid?
  228. # @return Array for valid properties with the reasons
  229. 1 def list_invalid_properties
  230. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  231. invalid_properties = Array.new
  232. invalid_properties
  233. end
  234. # Check to see if the all the properties in the model are valid
  235. # @return true if the model is valid
  236. 1 def valid?
  237. warn '[DEPRECATED] the `valid?` method is obsolete'
  238. true
  239. end
  240. # Checks equality by comparing each attribute.
  241. # @param [Object] Object to be compared
  242. 1 def ==(o)
  243. 2 return true if self.equal?(o)
  244. 2 self.class == o.class &&
  245. event_type == o.event_type &&
  246. event_time == o.event_time &&
  247. account_id == o.account_id &&
  248. application_id == o.application_id &&
  249. from == o.from &&
  250. to == o.to &&
  251. direction == o.direction &&
  252. call_id == o.call_id &&
  253. call_url == o.call_url &&
  254. parent_call_id == o.parent_call_id &&
  255. recording_id == o.recording_id &&
  256. media_url == o.media_url &&
  257. enqueued_time == o.enqueued_time &&
  258. start_time == o.start_time &&
  259. answer_time == o.answer_time &&
  260. end_time == o.end_time &&
  261. duration == o.duration &&
  262. file_format == o.file_format &&
  263. channels == o.channels &&
  264. tag == o.tag &&
  265. transfer_caller_id == o.transfer_caller_id &&
  266. transfer_to == o.transfer_to
  267. end
  268. # @see the `==` method
  269. # @param [Object] Object to be compared
  270. 1 def eql?(o)
  271. 2 self == o
  272. end
  273. # Calculates hash code according to all attributes.
  274. # @return [Integer] Hash code
  275. 1 def hash
  276. [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, parent_call_id, recording_id, media_url, enqueued_time, start_time, answer_time, end_time, duration, file_format, channels, tag, transfer_caller_id, transfer_to].hash
  277. end
  278. # Builds the object from hash
  279. # @param [Hash] attributes Model attributes in the form of hash
  280. # @return [Object] Returns the model itself
  281. 1 def self.build_from_hash(attributes)
  282. 1 return nil unless attributes.is_a?(Hash)
  283. 1 attributes = attributes.transform_keys(&:to_sym)
  284. 1 transformed_hash = {}
  285. 1 openapi_types.each_pair do |key, type|
  286. 22 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  287. transformed_hash["#{key}"] = nil
  288. 22 elsif type =~ /\AArray<(.*)>/i
  289. # check to ensure the input is an array given that the attribute
  290. # is documented as an array but the input is not
  291. if attributes[attribute_map[key]].is_a?(Array)
  292. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  293. end
  294. 22 elsif !attributes[attribute_map[key]].nil?
  295. 22 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  296. end
  297. end
  298. 1 new(transformed_hash)
  299. end
  300. # Returns the object in the form of hash
  301. # @return [Hash] Returns the object in the form of hash
  302. 1 def to_hash
  303. 2 hash = {}
  304. 2 self.class.attribute_map.each_pair do |attr, param|
  305. 44 value = self.send(attr)
  306. 44 if value.nil?
  307. is_nullable = self.class.openapi_nullable.include?(attr)
  308. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  309. end
  310. 44 hash[param] = _to_hash(value)
  311. end
  312. 2 hash
  313. end
  314. end
  315. end

lib/bandwidth-sdk/models/recording_state_enum.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class RecordingStateEnum
  13. 1 PAUSED = 'paused'.freeze
  14. 1 RECORDING = 'recording'.freeze
  15. 1 def self.all_vars
  16. 5 @all_vars ||= [PAUSED, RECORDING].freeze
  17. end
  18. # Builds the enum from string
  19. # @param [String] The enum value in the form of the string
  20. # @return [String] The enum value
  21. 1 def self.build_from_hash(value)
  22. 4 new.build_from_hash(value)
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def build_from_hash(value)
  28. 4 return value if RecordingStateEnum.all_vars.include?(value)
  29. 1 raise "Invalid ENUM value #{value} for class #RecordingStateEnum"
  30. end
  31. end
  32. end

lib/bandwidth-sdk/models/recording_transcription_metadata.rb

84.29% lines covered

70 relevant lines. 59 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # If the recording was transcribed, metadata about the transcription
  13. 1 class RecordingTranscriptionMetadata < ApiModelBase
  14. # The unique transcription ID
  15. 1 attr_accessor :id
  16. # The current status of the process. For recording, current possible values are 'processing', 'partial', 'complete', 'deleted', and 'error'. For transcriptions, current possible values are 'none', 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and 'file-size-too-small'. Additional states may be added in the future, so your application must be tolerant of unknown values.
  17. 1 attr_accessor :status
  18. # The time that the transcription was completed
  19. 1 attr_accessor :completed_time
  20. # The URL of the [transcription](#operation/getCallTranscription)
  21. 1 attr_accessor :url
  22. # Attribute mapping from ruby-style variable name to JSON key.
  23. 1 def self.attribute_map
  24. 61 {
  25. :'id' => :'id',
  26. :'status' => :'status',
  27. :'completed_time' => :'completedTime',
  28. :'url' => :'url'
  29. }
  30. end
  31. # Returns attribute mapping this model knows about
  32. 1 def self.acceptable_attribute_map
  33. 10 attribute_map
  34. end
  35. # Returns all the JSON keys this model knows about
  36. 1 def self.acceptable_attributes
  37. 1 acceptable_attribute_map.values
  38. end
  39. # Attribute type mapping.
  40. 1 def self.openapi_types
  41. 3 {
  42. :'id' => :'String',
  43. :'status' => :'String',
  44. :'completed_time' => :'Time',
  45. :'url' => :'String'
  46. }
  47. end
  48. # List of attributes with nullable: true
  49. 1 def self.openapi_nullable
  50. 1 Set.new([
  51. ])
  52. end
  53. # Initializes the object
  54. # @param [Hash] attributes Model attributes in the form of hash
  55. 1 def initialize(attributes = {})
  56. 10 if (!attributes.is_a?(Hash))
  57. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RecordingTranscriptionMetadata` initialize method'
  58. end
  59. # check to see if the attribute exists and convert string to symbol for hash key
  60. 9 acceptable_attribute_map = self.class.acceptable_attribute_map
  61. 9 attributes = attributes.each_with_object({}) { |(k, v), h|
  62. 25 if (!acceptable_attribute_map.key?(k.to_sym))
  63. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RecordingTranscriptionMetadata`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  64. end
  65. 24 h[k.to_sym] = v
  66. }
  67. 8 if attributes.key?(:'id')
  68. 6 self.id = attributes[:'id']
  69. end
  70. 8 if attributes.key?(:'status')
  71. 6 self.status = attributes[:'status']
  72. end
  73. 8 if attributes.key?(:'completed_time')
  74. 6 self.completed_time = attributes[:'completed_time']
  75. end
  76. 8 if attributes.key?(:'url')
  77. 6 self.url = attributes[:'url']
  78. end
  79. end
  80. # Show invalid properties with the reasons. Usually used together with valid?
  81. # @return Array for valid properties with the reasons
  82. 1 def list_invalid_properties
  83. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  84. invalid_properties = Array.new
  85. invalid_properties
  86. end
  87. # Check to see if the all the properties in the model are valid
  88. # @return true if the model is valid
  89. 1 def valid?
  90. warn '[DEPRECATED] the `valid?` method is obsolete'
  91. true
  92. end
  93. # Checks equality by comparing each attribute.
  94. # @param [Object] Object to be compared
  95. 1 def ==(o)
  96. 2 return true if self.equal?(o)
  97. 2 self.class == o.class &&
  98. id == o.id &&
  99. status == o.status &&
  100. completed_time == o.completed_time &&
  101. url == o.url
  102. end
  103. # @see the `==` method
  104. # @param [Object] Object to be compared
  105. 1 def eql?(o)
  106. 2 self == o
  107. end
  108. # Calculates hash code according to all attributes.
  109. # @return [Integer] Hash code
  110. 1 def hash
  111. [id, status, completed_time, url].hash
  112. end
  113. # Builds the object from hash
  114. # @param [Hash] attributes Model attributes in the form of hash
  115. # @return [Object] Returns the model itself
  116. 1 def self.build_from_hash(attributes)
  117. 3 return nil unless attributes.is_a?(Hash)
  118. 3 attributes = attributes.transform_keys(&:to_sym)
  119. 3 transformed_hash = {}
  120. 3 openapi_types.each_pair do |key, type|
  121. 12 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  122. transformed_hash["#{key}"] = nil
  123. 12 elsif type =~ /\AArray<(.*)>/i
  124. # check to ensure the input is an array given that the attribute
  125. # is documented as an array but the input is not
  126. if attributes[attribute_map[key]].is_a?(Array)
  127. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  128. end
  129. 12 elsif !attributes[attribute_map[key]].nil?
  130. 12 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  131. end
  132. end
  133. 3 new(transformed_hash)
  134. end
  135. # Returns the object in the form of hash
  136. # @return [Hash] Returns the object in the form of hash
  137. 1 def to_hash
  138. 2 hash = {}
  139. 2 self.class.attribute_map.each_pair do |attr, param|
  140. 8 value = self.send(attr)
  141. 8 if value.nil?
  142. is_nullable = self.class.openapi_nullable.include?(attr)
  143. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  144. end
  145. 8 hash[param] = _to_hash(value)
  146. end
  147. 2 hash
  148. end
  149. end
  150. end

lib/bandwidth-sdk/models/recording_transcriptions.rb

82.26% lines covered

62 relevant lines. 51 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class RecordingTranscriptions < ApiModelBase
  13. 1 attr_accessor :transcripts
  14. # Attribute mapping from ruby-style variable name to JSON key.
  15. 1 def self.attribute_map
  16. 20 {
  17. :'transcripts' => :'transcripts'
  18. }
  19. end
  20. # Returns attribute mapping this model knows about
  21. 1 def self.acceptable_attribute_map
  22. 9 attribute_map
  23. end
  24. # Returns all the JSON keys this model knows about
  25. 1 def self.acceptable_attributes
  26. 1 acceptable_attribute_map.values
  27. end
  28. # Attribute type mapping.
  29. 1 def self.openapi_types
  30. 2 {
  31. :'transcripts' => :'Array<Transcription>'
  32. }
  33. end
  34. # List of attributes with nullable: true
  35. 1 def self.openapi_nullable
  36. 1 Set.new([
  37. ])
  38. end
  39. # Initializes the object
  40. # @param [Hash] attributes Model attributes in the form of hash
  41. 1 def initialize(attributes = {})
  42. 9 if (!attributes.is_a?(Hash))
  43. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RecordingTranscriptions` initialize method'
  44. end
  45. # check to see if the attribute exists and convert string to symbol for hash key
  46. 8 acceptable_attribute_map = self.class.acceptable_attribute_map
  47. 8 attributes = attributes.each_with_object({}) { |(k, v), h|
  48. 6 if (!acceptable_attribute_map.key?(k.to_sym))
  49. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RecordingTranscriptions`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  50. end
  51. 5 h[k.to_sym] = v
  52. }
  53. 7 if attributes.key?(:'transcripts')
  54. 5 if (value = attributes[:'transcripts']).is_a?(Array)
  55. 5 self.transcripts = value
  56. end
  57. end
  58. end
  59. # Show invalid properties with the reasons. Usually used together with valid?
  60. # @return Array for valid properties with the reasons
  61. 1 def list_invalid_properties
  62. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  63. invalid_properties = Array.new
  64. invalid_properties
  65. end
  66. # Check to see if the all the properties in the model are valid
  67. # @return true if the model is valid
  68. 1 def valid?
  69. warn '[DEPRECATED] the `valid?` method is obsolete'
  70. true
  71. end
  72. # Checks equality by comparing each attribute.
  73. # @param [Object] Object to be compared
  74. 1 def ==(o)
  75. 2 return true if self.equal?(o)
  76. 2 self.class == o.class &&
  77. transcripts == o.transcripts
  78. end
  79. # @see the `==` method
  80. # @param [Object] Object to be compared
  81. 1 def eql?(o)
  82. 2 self == o
  83. end
  84. # Calculates hash code according to all attributes.
  85. # @return [Integer] Hash code
  86. 1 def hash
  87. [transcripts].hash
  88. end
  89. # Builds the object from hash
  90. # @param [Hash] attributes Model attributes in the form of hash
  91. # @return [Object] Returns the model itself
  92. 1 def self.build_from_hash(attributes)
  93. 2 return nil unless attributes.is_a?(Hash)
  94. 2 attributes = attributes.transform_keys(&:to_sym)
  95. 2 transformed_hash = {}
  96. 2 openapi_types.each_pair do |key, type|
  97. 2 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  98. transformed_hash["#{key}"] = nil
  99. 2 elsif type =~ /\AArray<(.*)>/i
  100. # check to ensure the input is an array given that the attribute
  101. # is documented as an array but the input is not
  102. 2 if attributes[attribute_map[key]].is_a?(Array)
  103. 4 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  104. end
  105. elsif !attributes[attribute_map[key]].nil?
  106. transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  107. end
  108. end
  109. 2 new(transformed_hash)
  110. end
  111. # Returns the object in the form of hash
  112. # @return [Hash] Returns the object in the form of hash
  113. 1 def to_hash
  114. 2 hash = {}
  115. 2 self.class.attribute_map.each_pair do |attr, param|
  116. 2 value = self.send(attr)
  117. 2 if value.nil?
  118. is_nullable = self.class.openapi_nullable.include?(attr)
  119. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  120. end
  121. 2 hash[param] = _to_hash(value)
  122. end
  123. 2 hash
  124. end
  125. end
  126. end

lib/bandwidth-sdk/models/redirect_callback.rb

85.47% lines covered

117 relevant lines. 100 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The Redirect event is fired when a <Redirect> verb is executed. Its purpose is to get the next set of verbs from the calling application.
  13. 1 class RedirectCallback < ApiModelBase
  14. # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect.
  15. 1 attr_accessor :event_type
  16. # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.
  17. 1 attr_accessor :event_time
  18. # The user account associated with the call.
  19. 1 attr_accessor :account_id
  20. # The id of the application associated with the call.
  21. 1 attr_accessor :application_id
  22. # The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555).
  23. 1 attr_accessor :from
  24. # The phone number that received the call, in E.164 format (e.g. +15555555555).
  25. 1 attr_accessor :to
  26. 1 attr_accessor :direction
  27. # The call id associated with the event.
  28. 1 attr_accessor :call_id
  29. # The URL of the call associated with the event.
  30. 1 attr_accessor :call_url
  31. # (optional) If the event is related to the B leg of a <Transfer>, the call id of the original call leg that executed the <Transfer>. Otherwise, this field will not be present.
  32. 1 attr_accessor :parent_call_id
  33. # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format.
  34. 1 attr_accessor :enqueued_time
  35. # Time the call was started, in ISO 8601 format.
  36. 1 attr_accessor :start_time
  37. # Time the call was answered, in ISO 8601 format.
  38. 1 attr_accessor :answer_time
  39. # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.
  40. 1 attr_accessor :tag
  41. # The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555).
  42. 1 attr_accessor :transfer_caller_id
  43. # The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555).
  44. 1 attr_accessor :transfer_to
  45. 1 class EnumAttributeValidator
  46. 1 attr_reader :datatype
  47. 1 attr_reader :allowable_values
  48. 1 def initialize(datatype, allowable_values)
  49. @allowable_values = allowable_values.map do |value|
  50. case datatype.to_s
  51. when /Integer/i
  52. value.to_i
  53. when /Float/i
  54. value.to_f
  55. else
  56. value
  57. end
  58. end
  59. end
  60. 1 def valid?(value)
  61. !value || allowable_values.include?(value)
  62. end
  63. end
  64. # Attribute mapping from ruby-style variable name to JSON key.
  65. 1 def self.attribute_map
  66. 75 {
  67. :'event_type' => :'eventType',
  68. :'event_time' => :'eventTime',
  69. :'account_id' => :'accountId',
  70. :'application_id' => :'applicationId',
  71. :'from' => :'from',
  72. :'to' => :'to',
  73. :'direction' => :'direction',
  74. :'call_id' => :'callId',
  75. :'call_url' => :'callUrl',
  76. :'parent_call_id' => :'parentCallId',
  77. :'enqueued_time' => :'enqueuedTime',
  78. :'start_time' => :'startTime',
  79. :'answer_time' => :'answerTime',
  80. :'tag' => :'tag',
  81. :'transfer_caller_id' => :'transferCallerId',
  82. :'transfer_to' => :'transferTo'
  83. }
  84. end
  85. # Returns attribute mapping this model knows about
  86. 1 def self.acceptable_attribute_map
  87. 8 attribute_map
  88. end
  89. # Returns all the JSON keys this model knows about
  90. 1 def self.acceptable_attributes
  91. 1 acceptable_attribute_map.values
  92. end
  93. # Attribute type mapping.
  94. 1 def self.openapi_types
  95. 1 {
  96. :'event_type' => :'String',
  97. :'event_time' => :'Time',
  98. :'account_id' => :'String',
  99. :'application_id' => :'String',
  100. :'from' => :'String',
  101. :'to' => :'String',
  102. :'direction' => :'CallDirectionEnum',
  103. :'call_id' => :'String',
  104. :'call_url' => :'String',
  105. :'parent_call_id' => :'String',
  106. :'enqueued_time' => :'Time',
  107. :'start_time' => :'Time',
  108. :'answer_time' => :'Time',
  109. :'tag' => :'String',
  110. :'transfer_caller_id' => :'String',
  111. :'transfer_to' => :'String'
  112. }
  113. end
  114. # List of attributes with nullable: true
  115. 1 def self.openapi_nullable
  116. 1 Set.new([
  117. :'enqueued_time',
  118. :'answer_time',
  119. :'tag',
  120. ])
  121. end
  122. # Initializes the object
  123. # @param [Hash] attributes Model attributes in the form of hash
  124. 1 def initialize(attributes = {})
  125. 8 if (!attributes.is_a?(Hash))
  126. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RedirectCallback` initialize method'
  127. end
  128. # check to see if the attribute exists and convert string to symbol for hash key
  129. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  130. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  131. 65 if (!acceptable_attribute_map.key?(k.to_sym))
  132. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RedirectCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  133. end
  134. 64 h[k.to_sym] = v
  135. }
  136. 6 if attributes.key?(:'event_type')
  137. 4 self.event_type = attributes[:'event_type']
  138. end
  139. 6 if attributes.key?(:'event_time')
  140. 4 self.event_time = attributes[:'event_time']
  141. end
  142. 6 if attributes.key?(:'account_id')
  143. 4 self.account_id = attributes[:'account_id']
  144. end
  145. 6 if attributes.key?(:'application_id')
  146. 4 self.application_id = attributes[:'application_id']
  147. end
  148. 6 if attributes.key?(:'from')
  149. 4 self.from = attributes[:'from']
  150. end
  151. 6 if attributes.key?(:'to')
  152. 4 self.to = attributes[:'to']
  153. end
  154. 6 if attributes.key?(:'direction')
  155. 4 self.direction = attributes[:'direction']
  156. end
  157. 6 if attributes.key?(:'call_id')
  158. 4 self.call_id = attributes[:'call_id']
  159. end
  160. 6 if attributes.key?(:'call_url')
  161. 4 self.call_url = attributes[:'call_url']
  162. end
  163. 6 if attributes.key?(:'parent_call_id')
  164. 4 self.parent_call_id = attributes[:'parent_call_id']
  165. end
  166. 6 if attributes.key?(:'enqueued_time')
  167. 4 self.enqueued_time = attributes[:'enqueued_time']
  168. end
  169. 6 if attributes.key?(:'start_time')
  170. 4 self.start_time = attributes[:'start_time']
  171. end
  172. 6 if attributes.key?(:'answer_time')
  173. 4 self.answer_time = attributes[:'answer_time']
  174. end
  175. 6 if attributes.key?(:'tag')
  176. 4 self.tag = attributes[:'tag']
  177. end
  178. 6 if attributes.key?(:'transfer_caller_id')
  179. 4 self.transfer_caller_id = attributes[:'transfer_caller_id']
  180. end
  181. 6 if attributes.key?(:'transfer_to')
  182. 4 self.transfer_to = attributes[:'transfer_to']
  183. end
  184. end
  185. # Show invalid properties with the reasons. Usually used together with valid?
  186. # @return Array for valid properties with the reasons
  187. 1 def list_invalid_properties
  188. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  189. invalid_properties = Array.new
  190. invalid_properties
  191. end
  192. # Check to see if the all the properties in the model are valid
  193. # @return true if the model is valid
  194. 1 def valid?
  195. warn '[DEPRECATED] the `valid?` method is obsolete'
  196. true
  197. end
  198. # Checks equality by comparing each attribute.
  199. # @param [Object] Object to be compared
  200. 1 def ==(o)
  201. 2 return true if self.equal?(o)
  202. 2 self.class == o.class &&
  203. event_type == o.event_type &&
  204. event_time == o.event_time &&
  205. account_id == o.account_id &&
  206. application_id == o.application_id &&
  207. from == o.from &&
  208. to == o.to &&
  209. direction == o.direction &&
  210. call_id == o.call_id &&
  211. call_url == o.call_url &&
  212. parent_call_id == o.parent_call_id &&
  213. enqueued_time == o.enqueued_time &&
  214. start_time == o.start_time &&
  215. answer_time == o.answer_time &&
  216. tag == o.tag &&
  217. transfer_caller_id == o.transfer_caller_id &&
  218. transfer_to == o.transfer_to
  219. end
  220. # @see the `==` method
  221. # @param [Object] Object to be compared
  222. 1 def eql?(o)
  223. 2 self == o
  224. end
  225. # Calculates hash code according to all attributes.
  226. # @return [Integer] Hash code
  227. 1 def hash
  228. [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, parent_call_id, enqueued_time, start_time, answer_time, tag, transfer_caller_id, transfer_to].hash
  229. end
  230. # Builds the object from hash
  231. # @param [Hash] attributes Model attributes in the form of hash
  232. # @return [Object] Returns the model itself
  233. 1 def self.build_from_hash(attributes)
  234. 1 return nil unless attributes.is_a?(Hash)
  235. 1 attributes = attributes.transform_keys(&:to_sym)
  236. 1 transformed_hash = {}
  237. 1 openapi_types.each_pair do |key, type|
  238. 16 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  239. transformed_hash["#{key}"] = nil
  240. 16 elsif type =~ /\AArray<(.*)>/i
  241. # check to ensure the input is an array given that the attribute
  242. # is documented as an array but the input is not
  243. if attributes[attribute_map[key]].is_a?(Array)
  244. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  245. end
  246. 16 elsif !attributes[attribute_map[key]].nil?
  247. 16 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  248. end
  249. end
  250. 1 new(transformed_hash)
  251. end
  252. # Returns the object in the form of hash
  253. # @return [Hash] Returns the object in the form of hash
  254. 1 def to_hash
  255. 2 hash = {}
  256. 2 self.class.attribute_map.each_pair do |attr, param|
  257. 32 value = self.send(attr)
  258. 32 if value.nil?
  259. is_nullable = self.class.openapi_nullable.include?(attr)
  260. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  261. end
  262. 32 hash[param] = _to_hash(value)
  263. end
  264. 2 hash
  265. end
  266. end
  267. end

lib/bandwidth-sdk/models/redirect_method_enum.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class RedirectMethodEnum
  13. 1 GET = 'GET'.freeze
  14. 1 POST = 'POST'.freeze
  15. 1 def self.all_vars
  16. 8 @all_vars ||= [GET, POST].freeze
  17. end
  18. # Builds the enum from string
  19. # @param [String] The enum value in the form of the string
  20. # @return [String] The enum value
  21. 1 def self.build_from_hash(value)
  22. 7 new.build_from_hash(value)
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def build_from_hash(value)
  28. 7 return value if RedirectMethodEnum.all_vars.include?(value)
  29. 1 raise "Invalid ENUM value #{value} for class #RedirectMethodEnum"
  30. end
  31. end
  32. end

lib/bandwidth-sdk/models/sip_connection_metadata.rb

84.29% lines covered

70 relevant lines. 59 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class SipConnectionMetadata < ApiModelBase
  13. # The IP address of the SIP connection.
  14. 1 attr_accessor :ip_address
  15. # The port of the SIP connection.
  16. 1 attr_accessor :port
  17. 1 attr_accessor :credentials
  18. # The User-to-User Information header for the SIP connection.
  19. 1 attr_accessor :uui_header
  20. # Attribute mapping from ruby-style variable name to JSON key.
  21. 1 def self.attribute_map
  22. 27 {
  23. :'ip_address' => :'ipAddress',
  24. :'port' => :'port',
  25. :'credentials' => :'credentials',
  26. :'uui_header' => :'uuiHeader'
  27. }
  28. end
  29. # Returns attribute mapping this model knows about
  30. 1 def self.acceptable_attribute_map
  31. 8 attribute_map
  32. end
  33. # Returns all the JSON keys this model knows about
  34. 1 def self.acceptable_attributes
  35. 1 acceptable_attribute_map.values
  36. end
  37. # Attribute type mapping.
  38. 1 def self.openapi_types
  39. 1 {
  40. :'ip_address' => :'String',
  41. :'port' => :'Integer',
  42. :'credentials' => :'SipCredentials',
  43. :'uui_header' => :'String'
  44. }
  45. end
  46. # List of attributes with nullable: true
  47. 1 def self.openapi_nullable
  48. 1 Set.new([
  49. ])
  50. end
  51. # Initializes the object
  52. # @param [Hash] attributes Model attributes in the form of hash
  53. 1 def initialize(attributes = {})
  54. 8 if (!attributes.is_a?(Hash))
  55. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::SipConnectionMetadata` initialize method'
  56. end
  57. # check to see if the attribute exists and convert string to symbol for hash key
  58. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  59. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  60. 17 if (!acceptable_attribute_map.key?(k.to_sym))
  61. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::SipConnectionMetadata`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  62. end
  63. 16 h[k.to_sym] = v
  64. }
  65. 6 if attributes.key?(:'ip_address')
  66. 4 self.ip_address = attributes[:'ip_address']
  67. end
  68. 6 if attributes.key?(:'port')
  69. 4 self.port = attributes[:'port']
  70. end
  71. 6 if attributes.key?(:'credentials')
  72. 4 self.credentials = attributes[:'credentials']
  73. end
  74. 6 if attributes.key?(:'uui_header')
  75. 4 self.uui_header = attributes[:'uui_header']
  76. end
  77. end
  78. # Show invalid properties with the reasons. Usually used together with valid?
  79. # @return Array for valid properties with the reasons
  80. 1 def list_invalid_properties
  81. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  82. invalid_properties = Array.new
  83. invalid_properties
  84. end
  85. # Check to see if the all the properties in the model are valid
  86. # @return true if the model is valid
  87. 1 def valid?
  88. warn '[DEPRECATED] the `valid?` method is obsolete'
  89. true
  90. end
  91. # Checks equality by comparing each attribute.
  92. # @param [Object] Object to be compared
  93. 1 def ==(o)
  94. 2 return true if self.equal?(o)
  95. 2 self.class == o.class &&
  96. ip_address == o.ip_address &&
  97. port == o.port &&
  98. credentials == o.credentials &&
  99. uui_header == o.uui_header
  100. end
  101. # @see the `==` method
  102. # @param [Object] Object to be compared
  103. 1 def eql?(o)
  104. 2 self == o
  105. end
  106. # Calculates hash code according to all attributes.
  107. # @return [Integer] Hash code
  108. 1 def hash
  109. [ip_address, port, credentials, uui_header].hash
  110. end
  111. # Builds the object from hash
  112. # @param [Hash] attributes Model attributes in the form of hash
  113. # @return [Object] Returns the model itself
  114. 1 def self.build_from_hash(attributes)
  115. 1 return nil unless attributes.is_a?(Hash)
  116. 1 attributes = attributes.transform_keys(&:to_sym)
  117. 1 transformed_hash = {}
  118. 1 openapi_types.each_pair do |key, type|
  119. 4 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  120. transformed_hash["#{key}"] = nil
  121. 4 elsif type =~ /\AArray<(.*)>/i
  122. # check to ensure the input is an array given that the attribute
  123. # is documented as an array but the input is not
  124. if attributes[attribute_map[key]].is_a?(Array)
  125. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  126. end
  127. 4 elsif !attributes[attribute_map[key]].nil?
  128. 4 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  129. end
  130. end
  131. 1 new(transformed_hash)
  132. end
  133. # Returns the object in the form of hash
  134. # @return [Hash] Returns the object in the form of hash
  135. 1 def to_hash
  136. 2 hash = {}
  137. 2 self.class.attribute_map.each_pair do |attr, param|
  138. 8 value = self.send(attr)
  139. 8 if value.nil?
  140. is_nullable = self.class.openapi_nullable.include?(attr)
  141. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  142. end
  143. 8 hash[param] = _to_hash(value)
  144. end
  145. 2 hash
  146. end
  147. end
  148. end

lib/bandwidth-sdk/models/sip_credentials.rb

82.81% lines covered

64 relevant lines. 53 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class SipCredentials < ApiModelBase
  13. # The username for the SIP connection.
  14. 1 attr_accessor :username
  15. # The password for the SIP connection.
  16. 1 attr_accessor :password
  17. # Attribute mapping from ruby-style variable name to JSON key.
  18. 1 def self.attribute_map
  19. 33 {
  20. :'username' => :'username',
  21. :'password' => :'password'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 12 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 1 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 2 {
  35. :'username' => :'String',
  36. :'password' => :'String'
  37. }
  38. end
  39. # List of attributes with nullable: true
  40. 1 def self.openapi_nullable
  41. 1 Set.new([
  42. ])
  43. end
  44. # Initializes the object
  45. # @param [Hash] attributes Model attributes in the form of hash
  46. 1 def initialize(attributes = {})
  47. 12 if (!attributes.is_a?(Hash))
  48. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::SipCredentials` initialize method'
  49. end
  50. # check to see if the attribute exists and convert string to symbol for hash key
  51. 11 acceptable_attribute_map = self.class.acceptable_attribute_map
  52. 11 attributes = attributes.each_with_object({}) { |(k, v), h|
  53. 17 if (!acceptable_attribute_map.key?(k.to_sym))
  54. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::SipCredentials`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  55. end
  56. 16 h[k.to_sym] = v
  57. }
  58. 10 if attributes.key?(:'username')
  59. 8 self.username = attributes[:'username']
  60. end
  61. 10 if attributes.key?(:'password')
  62. 8 self.password = attributes[:'password']
  63. end
  64. end
  65. # Show invalid properties with the reasons. Usually used together with valid?
  66. # @return Array for valid properties with the reasons
  67. 1 def list_invalid_properties
  68. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  69. invalid_properties = Array.new
  70. invalid_properties
  71. end
  72. # Check to see if the all the properties in the model are valid
  73. # @return true if the model is valid
  74. 1 def valid?
  75. warn '[DEPRECATED] the `valid?` method is obsolete'
  76. true
  77. end
  78. # Checks equality by comparing each attribute.
  79. # @param [Object] Object to be compared
  80. 1 def ==(o)
  81. 2 return true if self.equal?(o)
  82. 2 self.class == o.class &&
  83. username == o.username &&
  84. password == o.password
  85. end
  86. # @see the `==` method
  87. # @param [Object] Object to be compared
  88. 1 def eql?(o)
  89. 2 self == o
  90. end
  91. # Calculates hash code according to all attributes.
  92. # @return [Integer] Hash code
  93. 1 def hash
  94. [username, password].hash
  95. end
  96. # Builds the object from hash
  97. # @param [Hash] attributes Model attributes in the form of hash
  98. # @return [Object] Returns the model itself
  99. 1 def self.build_from_hash(attributes)
  100. 2 return nil unless attributes.is_a?(Hash)
  101. 2 attributes = attributes.transform_keys(&:to_sym)
  102. 2 transformed_hash = {}
  103. 2 openapi_types.each_pair do |key, type|
  104. 4 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  105. transformed_hash["#{key}"] = nil
  106. 4 elsif type =~ /\AArray<(.*)>/i
  107. # check to ensure the input is an array given that the attribute
  108. # is documented as an array but the input is not
  109. if attributes[attribute_map[key]].is_a?(Array)
  110. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  111. end
  112. 4 elsif !attributes[attribute_map[key]].nil?
  113. 4 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  114. end
  115. end
  116. 2 new(transformed_hash)
  117. end
  118. # Returns the object in the form of hash
  119. # @return [Hash] Returns the object in the form of hash
  120. 1 def to_hash
  121. 4 hash = {}
  122. 4 self.class.attribute_map.each_pair do |attr, param|
  123. 8 value = self.send(attr)
  124. 8 if value.nil?
  125. is_nullable = self.class.openapi_nullable.include?(attr)
  126. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  127. end
  128. 8 hash[param] = _to_hash(value)
  129. end
  130. 4 hash
  131. end
  132. end
  133. end

lib/bandwidth-sdk/models/sms_message_content.rb

75.68% lines covered

74 relevant lines. 56 lines covered and 18 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class SmsMessageContent < ApiModelBase
  13. # The contents of the text message. Must be 2048 characters or less.
  14. 1 attr_accessor :text
  15. # Attribute mapping from ruby-style variable name to JSON key.
  16. 1 def self.attribute_map
  17. 66 {
  18. :'text' => :'text'
  19. }
  20. end
  21. # Returns attribute mapping this model knows about
  22. 1 def self.acceptable_attribute_map
  23. 34 attribute_map
  24. end
  25. # Returns all the JSON keys this model knows about
  26. 1 def self.acceptable_attributes
  27. 1 acceptable_attribute_map.values
  28. end
  29. # Attribute type mapping.
  30. 1 def self.openapi_types
  31. 5 {
  32. :'text' => :'String'
  33. }
  34. end
  35. # List of attributes with nullable: true
  36. 1 def self.openapi_nullable
  37. 1 Set.new([
  38. ])
  39. end
  40. # Initializes the object
  41. # @param [Hash] attributes Model attributes in the form of hash
  42. 1 def initialize(attributes = {})
  43. 34 if (!attributes.is_a?(Hash))
  44. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::SmsMessageContent` initialize method'
  45. end
  46. # check to see if the attribute exists and convert string to symbol for hash key
  47. 33 acceptable_attribute_map = self.class.acceptable_attribute_map
  48. 33 attributes = attributes.each_with_object({}) { |(k, v), h|
  49. 33 if (!acceptable_attribute_map.key?(k.to_sym))
  50. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::SmsMessageContent`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  51. end
  52. 32 h[k.to_sym] = v
  53. }
  54. 32 if attributes.key?(:'text')
  55. 32 self.text = attributes[:'text']
  56. else
  57. self.text = nil
  58. end
  59. end
  60. # Show invalid properties with the reasons. Usually used together with valid?
  61. # @return Array for valid properties with the reasons
  62. 1 def list_invalid_properties
  63. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  64. invalid_properties = Array.new
  65. if @text.nil?
  66. invalid_properties.push('invalid value for "text", text cannot be nil.')
  67. end
  68. if @text.to_s.length > 2048
  69. invalid_properties.push('invalid value for "text", the character length must be smaller than or equal to 2048.')
  70. end
  71. invalid_properties
  72. end
  73. # Check to see if the all the properties in the model are valid
  74. # @return true if the model is valid
  75. 1 def valid?
  76. warn '[DEPRECATED] the `valid?` method is obsolete'
  77. return false if @text.nil?
  78. return false if @text.to_s.length > 2048
  79. true
  80. end
  81. # Custom attribute writer method with validation
  82. # @param [Object] text Value to be assigned
  83. 1 def text=(text)
  84. 32 if text.nil?
  85. 1 fail ArgumentError, 'text cannot be nil'
  86. end
  87. 31 if text.to_s.length > 2048
  88. 1 fail ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 2048.'
  89. end
  90. 30 @text = text
  91. end
  92. # Checks equality by comparing each attribute.
  93. # @param [Object] Object to be compared
  94. 1 def ==(o)
  95. 4 return true if self.equal?(o)
  96. 4 self.class == o.class &&
  97. text == o.text
  98. end
  99. # @see the `==` method
  100. # @param [Object] Object to be compared
  101. 1 def eql?(o)
  102. 2 self == o
  103. end
  104. # Calculates hash code according to all attributes.
  105. # @return [Integer] Hash code
  106. 1 def hash
  107. [text].hash
  108. end
  109. # Builds the object from hash
  110. # @param [Hash] attributes Model attributes in the form of hash
  111. # @return [Object] Returns the model itself
  112. 1 def self.build_from_hash(attributes)
  113. 5 return nil unless attributes.is_a?(Hash)
  114. 5 attributes = attributes.transform_keys(&:to_sym)
  115. 5 transformed_hash = {}
  116. 5 openapi_types.each_pair do |key, type|
  117. 5 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  118. transformed_hash["#{key}"] = nil
  119. 5 elsif type =~ /\AArray<(.*)>/i
  120. # check to ensure the input is an array given that the attribute
  121. # is documented as an array but the input is not
  122. if attributes[attribute_map[key]].is_a?(Array)
  123. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  124. end
  125. 5 elsif !attributes[attribute_map[key]].nil?
  126. 5 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  127. end
  128. end
  129. 5 new(transformed_hash)
  130. end
  131. # Returns the object in the form of hash
  132. # @return [Hash] Returns the object in the form of hash
  133. 1 def to_hash
  134. 11 hash = {}
  135. 11 self.class.attribute_map.each_pair do |attr, param|
  136. 11 value = self.send(attr)
  137. 11 if value.nil?
  138. is_nullable = self.class.openapi_nullable.include?(attr)
  139. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  140. end
  141. 11 hash[param] = _to_hash(value)
  142. end
  143. 11 hash
  144. end
  145. end
  146. end

lib/bandwidth-sdk/models/standalone_card_orientation_enum.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class StandaloneCardOrientationEnum
  13. 1 HORIZONTAL = 'HORIZONTAL'.freeze
  14. 1 VERTICAL = 'VERTICAL'.freeze
  15. 1 def self.all_vars
  16. 6 @all_vars ||= [HORIZONTAL, VERTICAL].freeze
  17. end
  18. # Builds the enum from string
  19. # @param [String] The enum value in the form of the string
  20. # @return [String] The enum value
  21. 1 def self.build_from_hash(value)
  22. 5 new.build_from_hash(value)
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def build_from_hash(value)
  28. 5 return value if StandaloneCardOrientationEnum.all_vars.include?(value)
  29. 1 raise "Invalid ENUM value #{value} for class #StandaloneCardOrientationEnum"
  30. end
  31. end
  32. end

lib/bandwidth-sdk/models/status_callback.rb

72.18% lines covered

133 relevant lines. 96 lines covered and 37 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # Represents a status callback for an outbound MT SMS or MMS or RBM message.
  13. 1 class StatusCallback < ApiModelBase
  14. 1 attr_accessor :time
  15. # Represents the time at which the message was read, for `message-read` callbacks.
  16. 1 attr_accessor :event_time
  17. 1 attr_accessor :type
  18. # The destination phone number the message was sent to. For status callbacks, this the the Bandwidth user's client phone number.
  19. 1 attr_accessor :to
  20. # A detailed description of the event described by the callback.
  21. 1 attr_accessor :description
  22. 1 attr_accessor :message
  23. # Optional error code, applicable only when type is `message-failed`.
  24. 1 attr_accessor :error_code
  25. # The name of the Authorized Message Provider (AMP) that handled this message. In the US, this is the carrier that the message was sent to. This field is present only when this account feature has been enabled.
  26. 1 attr_accessor :carrier_name
  27. 1 class EnumAttributeValidator
  28. 1 attr_reader :datatype
  29. 1 attr_reader :allowable_values
  30. 1 def initialize(datatype, allowable_values)
  31. @allowable_values = allowable_values.map do |value|
  32. case datatype.to_s
  33. when /Integer/i
  34. value.to_i
  35. when /Float/i
  36. value.to_f
  37. else
  38. value
  39. end
  40. end
  41. end
  42. 1 def valid?(value)
  43. !value || allowable_values.include?(value)
  44. end
  45. end
  46. # Attribute mapping from ruby-style variable name to JSON key.
  47. 1 def self.attribute_map
  48. 48 {
  49. :'time' => :'time',
  50. :'event_time' => :'eventTime',
  51. :'type' => :'type',
  52. :'to' => :'to',
  53. :'description' => :'description',
  54. :'message' => :'message',
  55. :'error_code' => :'errorCode',
  56. :'carrier_name' => :'carrierName'
  57. }
  58. end
  59. # Returns attribute mapping this model knows about
  60. 1 def self.acceptable_attribute_map
  61. 13 attribute_map
  62. end
  63. # Returns all the JSON keys this model knows about
  64. 1 def self.acceptable_attributes
  65. 1 acceptable_attribute_map.values
  66. end
  67. # Attribute type mapping.
  68. 1 def self.openapi_types
  69. 1 {
  70. :'time' => :'Time',
  71. :'event_time' => :'Time',
  72. :'type' => :'StatusCallbackTypeEnum',
  73. :'to' => :'String',
  74. :'description' => :'String',
  75. :'message' => :'StatusCallbackMessage',
  76. :'error_code' => :'Integer',
  77. :'carrier_name' => :'String'
  78. }
  79. end
  80. # List of attributes with nullable: true
  81. 1 def self.openapi_nullable
  82. 1 Set.new([
  83. ])
  84. end
  85. # Initializes the object
  86. # @param [Hash] attributes Model attributes in the form of hash
  87. 1 def initialize(attributes = {})
  88. 13 if (!attributes.is_a?(Hash))
  89. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::StatusCallback` initialize method'
  90. end
  91. # check to see if the attribute exists and convert string to symbol for hash key
  92. 12 acceptable_attribute_map = self.class.acceptable_attribute_map
  93. 12 attributes = attributes.each_with_object({}) { |(k, v), h|
  94. 83 if (!acceptable_attribute_map.key?(k.to_sym))
  95. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::StatusCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  96. end
  97. 82 h[k.to_sym] = v
  98. }
  99. 11 if attributes.key?(:'time')
  100. 11 self.time = attributes[:'time']
  101. else
  102. self.time = nil
  103. end
  104. 11 if attributes.key?(:'event_time')
  105. 9 self.event_time = attributes[:'event_time']
  106. end
  107. 11 if attributes.key?(:'type')
  108. 11 self.type = attributes[:'type']
  109. else
  110. self.type = nil
  111. end
  112. 11 if attributes.key?(:'to')
  113. 11 self.to = attributes[:'to']
  114. else
  115. self.to = nil
  116. end
  117. 11 if attributes.key?(:'description')
  118. 11 self.description = attributes[:'description']
  119. else
  120. self.description = nil
  121. end
  122. 11 if attributes.key?(:'message')
  123. 11 self.message = attributes[:'message']
  124. else
  125. self.message = nil
  126. end
  127. 11 if attributes.key?(:'error_code')
  128. 9 self.error_code = attributes[:'error_code']
  129. end
  130. 11 if attributes.key?(:'carrier_name')
  131. 9 self.carrier_name = attributes[:'carrier_name']
  132. end
  133. end
  134. # Show invalid properties with the reasons. Usually used together with valid?
  135. # @return Array for valid properties with the reasons
  136. 1 def list_invalid_properties
  137. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  138. invalid_properties = Array.new
  139. if @time.nil?
  140. invalid_properties.push('invalid value for "time", time cannot be nil.')
  141. end
  142. if @type.nil?
  143. invalid_properties.push('invalid value for "type", type cannot be nil.')
  144. end
  145. if @to.nil?
  146. invalid_properties.push('invalid value for "to", to cannot be nil.')
  147. end
  148. if @description.nil?
  149. invalid_properties.push('invalid value for "description", description cannot be nil.')
  150. end
  151. if @message.nil?
  152. invalid_properties.push('invalid value for "message", message cannot be nil.')
  153. end
  154. invalid_properties
  155. end
  156. # Check to see if the all the properties in the model are valid
  157. # @return true if the model is valid
  158. 1 def valid?
  159. warn '[DEPRECATED] the `valid?` method is obsolete'
  160. return false if @time.nil?
  161. return false if @type.nil?
  162. return false if @to.nil?
  163. return false if @description.nil?
  164. return false if @message.nil?
  165. true
  166. end
  167. # Custom attribute writer method with validation
  168. # @param [Object] time Value to be assigned
  169. 1 def time=(time)
  170. 12 if time.nil?
  171. 1 fail ArgumentError, 'time cannot be nil'
  172. end
  173. 11 @time = time
  174. end
  175. # Custom attribute writer method with validation
  176. # @param [Object] type Value to be assigned
  177. 1 def type=(type)
  178. 12 if type.nil?
  179. 1 fail ArgumentError, 'type cannot be nil'
  180. end
  181. 11 @type = type
  182. end
  183. # Custom attribute writer method with validation
  184. # @param [Object] to Value to be assigned
  185. 1 def to=(to)
  186. 12 if to.nil?
  187. 1 fail ArgumentError, 'to cannot be nil'
  188. end
  189. 11 @to = to
  190. end
  191. # Custom attribute writer method with validation
  192. # @param [Object] description Value to be assigned
  193. 1 def description=(description)
  194. 12 if description.nil?
  195. 1 fail ArgumentError, 'description cannot be nil'
  196. end
  197. 11 @description = description
  198. end
  199. # Custom attribute writer method with validation
  200. # @param [Object] message Value to be assigned
  201. 1 def message=(message)
  202. 12 if message.nil?
  203. 1 fail ArgumentError, 'message cannot be nil'
  204. end
  205. 11 @message = message
  206. end
  207. # Checks equality by comparing each attribute.
  208. # @param [Object] Object to be compared
  209. 1 def ==(o)
  210. 2 return true if self.equal?(o)
  211. 2 self.class == o.class &&
  212. time == o.time &&
  213. event_time == o.event_time &&
  214. type == o.type &&
  215. to == o.to &&
  216. description == o.description &&
  217. message == o.message &&
  218. error_code == o.error_code &&
  219. carrier_name == o.carrier_name
  220. end
  221. # @see the `==` method
  222. # @param [Object] Object to be compared
  223. 1 def eql?(o)
  224. 2 self == o
  225. end
  226. # Calculates hash code according to all attributes.
  227. # @return [Integer] Hash code
  228. 1 def hash
  229. [time, event_time, type, to, description, message, error_code, carrier_name].hash
  230. end
  231. # Builds the object from hash
  232. # @param [Hash] attributes Model attributes in the form of hash
  233. # @return [Object] Returns the model itself
  234. 1 def self.build_from_hash(attributes)
  235. 1 return nil unless attributes.is_a?(Hash)
  236. 1 attributes = attributes.transform_keys(&:to_sym)
  237. 1 transformed_hash = {}
  238. 1 openapi_types.each_pair do |key, type|
  239. 8 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  240. transformed_hash["#{key}"] = nil
  241. 8 elsif type =~ /\AArray<(.*)>/i
  242. # check to ensure the input is an array given that the attribute
  243. # is documented as an array but the input is not
  244. if attributes[attribute_map[key]].is_a?(Array)
  245. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  246. end
  247. 8 elsif !attributes[attribute_map[key]].nil?
  248. 8 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  249. end
  250. end
  251. 1 new(transformed_hash)
  252. end
  253. # Returns the object in the form of hash
  254. # @return [Hash] Returns the object in the form of hash
  255. 1 def to_hash
  256. 2 hash = {}
  257. 2 self.class.attribute_map.each_pair do |attr, param|
  258. 16 value = self.send(attr)
  259. 16 if value.nil?
  260. is_nullable = self.class.openapi_nullable.include?(attr)
  261. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  262. end
  263. 16 hash[param] = _to_hash(value)
  264. end
  265. 2 hash
  266. end
  267. end
  268. end

lib/bandwidth-sdk/models/status_callback_message.rb

72.99% lines covered

174 relevant lines. 127 lines covered and 47 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # Message payload schema within a callback
  13. 1 class StatusCallbackMessage < ApiModelBase
  14. # A unique identifier of the message.
  15. 1 attr_accessor :id
  16. # The Bandwidth phone number or alphanumeric identifier associated with the message.
  17. 1 attr_accessor :owner
  18. # The ID of the Application your from number or senderId is associated with in the Bandwidth App.
  19. 1 attr_accessor :application_id
  20. 1 attr_accessor :time
  21. # The number of segments the user's message is broken into before sending over carrier networks.
  22. 1 attr_accessor :segment_count
  23. 1 attr_accessor :direction
  24. # The phone number recipients of the message.
  25. 1 attr_accessor :to
  26. # The Bandwidth phone number or alphanumeric identifier the message was sent from.
  27. 1 attr_accessor :from
  28. 1 attr_accessor :text
  29. # A custom string that will be included in callback events of the message. Max 1024 characters.
  30. 1 attr_accessor :tag
  31. # Optional media, not applicable for sms
  32. 1 attr_accessor :media
  33. 1 attr_accessor :priority
  34. 1 attr_accessor :channel
  35. 1 class EnumAttributeValidator
  36. 1 attr_reader :datatype
  37. 1 attr_reader :allowable_values
  38. 1 def initialize(datatype, allowable_values)
  39. @allowable_values = allowable_values.map do |value|
  40. case datatype.to_s
  41. when /Integer/i
  42. value.to_i
  43. when /Float/i
  44. value.to_f
  45. else
  46. value
  47. end
  48. end
  49. end
  50. 1 def valid?(value)
  51. !value || allowable_values.include?(value)
  52. end
  53. end
  54. # Attribute mapping from ruby-style variable name to JSON key.
  55. 1 def self.attribute_map
  56. 116 {
  57. :'id' => :'id',
  58. :'owner' => :'owner',
  59. :'application_id' => :'applicationId',
  60. :'time' => :'time',
  61. :'segment_count' => :'segmentCount',
  62. :'direction' => :'direction',
  63. :'to' => :'to',
  64. :'from' => :'from',
  65. :'text' => :'text',
  66. :'tag' => :'tag',
  67. :'media' => :'media',
  68. :'priority' => :'priority',
  69. :'channel' => :'channel'
  70. }
  71. end
  72. # Returns attribute mapping this model knows about
  73. 1 def self.acceptable_attribute_map
  74. 17 attribute_map
  75. end
  76. # Returns all the JSON keys this model knows about
  77. 1 def self.acceptable_attributes
  78. 1 acceptable_attribute_map.values
  79. end
  80. # Attribute type mapping.
  81. 1 def self.openapi_types
  82. 2 {
  83. :'id' => :'String',
  84. :'owner' => :'String',
  85. :'application_id' => :'String',
  86. :'time' => :'Time',
  87. :'segment_count' => :'Integer',
  88. :'direction' => :'MessageDirectionEnum',
  89. :'to' => :'Array<String>',
  90. :'from' => :'String',
  91. :'text' => :'String',
  92. :'tag' => :'String',
  93. :'media' => :'Array<String>',
  94. :'priority' => :'PriorityEnum',
  95. :'channel' => :'MultiChannelMessageChannelEnum'
  96. }
  97. end
  98. # List of attributes with nullable: true
  99. 1 def self.openapi_nullable
  100. 1 Set.new([
  101. ])
  102. end
  103. # Initializes the object
  104. # @param [Hash] attributes Model attributes in the form of hash
  105. 1 def initialize(attributes = {})
  106. 17 if (!attributes.is_a?(Hash))
  107. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::StatusCallbackMessage` initialize method'
  108. end
  109. # check to see if the attribute exists and convert string to symbol for hash key
  110. 16 acceptable_attribute_map = self.class.acceptable_attribute_map
  111. 16 attributes = attributes.each_with_object({}) { |(k, v), h|
  112. 182 if (!acceptable_attribute_map.key?(k.to_sym))
  113. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::StatusCallbackMessage`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  114. end
  115. 181 h[k.to_sym] = v
  116. }
  117. 15 if attributes.key?(:'id')
  118. 15 self.id = attributes[:'id']
  119. else
  120. self.id = nil
  121. end
  122. 15 if attributes.key?(:'owner')
  123. 15 self.owner = attributes[:'owner']
  124. else
  125. self.owner = nil
  126. end
  127. 15 if attributes.key?(:'application_id')
  128. 15 self.application_id = attributes[:'application_id']
  129. else
  130. self.application_id = nil
  131. end
  132. 15 if attributes.key?(:'time')
  133. 15 self.time = attributes[:'time']
  134. else
  135. self.time = nil
  136. end
  137. 15 if attributes.key?(:'segment_count')
  138. 15 self.segment_count = attributes[:'segment_count']
  139. else
  140. self.segment_count = nil
  141. end
  142. 15 if attributes.key?(:'direction')
  143. 15 self.direction = attributes[:'direction']
  144. else
  145. self.direction = nil
  146. end
  147. 15 if attributes.key?(:'to')
  148. 15 if (value = attributes[:'to']).is_a?(Array)
  149. 15 self.to = value
  150. end
  151. else
  152. self.to = nil
  153. end
  154. 15 if attributes.key?(:'from')
  155. 15 self.from = attributes[:'from']
  156. else
  157. self.from = nil
  158. end
  159. 15 if attributes.key?(:'text')
  160. 13 self.text = attributes[:'text']
  161. end
  162. 15 if attributes.key?(:'tag')
  163. 12 self.tag = attributes[:'tag']
  164. end
  165. 15 if attributes.key?(:'media')
  166. 12 if (value = attributes[:'media']).is_a?(Array)
  167. 12 self.media = value
  168. end
  169. end
  170. 15 if attributes.key?(:'priority')
  171. 12 self.priority = attributes[:'priority']
  172. end
  173. 15 if attributes.key?(:'channel')
  174. 12 self.channel = attributes[:'channel']
  175. end
  176. end
  177. # Show invalid properties with the reasons. Usually used together with valid?
  178. # @return Array for valid properties with the reasons
  179. 1 def list_invalid_properties
  180. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  181. invalid_properties = Array.new
  182. if @id.nil?
  183. invalid_properties.push('invalid value for "id", id cannot be nil.')
  184. end
  185. if @owner.nil?
  186. invalid_properties.push('invalid value for "owner", owner cannot be nil.')
  187. end
  188. if @application_id.nil?
  189. invalid_properties.push('invalid value for "application_id", application_id cannot be nil.')
  190. end
  191. if @time.nil?
  192. invalid_properties.push('invalid value for "time", time cannot be nil.')
  193. end
  194. if @segment_count.nil?
  195. invalid_properties.push('invalid value for "segment_count", segment_count cannot be nil.')
  196. end
  197. if @direction.nil?
  198. invalid_properties.push('invalid value for "direction", direction cannot be nil.')
  199. end
  200. if @to.nil?
  201. invalid_properties.push('invalid value for "to", to cannot be nil.')
  202. end
  203. if @from.nil?
  204. invalid_properties.push('invalid value for "from", from cannot be nil.')
  205. end
  206. invalid_properties
  207. end
  208. # Check to see if the all the properties in the model are valid
  209. # @return true if the model is valid
  210. 1 def valid?
  211. warn '[DEPRECATED] the `valid?` method is obsolete'
  212. return false if @id.nil?
  213. return false if @owner.nil?
  214. return false if @application_id.nil?
  215. return false if @time.nil?
  216. return false if @segment_count.nil?
  217. return false if @direction.nil?
  218. return false if @to.nil?
  219. return false if @from.nil?
  220. true
  221. end
  222. # Custom attribute writer method with validation
  223. # @param [Object] id Value to be assigned
  224. 1 def id=(id)
  225. 16 if id.nil?
  226. 1 fail ArgumentError, 'id cannot be nil'
  227. end
  228. 15 @id = id
  229. end
  230. # Custom attribute writer method with validation
  231. # @param [Object] owner Value to be assigned
  232. 1 def owner=(owner)
  233. 16 if owner.nil?
  234. 1 fail ArgumentError, 'owner cannot be nil'
  235. end
  236. 15 @owner = owner
  237. end
  238. # Custom attribute writer method with validation
  239. # @param [Object] application_id Value to be assigned
  240. 1 def application_id=(application_id)
  241. 16 if application_id.nil?
  242. 1 fail ArgumentError, 'application_id cannot be nil'
  243. end
  244. 15 @application_id = application_id
  245. end
  246. # Custom attribute writer method with validation
  247. # @param [Object] time Value to be assigned
  248. 1 def time=(time)
  249. 16 if time.nil?
  250. 1 fail ArgumentError, 'time cannot be nil'
  251. end
  252. 15 @time = time
  253. end
  254. # Custom attribute writer method with validation
  255. # @param [Object] segment_count Value to be assigned
  256. 1 def segment_count=(segment_count)
  257. 16 if segment_count.nil?
  258. 1 fail ArgumentError, 'segment_count cannot be nil'
  259. end
  260. 15 @segment_count = segment_count
  261. end
  262. # Custom attribute writer method with validation
  263. # @param [Object] direction Value to be assigned
  264. 1 def direction=(direction)
  265. 16 if direction.nil?
  266. 1 fail ArgumentError, 'direction cannot be nil'
  267. end
  268. 15 @direction = direction
  269. end
  270. # Custom attribute writer method with validation
  271. # @param [Object] to Value to be assigned
  272. 1 def to=(to)
  273. 16 if to.nil?
  274. 1 fail ArgumentError, 'to cannot be nil'
  275. end
  276. 15 @to = to
  277. end
  278. # Custom attribute writer method with validation
  279. # @param [Object] from Value to be assigned
  280. 1 def from=(from)
  281. 16 if from.nil?
  282. 1 fail ArgumentError, 'from cannot be nil'
  283. end
  284. 15 @from = from
  285. end
  286. # Checks equality by comparing each attribute.
  287. # @param [Object] Object to be compared
  288. 1 def ==(o)
  289. 2 return true if self.equal?(o)
  290. 2 self.class == o.class &&
  291. id == o.id &&
  292. owner == o.owner &&
  293. application_id == o.application_id &&
  294. time == o.time &&
  295. segment_count == o.segment_count &&
  296. direction == o.direction &&
  297. to == o.to &&
  298. from == o.from &&
  299. text == o.text &&
  300. tag == o.tag &&
  301. media == o.media &&
  302. priority == o.priority &&
  303. channel == o.channel
  304. end
  305. # @see the `==` method
  306. # @param [Object] Object to be compared
  307. 1 def eql?(o)
  308. 2 self == o
  309. end
  310. # Calculates hash code according to all attributes.
  311. # @return [Integer] Hash code
  312. 1 def hash
  313. [id, owner, application_id, time, segment_count, direction, to, from, text, tag, media, priority, channel].hash
  314. end
  315. # Builds the object from hash
  316. # @param [Hash] attributes Model attributes in the form of hash
  317. # @return [Object] Returns the model itself
  318. 1 def self.build_from_hash(attributes)
  319. 2 return nil unless attributes.is_a?(Hash)
  320. 2 attributes = attributes.transform_keys(&:to_sym)
  321. 2 transformed_hash = {}
  322. 2 openapi_types.each_pair do |key, type|
  323. 26 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  324. transformed_hash["#{key}"] = nil
  325. 26 elsif type =~ /\AArray<(.*)>/i
  326. # check to ensure the input is an array given that the attribute
  327. # is documented as an array but the input is not
  328. 4 if attributes[attribute_map[key]].is_a?(Array)
  329. 6 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  330. end
  331. 22 elsif !attributes[attribute_map[key]].nil?
  332. 19 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  333. end
  334. end
  335. 2 new(transformed_hash)
  336. end
  337. # Returns the object in the form of hash
  338. # @return [Hash] Returns the object in the form of hash
  339. 1 def to_hash
  340. 2 hash = {}
  341. 2 self.class.attribute_map.each_pair do |attr, param|
  342. 26 value = self.send(attr)
  343. 26 if value.nil?
  344. is_nullable = self.class.openapi_nullable.include?(attr)
  345. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  346. end
  347. 26 hash[param] = _to_hash(value)
  348. end
  349. 2 hash
  350. end
  351. end
  352. end

lib/bandwidth-sdk/models/status_callback_type_enum.rb

100.0% lines covered

15 relevant lines. 15 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class StatusCallbackTypeEnum
  13. 1 MESSAGE_SENDING = 'message-sending'.freeze
  14. 1 MESSAGE_DELIVERED = 'message-delivered'.freeze
  15. 1 MESSAGE_FAILED = 'message-failed'.freeze
  16. 1 MESSAGE_READ = 'message-read'.freeze
  17. 1 def self.all_vars
  18. 7 @all_vars ||= [MESSAGE_SENDING, MESSAGE_DELIVERED, MESSAGE_FAILED, MESSAGE_READ].freeze
  19. end
  20. # Builds the enum from string
  21. # @param [String] The enum value in the form of the string
  22. # @return [String] The enum value
  23. 1 def self.build_from_hash(value)
  24. 6 new.build_from_hash(value)
  25. end
  26. # Builds the enum from string
  27. # @param [String] The enum value in the form of the string
  28. # @return [String] The enum value
  29. 1 def build_from_hash(value)
  30. 6 return value if StatusCallbackTypeEnum.all_vars.include?(value)
  31. 1 raise "Invalid ENUM value #{value} for class #StatusCallbackTypeEnum"
  32. end
  33. end
  34. end

lib/bandwidth-sdk/models/stir_shaken.rb

83.58% lines covered

67 relevant lines. 56 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class StirShaken < ApiModelBase
  13. # (optional) The verification status indicating whether the verification was successful or not. Possible values are TN-Validation-Passed and TN-Validation-Failed.
  14. 1 attr_accessor :verstat
  15. # (optional) The attestation level verified by Bandwidth. Possible values are A (full), B (partial) or C (gateway).
  16. 1 attr_accessor :attestation_indicator
  17. # (optional) A unique origination identifier.
  18. 1 attr_accessor :originating_id
  19. # Attribute mapping from ruby-style variable name to JSON key.
  20. 1 def self.attribute_map
  21. 36 {
  22. :'verstat' => :'verstat',
  23. :'attestation_indicator' => :'attestationIndicator',
  24. :'originating_id' => :'originatingId'
  25. }
  26. end
  27. # Returns attribute mapping this model knows about
  28. 1 def self.acceptable_attribute_map
  29. 9 attribute_map
  30. end
  31. # Returns all the JSON keys this model knows about
  32. 1 def self.acceptable_attributes
  33. 1 acceptable_attribute_map.values
  34. end
  35. # Attribute type mapping.
  36. 1 def self.openapi_types
  37. 2 {
  38. :'verstat' => :'String',
  39. :'attestation_indicator' => :'String',
  40. :'originating_id' => :'String'
  41. }
  42. end
  43. # List of attributes with nullable: true
  44. 1 def self.openapi_nullable
  45. 1 Set.new([
  46. ])
  47. end
  48. # Initializes the object
  49. # @param [Hash] attributes Model attributes in the form of hash
  50. 1 def initialize(attributes = {})
  51. 9 if (!attributes.is_a?(Hash))
  52. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::StirShaken` initialize method'
  53. end
  54. # check to see if the attribute exists and convert string to symbol for hash key
  55. 8 acceptable_attribute_map = self.class.acceptable_attribute_map
  56. 8 attributes = attributes.each_with_object({}) { |(k, v), h|
  57. 16 if (!acceptable_attribute_map.key?(k.to_sym))
  58. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::StirShaken`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  59. end
  60. 15 h[k.to_sym] = v
  61. }
  62. 7 if attributes.key?(:'verstat')
  63. 5 self.verstat = attributes[:'verstat']
  64. end
  65. 7 if attributes.key?(:'attestation_indicator')
  66. 5 self.attestation_indicator = attributes[:'attestation_indicator']
  67. end
  68. 7 if attributes.key?(:'originating_id')
  69. 5 self.originating_id = attributes[:'originating_id']
  70. end
  71. end
  72. # Show invalid properties with the reasons. Usually used together with valid?
  73. # @return Array for valid properties with the reasons
  74. 1 def list_invalid_properties
  75. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  76. invalid_properties = Array.new
  77. invalid_properties
  78. end
  79. # Check to see if the all the properties in the model are valid
  80. # @return true if the model is valid
  81. 1 def valid?
  82. warn '[DEPRECATED] the `valid?` method is obsolete'
  83. true
  84. end
  85. # Checks equality by comparing each attribute.
  86. # @param [Object] Object to be compared
  87. 1 def ==(o)
  88. 2 return true if self.equal?(o)
  89. 2 self.class == o.class &&
  90. verstat == o.verstat &&
  91. attestation_indicator == o.attestation_indicator &&
  92. originating_id == o.originating_id
  93. end
  94. # @see the `==` method
  95. # @param [Object] Object to be compared
  96. 1 def eql?(o)
  97. 2 self == o
  98. end
  99. # Calculates hash code according to all attributes.
  100. # @return [Integer] Hash code
  101. 1 def hash
  102. [verstat, attestation_indicator, originating_id].hash
  103. end
  104. # Builds the object from hash
  105. # @param [Hash] attributes Model attributes in the form of hash
  106. # @return [Object] Returns the model itself
  107. 1 def self.build_from_hash(attributes)
  108. 2 return nil unless attributes.is_a?(Hash)
  109. 2 attributes = attributes.transform_keys(&:to_sym)
  110. 2 transformed_hash = {}
  111. 2 openapi_types.each_pair do |key, type|
  112. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  113. transformed_hash["#{key}"] = nil
  114. 6 elsif type =~ /\AArray<(.*)>/i
  115. # check to ensure the input is an array given that the attribute
  116. # is documented as an array but the input is not
  117. if attributes[attribute_map[key]].is_a?(Array)
  118. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  119. end
  120. 6 elsif !attributes[attribute_map[key]].nil?
  121. 6 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  122. end
  123. end
  124. 2 new(transformed_hash)
  125. end
  126. # Returns the object in the form of hash
  127. # @return [Hash] Returns the object in the form of hash
  128. 1 def to_hash
  129. 2 hash = {}
  130. 2 self.class.attribute_map.each_pair do |attr, param|
  131. 6 value = self.send(attr)
  132. 6 if value.nil?
  133. is_nullable = self.class.openapi_nullable.include?(attr)
  134. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  135. end
  136. 6 hash[param] = _to_hash(value)
  137. end
  138. 2 hash
  139. end
  140. end
  141. end

lib/bandwidth-sdk/models/sync_lookup_request.rb

79.76% lines covered

84 relevant lines. 67 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class SyncLookupRequest < ApiModelBase
  13. # Telephone numbers in E.164 format.
  14. 1 attr_accessor :phone_numbers
  15. # Override the default RCS sender/agent ID used when checking RCS capabilities. When provided, this value is used as the `sender` in the RCS capability-check request instead of the account default. Must be 1–40 characters and contain only letters, digits, underscores, or hyphens.
  16. 1 attr_accessor :rcs_agent
  17. # Attribute mapping from ruby-style variable name to JSON key.
  18. 1 def self.attribute_map
  19. 25 {
  20. :'phone_numbers' => :'phoneNumbers',
  21. :'rcs_agent' => :'rcsAgent'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 13 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 1 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 1 {
  35. :'phone_numbers' => :'Array<String>',
  36. :'rcs_agent' => :'String'
  37. }
  38. end
  39. # List of attributes with nullable: true
  40. 1 def self.openapi_nullable
  41. 1 Set.new([
  42. ])
  43. end
  44. # Initializes the object
  45. # @param [Hash] attributes Model attributes in the form of hash
  46. 1 def initialize(attributes = {})
  47. 13 if (!attributes.is_a?(Hash))
  48. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::SyncLookupRequest` initialize method'
  49. end
  50. # check to see if the attribute exists and convert string to symbol for hash key
  51. 12 acceptable_attribute_map = self.class.acceptable_attribute_map
  52. 12 attributes = attributes.each_with_object({}) { |(k, v), h|
  53. 21 if (!acceptable_attribute_map.key?(k.to_sym))
  54. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::SyncLookupRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  55. end
  56. 20 h[k.to_sym] = v
  57. }
  58. 11 if attributes.key?(:'phone_numbers')
  59. 11 if (value = attributes[:'phone_numbers']).is_a?(Array)
  60. 11 self.phone_numbers = value
  61. end
  62. else
  63. self.phone_numbers = nil
  64. end
  65. 11 if attributes.key?(:'rcs_agent')
  66. 9 self.rcs_agent = attributes[:'rcs_agent']
  67. end
  68. end
  69. # Show invalid properties with the reasons. Usually used together with valid?
  70. # @return Array for valid properties with the reasons
  71. 1 def list_invalid_properties
  72. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  73. invalid_properties = Array.new
  74. if @phone_numbers.nil?
  75. invalid_properties.push('invalid value for "phone_numbers", phone_numbers cannot be nil.')
  76. end
  77. pattern = Regexp.new(/^[A-Za-z0-9_-]{1,40}$/)
  78. if !@rcs_agent.nil? && @rcs_agent !~ pattern
  79. invalid_properties.push("invalid value for \"rcs_agent\", must conform to the pattern #{pattern}.")
  80. end
  81. invalid_properties
  82. end
  83. # Check to see if the all the properties in the model are valid
  84. # @return true if the model is valid
  85. 1 def valid?
  86. warn '[DEPRECATED] the `valid?` method is obsolete'
  87. return false if @phone_numbers.nil?
  88. return false if !@rcs_agent.nil? && @rcs_agent !~ Regexp.new(/^[A-Za-z0-9_-]{1,40}$/)
  89. true
  90. end
  91. # Custom attribute writer method with validation
  92. # @param [Object] phone_numbers Value to be assigned
  93. 1 def phone_numbers=(phone_numbers)
  94. 12 if phone_numbers.nil?
  95. 1 fail ArgumentError, 'phone_numbers cannot be nil'
  96. end
  97. 11 @phone_numbers = phone_numbers
  98. end
  99. # Custom attribute writer method with validation
  100. # @param [Object] rcs_agent Value to be assigned
  101. 1 def rcs_agent=(rcs_agent)
  102. 9 if rcs_agent.nil?
  103. 1 fail ArgumentError, 'rcs_agent cannot be nil'
  104. end
  105. 8 pattern = Regexp.new(/^[A-Za-z0-9_-]{1,40}$/)
  106. 8 if rcs_agent !~ pattern
  107. 1 fail ArgumentError, "invalid value for \"rcs_agent\", must conform to the pattern #{pattern}."
  108. end
  109. 7 @rcs_agent = rcs_agent
  110. end
  111. # Checks equality by comparing each attribute.
  112. # @param [Object] Object to be compared
  113. 1 def ==(o)
  114. 2 return true if self.equal?(o)
  115. 2 self.class == o.class &&
  116. phone_numbers == o.phone_numbers &&
  117. rcs_agent == o.rcs_agent
  118. end
  119. # @see the `==` method
  120. # @param [Object] Object to be compared
  121. 1 def eql?(o)
  122. 2 self == o
  123. end
  124. # Calculates hash code according to all attributes.
  125. # @return [Integer] Hash code
  126. 1 def hash
  127. [phone_numbers, rcs_agent].hash
  128. end
  129. # Builds the object from hash
  130. # @param [Hash] attributes Model attributes in the form of hash
  131. # @return [Object] Returns the model itself
  132. 1 def self.build_from_hash(attributes)
  133. 1 return nil unless attributes.is_a?(Hash)
  134. 1 attributes = attributes.transform_keys(&:to_sym)
  135. 1 transformed_hash = {}
  136. 1 openapi_types.each_pair do |key, type|
  137. 2 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  138. transformed_hash["#{key}"] = nil
  139. 2 elsif type =~ /\AArray<(.*)>/i
  140. # check to ensure the input is an array given that the attribute
  141. # is documented as an array but the input is not
  142. 1 if attributes[attribute_map[key]].is_a?(Array)
  143. 3 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  144. end
  145. 1 elsif !attributes[attribute_map[key]].nil?
  146. 1 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  147. end
  148. end
  149. 1 new(transformed_hash)
  150. end
  151. # Returns the object in the form of hash
  152. # @return [Hash] Returns the object in the form of hash
  153. 1 def to_hash
  154. 3 hash = {}
  155. 3 self.class.attribute_map.each_pair do |attr, param|
  156. 6 value = self.send(attr)
  157. 6 if value.nil?
  158. is_nullable = self.class.openapi_nullable.include?(attr)
  159. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  160. end
  161. 6 hash[param] = _to_hash(value)
  162. end
  163. 3 hash
  164. end
  165. end
  166. end

lib/bandwidth-sdk/models/telephone_number.rb

81.97% lines covered

61 relevant lines. 50 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class TelephoneNumber < ApiModelBase
  13. # Simple Telephone Number.
  14. 1 attr_accessor :telephone_number
  15. # Attribute mapping from ruby-style variable name to JSON key.
  16. 1 def self.attribute_map
  17. 30 {
  18. :'telephone_number' => :'telephoneNumber'
  19. }
  20. end
  21. # Returns attribute mapping this model knows about
  22. 1 def self.acceptable_attribute_map
  23. 13 attribute_map
  24. end
  25. # Returns all the JSON keys this model knows about
  26. 1 def self.acceptable_attributes
  27. 1 acceptable_attribute_map.values
  28. end
  29. # Attribute type mapping.
  30. 1 def self.openapi_types
  31. 3 {
  32. :'telephone_number' => :'String'
  33. }
  34. end
  35. # List of attributes with nullable: true
  36. 1 def self.openapi_nullable
  37. 1 Set.new([
  38. ])
  39. end
  40. # Initializes the object
  41. # @param [Hash] attributes Model attributes in the form of hash
  42. 1 def initialize(attributes = {})
  43. 13 if (!attributes.is_a?(Hash))
  44. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::TelephoneNumber` initialize method'
  45. end
  46. # check to see if the attribute exists and convert string to symbol for hash key
  47. 12 acceptable_attribute_map = self.class.acceptable_attribute_map
  48. 12 attributes = attributes.each_with_object({}) { |(k, v), h|
  49. 10 if (!acceptable_attribute_map.key?(k.to_sym))
  50. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::TelephoneNumber`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  51. end
  52. 9 h[k.to_sym] = v
  53. }
  54. 11 if attributes.key?(:'telephone_number')
  55. 9 self.telephone_number = attributes[:'telephone_number']
  56. end
  57. end
  58. # Show invalid properties with the reasons. Usually used together with valid?
  59. # @return Array for valid properties with the reasons
  60. 1 def list_invalid_properties
  61. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  62. invalid_properties = Array.new
  63. invalid_properties
  64. end
  65. # Check to see if the all the properties in the model are valid
  66. # @return true if the model is valid
  67. 1 def valid?
  68. warn '[DEPRECATED] the `valid?` method is obsolete'
  69. true
  70. end
  71. # Checks equality by comparing each attribute.
  72. # @param [Object] Object to be compared
  73. 1 def ==(o)
  74. 2 return true if self.equal?(o)
  75. 2 self.class == o.class &&
  76. telephone_number == o.telephone_number
  77. end
  78. # @see the `==` method
  79. # @param [Object] Object to be compared
  80. 1 def eql?(o)
  81. 2 self == o
  82. end
  83. # Calculates hash code according to all attributes.
  84. # @return [Integer] Hash code
  85. 1 def hash
  86. [telephone_number].hash
  87. end
  88. # Builds the object from hash
  89. # @param [Hash] attributes Model attributes in the form of hash
  90. # @return [Object] Returns the model itself
  91. 1 def self.build_from_hash(attributes)
  92. 3 return nil unless attributes.is_a?(Hash)
  93. 3 attributes = attributes.transform_keys(&:to_sym)
  94. 3 transformed_hash = {}
  95. 3 openapi_types.each_pair do |key, type|
  96. 3 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  97. transformed_hash["#{key}"] = nil
  98. 3 elsif type =~ /\AArray<(.*)>/i
  99. # check to ensure the input is an array given that the attribute
  100. # is documented as an array but the input is not
  101. if attributes[attribute_map[key]].is_a?(Array)
  102. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  103. end
  104. 3 elsif !attributes[attribute_map[key]].nil?
  105. 3 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  106. end
  107. end
  108. 3 new(transformed_hash)
  109. end
  110. # Returns the object in the form of hash
  111. # @return [Hash] Returns the object in the form of hash
  112. 1 def to_hash
  113. 4 hash = {}
  114. 4 self.class.attribute_map.each_pair do |attr, param|
  115. 4 value = self.send(attr)
  116. 4 if value.nil?
  117. is_nullable = self.class.openapi_nullable.include?(attr)
  118. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  119. end
  120. 4 hash[param] = _to_hash(value)
  121. end
  122. 4 hash
  123. end
  124. end
  125. end

lib/bandwidth-sdk/models/tfv_basic_authentication.rb

72.22% lines covered

90 relevant lines. 65 lines covered and 25 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class TfvBasicAuthentication < ApiModelBase
  13. 1 attr_accessor :username
  14. 1 attr_accessor :password
  15. # Attribute mapping from ruby-style variable name to JSON key.
  16. 1 def self.attribute_map
  17. 39 {
  18. :'username' => :'username',
  19. :'password' => :'password'
  20. }
  21. end
  22. # Returns attribute mapping this model knows about
  23. 1 def self.acceptable_attribute_map
  24. 18 attribute_map
  25. end
  26. # Returns all the JSON keys this model knows about
  27. 1 def self.acceptable_attributes
  28. 1 acceptable_attribute_map.values
  29. end
  30. # Attribute type mapping.
  31. 1 def self.openapi_types
  32. 2 {
  33. :'username' => :'String',
  34. :'password' => :'String'
  35. }
  36. end
  37. # List of attributes with nullable: true
  38. 1 def self.openapi_nullable
  39. 1 Set.new([
  40. ])
  41. end
  42. # Initializes the object
  43. # @param [Hash] attributes Model attributes in the form of hash
  44. 1 def initialize(attributes = {})
  45. 18 if (!attributes.is_a?(Hash))
  46. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::TfvBasicAuthentication` initialize method'
  47. end
  48. # check to see if the attribute exists and convert string to symbol for hash key
  49. 17 acceptable_attribute_map = self.class.acceptable_attribute_map
  50. 17 attributes = attributes.each_with_object({}) { |(k, v), h|
  51. 33 if (!acceptable_attribute_map.key?(k.to_sym))
  52. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::TfvBasicAuthentication`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  53. end
  54. 32 h[k.to_sym] = v
  55. }
  56. 16 if attributes.key?(:'username')
  57. 16 self.username = attributes[:'username']
  58. else
  59. self.username = nil
  60. end
  61. 14 if attributes.key?(:'password')
  62. 14 self.password = attributes[:'password']
  63. else
  64. self.password = nil
  65. end
  66. end
  67. # Show invalid properties with the reasons. Usually used together with valid?
  68. # @return Array for valid properties with the reasons
  69. 1 def list_invalid_properties
  70. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  71. invalid_properties = Array.new
  72. if @username.nil?
  73. invalid_properties.push('invalid value for "username", username cannot be nil.')
  74. end
  75. if @username.to_s.length > 100
  76. invalid_properties.push('invalid value for "username", the character length must be smaller than or equal to 100.')
  77. end
  78. if @password.nil?
  79. invalid_properties.push('invalid value for "password", password cannot be nil.')
  80. end
  81. if @password.to_s.length > 200
  82. invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 200.')
  83. end
  84. invalid_properties
  85. end
  86. # Check to see if the all the properties in the model are valid
  87. # @return true if the model is valid
  88. 1 def valid?
  89. warn '[DEPRECATED] the `valid?` method is obsolete'
  90. return false if @username.nil?
  91. return false if @username.to_s.length > 100
  92. return false if @password.nil?
  93. return false if @password.to_s.length > 200
  94. true
  95. end
  96. # Custom attribute writer method with validation
  97. # @param [Object] username Value to be assigned
  98. 1 def username=(username)
  99. 16 if username.nil?
  100. 1 fail ArgumentError, 'username cannot be nil'
  101. end
  102. 15 if username.to_s.length > 100
  103. 1 fail ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 100.'
  104. end
  105. 14 @username = username
  106. end
  107. # Custom attribute writer method with validation
  108. # @param [Object] password Value to be assigned
  109. 1 def password=(password)
  110. 14 if password.nil?
  111. 1 fail ArgumentError, 'password cannot be nil'
  112. end
  113. 13 if password.to_s.length > 200
  114. 1 fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 200.'
  115. end
  116. 12 @password = password
  117. end
  118. # Checks equality by comparing each attribute.
  119. # @param [Object] Object to be compared
  120. 1 def ==(o)
  121. 2 return true if self.equal?(o)
  122. 2 self.class == o.class &&
  123. username == o.username &&
  124. password == o.password
  125. end
  126. # @see the `==` method
  127. # @param [Object] Object to be compared
  128. 1 def eql?(o)
  129. 2 self == o
  130. end
  131. # Calculates hash code according to all attributes.
  132. # @return [Integer] Hash code
  133. 1 def hash
  134. [username, password].hash
  135. end
  136. # Builds the object from hash
  137. # @param [Hash] attributes Model attributes in the form of hash
  138. # @return [Object] Returns the model itself
  139. 1 def self.build_from_hash(attributes)
  140. 2 return nil unless attributes.is_a?(Hash)
  141. 2 attributes = attributes.transform_keys(&:to_sym)
  142. 2 transformed_hash = {}
  143. 2 openapi_types.each_pair do |key, type|
  144. 4 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  145. transformed_hash["#{key}"] = nil
  146. 4 elsif type =~ /\AArray<(.*)>/i
  147. # check to ensure the input is an array given that the attribute
  148. # is documented as an array but the input is not
  149. if attributes[attribute_map[key]].is_a?(Array)
  150. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  151. end
  152. 4 elsif !attributes[attribute_map[key]].nil?
  153. 4 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  154. end
  155. end
  156. 2 new(transformed_hash)
  157. end
  158. # Returns the object in the form of hash
  159. # @return [Hash] Returns the object in the form of hash
  160. 1 def to_hash
  161. 4 hash = {}
  162. 4 self.class.attribute_map.each_pair do |attr, param|
  163. 8 value = self.send(attr)
  164. 8 if value.nil?
  165. is_nullable = self.class.openapi_nullable.include?(attr)
  166. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  167. end
  168. 8 hash[param] = _to_hash(value)
  169. end
  170. 4 hash
  171. end
  172. end
  173. end

lib/bandwidth-sdk/models/tfv_callback_status_enum.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class TfvCallbackStatusEnum
  13. 1 VERIFIED = 'VERIFIED'.freeze
  14. 1 UNVERIFIED = 'UNVERIFIED'.freeze
  15. 1 def self.all_vars
  16. 6 @all_vars ||= [VERIFIED, UNVERIFIED].freeze
  17. end
  18. # Builds the enum from string
  19. # @param [String] The enum value in the form of the string
  20. # @return [String] The enum value
  21. 1 def self.build_from_hash(value)
  22. 5 new.build_from_hash(value)
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def build_from_hash(value)
  28. 5 return value if TfvCallbackStatusEnum.all_vars.include?(value)
  29. 1 raise "Invalid ENUM value #{value} for class #TfvCallbackStatusEnum"
  30. end
  31. end
  32. end

lib/bandwidth-sdk/models/tfv_error.rb

83.58% lines covered

67 relevant lines. 56 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # A generic error object.
  13. 1 class TfvError < ApiModelBase
  14. 1 attr_accessor :type
  15. 1 attr_accessor :description
  16. # Each key of this errors object refers to a field of the submitted object (using dot notation for nested objects), with the field being a key to an array of one or more errors for that field.
  17. 1 attr_accessor :errors
  18. # Attribute mapping from ruby-style variable name to JSON key.
  19. 1 def self.attribute_map
  20. 23 {
  21. :'type' => :'type',
  22. :'description' => :'description',
  23. :'errors' => :'errors'
  24. }
  25. end
  26. # Returns attribute mapping this model knows about
  27. 1 def self.acceptable_attribute_map
  28. 8 attribute_map
  29. end
  30. # Returns all the JSON keys this model knows about
  31. 1 def self.acceptable_attributes
  32. 1 acceptable_attribute_map.values
  33. end
  34. # Attribute type mapping.
  35. 1 def self.openapi_types
  36. 1 {
  37. :'type' => :'String',
  38. :'description' => :'String',
  39. :'errors' => :'Object'
  40. }
  41. end
  42. # List of attributes with nullable: true
  43. 1 def self.openapi_nullable
  44. 1 Set.new([
  45. ])
  46. end
  47. # Initializes the object
  48. # @param [Hash] attributes Model attributes in the form of hash
  49. 1 def initialize(attributes = {})
  50. 8 if (!attributes.is_a?(Hash))
  51. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::TfvError` initialize method'
  52. end
  53. # check to see if the attribute exists and convert string to symbol for hash key
  54. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  55. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  56. 13 if (!acceptable_attribute_map.key?(k.to_sym))
  57. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::TfvError`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  58. end
  59. 12 h[k.to_sym] = v
  60. }
  61. 6 if attributes.key?(:'type')
  62. 4 self.type = attributes[:'type']
  63. end
  64. 6 if attributes.key?(:'description')
  65. 4 self.description = attributes[:'description']
  66. end
  67. 6 if attributes.key?(:'errors')
  68. 4 self.errors = attributes[:'errors']
  69. end
  70. end
  71. # Show invalid properties with the reasons. Usually used together with valid?
  72. # @return Array for valid properties with the reasons
  73. 1 def list_invalid_properties
  74. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  75. invalid_properties = Array.new
  76. invalid_properties
  77. end
  78. # Check to see if the all the properties in the model are valid
  79. # @return true if the model is valid
  80. 1 def valid?
  81. warn '[DEPRECATED] the `valid?` method is obsolete'
  82. true
  83. end
  84. # Checks equality by comparing each attribute.
  85. # @param [Object] Object to be compared
  86. 1 def ==(o)
  87. 2 return true if self.equal?(o)
  88. 2 self.class == o.class &&
  89. type == o.type &&
  90. description == o.description &&
  91. errors == o.errors
  92. end
  93. # @see the `==` method
  94. # @param [Object] Object to be compared
  95. 1 def eql?(o)
  96. 2 self == o
  97. end
  98. # Calculates hash code according to all attributes.
  99. # @return [Integer] Hash code
  100. 1 def hash
  101. [type, description, errors].hash
  102. end
  103. # Builds the object from hash
  104. # @param [Hash] attributes Model attributes in the form of hash
  105. # @return [Object] Returns the model itself
  106. 1 def self.build_from_hash(attributes)
  107. 1 return nil unless attributes.is_a?(Hash)
  108. 1 attributes = attributes.transform_keys(&:to_sym)
  109. 1 transformed_hash = {}
  110. 1 openapi_types.each_pair do |key, type|
  111. 3 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  112. transformed_hash["#{key}"] = nil
  113. 3 elsif type =~ /\AArray<(.*)>/i
  114. # check to ensure the input is an array given that the attribute
  115. # is documented as an array but the input is not
  116. if attributes[attribute_map[key]].is_a?(Array)
  117. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  118. end
  119. 3 elsif !attributes[attribute_map[key]].nil?
  120. 3 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  121. end
  122. end
  123. 1 new(transformed_hash)
  124. end
  125. # Returns the object in the form of hash
  126. # @return [Hash] Returns the object in the form of hash
  127. 1 def to_hash
  128. 2 hash = {}
  129. 2 self.class.attribute_map.each_pair do |attr, param|
  130. 6 value = self.send(attr)
  131. 6 if value.nil?
  132. is_nullable = self.class.openapi_nullable.include?(attr)
  133. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  134. end
  135. 6 hash[param] = _to_hash(value)
  136. end
  137. 2 hash
  138. end
  139. end
  140. end

lib/bandwidth-sdk/models/tfv_status.rb

74.81% lines covered

135 relevant lines. 101 lines covered and 34 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class TfvStatus < ApiModelBase
  13. # Toll-free telephone number in E.164 format.
  14. 1 attr_accessor :phone_number
  15. 1 attr_accessor :status
  16. # Unique identifier (UUID) generated by Bandwidth to assist in tracking the verification status of a toll-free number - included in all webhook payloads.
  17. 1 attr_accessor :internal_ticket_number
  18. # Explanation for why a verification request was declined.
  19. 1 attr_accessor :decline_reason_description
  20. # Whether a Toll-Free Verification request qualifies for resubmission via PUT.
  21. 1 attr_accessor :resubmit_allowed
  22. # Date and time the verification request was created.
  23. 1 attr_accessor :created_date_time
  24. # Date and time the verification request was last modified.
  25. 1 attr_accessor :modified_date_time
  26. 1 attr_accessor :submission
  27. # Whether a Toll-Free Verification is blocked. This attribute will only be defined when the number is blocked.
  28. 1 attr_accessor :blocked
  29. # The reason why the Toll-Free Verification is blocked. This attribute will only be defined when the number is blocked.
  30. 1 attr_accessor :blocked_reason
  31. # The token provided by Campaign Verify to validate your political use case. Only required for 527 political organizations. If you are not a 527 political organization, this field should be omitted. Supplying an empty string will likely result in rejection.
  32. 1 attr_accessor :cv_token
  33. 1 class EnumAttributeValidator
  34. 1 attr_reader :datatype
  35. 1 attr_reader :allowable_values
  36. 1 def initialize(datatype, allowable_values)
  37. @allowable_values = allowable_values.map do |value|
  38. case datatype.to_s
  39. when /Integer/i
  40. value.to_i
  41. when /Float/i
  42. value.to_f
  43. else
  44. value
  45. end
  46. end
  47. end
  48. 1 def valid?(value)
  49. !value || allowable_values.include?(value)
  50. end
  51. end
  52. # Attribute mapping from ruby-style variable name to JSON key.
  53. 1 def self.attribute_map
  54. 105 {
  55. :'phone_number' => :'phoneNumber',
  56. :'status' => :'status',
  57. :'internal_ticket_number' => :'internalTicketNumber',
  58. :'decline_reason_description' => :'declineReasonDescription',
  59. :'resubmit_allowed' => :'resubmitAllowed',
  60. :'created_date_time' => :'createdDateTime',
  61. :'modified_date_time' => :'modifiedDateTime',
  62. :'submission' => :'submission',
  63. :'blocked' => :'blocked',
  64. :'blocked_reason' => :'blockedReason',
  65. :'cv_token' => :'cvToken'
  66. }
  67. end
  68. # Returns attribute mapping this model knows about
  69. 1 def self.acceptable_attribute_map
  70. 14 attribute_map
  71. end
  72. # Returns all the JSON keys this model knows about
  73. 1 def self.acceptable_attributes
  74. 1 acceptable_attribute_map.values
  75. end
  76. # Attribute type mapping.
  77. 1 def self.openapi_types
  78. 2 {
  79. :'phone_number' => :'String',
  80. :'status' => :'TfvStatusEnum',
  81. :'internal_ticket_number' => :'String',
  82. :'decline_reason_description' => :'String',
  83. :'resubmit_allowed' => :'Boolean',
  84. :'created_date_time' => :'Time',
  85. :'modified_date_time' => :'Time',
  86. :'submission' => :'TfvSubmissionInfo',
  87. :'blocked' => :'Boolean',
  88. :'blocked_reason' => :'String',
  89. :'cv_token' => :'String'
  90. }
  91. end
  92. # List of attributes with nullable: true
  93. 1 def self.openapi_nullable
  94. 1 Set.new([
  95. :'cv_token'
  96. ])
  97. end
  98. # Initializes the object
  99. # @param [Hash] attributes Model attributes in the form of hash
  100. 1 def initialize(attributes = {})
  101. 14 if (!attributes.is_a?(Hash))
  102. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::TfvStatus` initialize method'
  103. end
  104. # check to see if the attribute exists and convert string to symbol for hash key
  105. 13 acceptable_attribute_map = self.class.acceptable_attribute_map
  106. 13 attributes = attributes.each_with_object({}) { |(k, v), h|
  107. 61 if (!acceptable_attribute_map.key?(k.to_sym))
  108. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::TfvStatus`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  109. end
  110. 60 h[k.to_sym] = v
  111. }
  112. 12 if attributes.key?(:'phone_number')
  113. 9 self.phone_number = attributes[:'phone_number']
  114. end
  115. 8 if attributes.key?(:'status')
  116. 5 self.status = attributes[:'status']
  117. end
  118. 8 if attributes.key?(:'internal_ticket_number')
  119. 5 self.internal_ticket_number = attributes[:'internal_ticket_number']
  120. end
  121. 8 if attributes.key?(:'decline_reason_description')
  122. 5 self.decline_reason_description = attributes[:'decline_reason_description']
  123. end
  124. 8 if attributes.key?(:'resubmit_allowed')
  125. 5 self.resubmit_allowed = attributes[:'resubmit_allowed']
  126. end
  127. 8 if attributes.key?(:'created_date_time')
  128. 5 self.created_date_time = attributes[:'created_date_time']
  129. end
  130. 8 if attributes.key?(:'modified_date_time')
  131. 5 self.modified_date_time = attributes[:'modified_date_time']
  132. end
  133. 8 if attributes.key?(:'submission')
  134. 5 self.submission = attributes[:'submission']
  135. end
  136. 8 if attributes.key?(:'blocked')
  137. 5 self.blocked = attributes[:'blocked']
  138. end
  139. 8 if attributes.key?(:'blocked_reason')
  140. 5 self.blocked_reason = attributes[:'blocked_reason']
  141. end
  142. 8 if attributes.key?(:'cv_token')
  143. 6 self.cv_token = attributes[:'cv_token']
  144. end
  145. end
  146. # Show invalid properties with the reasons. Usually used together with valid?
  147. # @return Array for valid properties with the reasons
  148. 1 def list_invalid_properties
  149. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  150. invalid_properties = Array.new
  151. if !@phone_number.nil? && @phone_number.to_s.length > 12
  152. invalid_properties.push('invalid value for "phone_number", the character length must be smaller than or equal to 12.')
  153. end
  154. if !@phone_number.nil? && @phone_number.to_s.length < 12
  155. invalid_properties.push('invalid value for "phone_number", the character length must be greater than or equal to 12.')
  156. end
  157. pattern = Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
  158. if !@phone_number.nil? && @phone_number !~ pattern
  159. invalid_properties.push("invalid value for \"phone_number\", must conform to the pattern #{pattern}.")
  160. end
  161. if !@cv_token.nil? && @cv_token.to_s.length > 500
  162. invalid_properties.push('invalid value for "cv_token", the character length must be smaller than or equal to 500.')
  163. end
  164. if !@cv_token.nil? && @cv_token.to_s.length < 0
  165. invalid_properties.push('invalid value for "cv_token", the character length must be greater than or equal to 0.')
  166. end
  167. invalid_properties
  168. end
  169. # Check to see if the all the properties in the model are valid
  170. # @return true if the model is valid
  171. 1 def valid?
  172. warn '[DEPRECATED] the `valid?` method is obsolete'
  173. return false if !@phone_number.nil? && @phone_number.to_s.length > 12
  174. return false if !@phone_number.nil? && @phone_number.to_s.length < 12
  175. return false if !@phone_number.nil? && @phone_number !~ Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
  176. return false if !@cv_token.nil? && @cv_token.to_s.length > 500
  177. return false if !@cv_token.nil? && @cv_token.to_s.length < 0
  178. true
  179. end
  180. # Custom attribute writer method with validation
  181. # @param [Object] phone_number Value to be assigned
  182. 1 def phone_number=(phone_number)
  183. 9 if phone_number.nil?
  184. 1 fail ArgumentError, 'phone_number cannot be nil'
  185. end
  186. 8 if phone_number.to_s.length > 12
  187. 1 fail ArgumentError, 'invalid value for "phone_number", the character length must be smaller than or equal to 12.'
  188. end
  189. 7 if phone_number.to_s.length < 12
  190. 1 fail ArgumentError, 'invalid value for "phone_number", the character length must be greater than or equal to 12.'
  191. end
  192. 6 pattern = Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
  193. 6 if phone_number !~ pattern
  194. 1 fail ArgumentError, "invalid value for \"phone_number\", must conform to the pattern #{pattern}."
  195. end
  196. 5 @phone_number = phone_number
  197. end
  198. # Custom attribute writer method with validation
  199. # @param [Object] cv_token Value to be assigned
  200. 1 def cv_token=(cv_token)
  201. 6 if !cv_token.nil? && cv_token.to_s.length > 500
  202. 1 fail ArgumentError, 'invalid value for "cv_token", the character length must be smaller than or equal to 500.'
  203. end
  204. 5 if !cv_token.nil? && cv_token.to_s.length < 0
  205. fail ArgumentError, 'invalid value for "cv_token", the character length must be greater than or equal to 0.'
  206. end
  207. 5 @cv_token = cv_token
  208. end
  209. # Checks equality by comparing each attribute.
  210. # @param [Object] Object to be compared
  211. 1 def ==(o)
  212. 2 return true if self.equal?(o)
  213. 2 self.class == o.class &&
  214. phone_number == o.phone_number &&
  215. status == o.status &&
  216. internal_ticket_number == o.internal_ticket_number &&
  217. decline_reason_description == o.decline_reason_description &&
  218. resubmit_allowed == o.resubmit_allowed &&
  219. created_date_time == o.created_date_time &&
  220. modified_date_time == o.modified_date_time &&
  221. submission == o.submission &&
  222. blocked == o.blocked &&
  223. blocked_reason == o.blocked_reason &&
  224. cv_token == o.cv_token
  225. end
  226. # @see the `==` method
  227. # @param [Object] Object to be compared
  228. 1 def eql?(o)
  229. 2 self == o
  230. end
  231. # Calculates hash code according to all attributes.
  232. # @return [Integer] Hash code
  233. 1 def hash
  234. [phone_number, status, internal_ticket_number, decline_reason_description, resubmit_allowed, created_date_time, modified_date_time, submission, blocked, blocked_reason, cv_token].hash
  235. end
  236. # Builds the object from hash
  237. # @param [Hash] attributes Model attributes in the form of hash
  238. # @return [Object] Returns the model itself
  239. 1 def self.build_from_hash(attributes)
  240. 2 return nil unless attributes.is_a?(Hash)
  241. 2 attributes = attributes.transform_keys(&:to_sym)
  242. 2 transformed_hash = {}
  243. 2 openapi_types.each_pair do |key, type|
  244. 22 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  245. transformed_hash["#{key}"] = nil
  246. 22 elsif type =~ /\AArray<(.*)>/i
  247. # check to ensure the input is an array given that the attribute
  248. # is documented as an array but the input is not
  249. if attributes[attribute_map[key]].is_a?(Array)
  250. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  251. end
  252. 22 elsif !attributes[attribute_map[key]].nil?
  253. 22 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  254. end
  255. end
  256. 2 new(transformed_hash)
  257. end
  258. # Returns the object in the form of hash
  259. # @return [Hash] Returns the object in the form of hash
  260. 1 def to_hash
  261. 2 hash = {}
  262. 2 self.class.attribute_map.each_pair do |attr, param|
  263. 22 value = self.send(attr)
  264. 22 if value.nil?
  265. is_nullable = self.class.openapi_nullable.include?(attr)
  266. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  267. end
  268. 22 hash[param] = _to_hash(value)
  269. end
  270. 2 hash
  271. end
  272. end
  273. end

lib/bandwidth-sdk/models/tfv_status_enum.rb

100.0% lines covered

14 relevant lines. 14 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class TfvStatusEnum
  13. 1 VERIFIED = 'VERIFIED'.freeze
  14. 1 UNVERIFIED = 'UNVERIFIED'.freeze
  15. 1 PENDING = 'PENDING'.freeze
  16. 1 def self.all_vars
  17. 8 @all_vars ||= [VERIFIED, UNVERIFIED, PENDING].freeze
  18. end
  19. # Builds the enum from string
  20. # @param [String] The enum value in the form of the string
  21. # @return [String] The enum value
  22. 1 def self.build_from_hash(value)
  23. 6 new.build_from_hash(value)
  24. end
  25. # Builds the enum from string
  26. # @param [String] The enum value in the form of the string
  27. # @return [String] The enum value
  28. 1 def build_from_hash(value)
  29. 6 return value if TfvStatusEnum.all_vars.include?(value)
  30. 1 raise "Invalid ENUM value #{value} for class #TfvStatusEnum"
  31. end
  32. end
  33. end

lib/bandwidth-sdk/models/tfv_submission_info.rb

69.7% lines covered

231 relevant lines. 161 lines covered and 70 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class TfvSubmissionInfo < ApiModelBase
  13. 1 attr_accessor :business_address
  14. 1 attr_accessor :business_contact
  15. # Estimated monthly volume of messages from the toll-free number.
  16. 1 attr_accessor :message_volume
  17. # The category of the use case.
  18. 1 attr_accessor :use_case
  19. # A general idea of the use case and customer.
  20. 1 attr_accessor :use_case_summary
  21. # Example of message content.
  22. 1 attr_accessor :production_message_content
  23. 1 attr_accessor :opt_in_workflow
  24. # Any additional information.
  25. 1 attr_accessor :additional_information
  26. # ISV name.
  27. 1 attr_accessor :isv_reseller
  28. # The Toll-Free Verification request privacy policy URL.
  29. 1 attr_accessor :privacy_policy_url
  30. # The Toll-Free Verification request terms and conditions policy URL.
  31. 1 attr_accessor :terms_and_conditions_url
  32. # The company 'Doing Business As'.
  33. 1 attr_accessor :business_dba
  34. # Government-issued business identifying number. **Note: As of October 19th, 2026 this field will be required when `businessEntityType` is _not_ `SOLE_PROPRIETOR`. If this field is provided, `businessRegistrationType` and `businessRegistrationIssuingCountry` are also required.**
  35. 1 attr_accessor :business_registration_number
  36. 1 attr_accessor :business_registration_type
  37. # The country issuing the business registration in ISO-3166-1 alpha-3 format. Alpha-2 format is accepted by the API, but alpha-3 is highly encouraged. **Note: As of October 19th, 2026 this field will be required when `businessRegistrationNumber` is provided.** | Registration Type | Supported Countries | |----------------------|------------------------------------| | EIN | USA | | CBN | CAN | | NEQ | CAN | | PROVINCIAL_NUMBER | CAN | | CRN | GBR, HKG | | VAT | GBR, IRL, BRA, NLD | | ACN | AUS | | ABN | AUS | | BRN | HKG | | SIREN | FRA | | SIRET | FRA | | NZBN | NZL | | UST_IDNR | DEU | | CIF | ESP | | NIF | ESP | | CNPJ | BRA | | UID | CHE | | OTHER | Must Provide Country Code |
  38. 1 attr_accessor :business_registration_issuing_country
  39. 1 attr_accessor :business_entity_type
  40. 1 class EnumAttributeValidator
  41. 1 attr_reader :datatype
  42. 1 attr_reader :allowable_values
  43. 1 def initialize(datatype, allowable_values)
  44. @allowable_values = allowable_values.map do |value|
  45. case datatype.to_s
  46. when /Integer/i
  47. value.to_i
  48. when /Float/i
  49. value.to_f
  50. else
  51. value
  52. end
  53. end
  54. end
  55. 1 def valid?(value)
  56. !value || allowable_values.include?(value)
  57. end
  58. end
  59. # Attribute mapping from ruby-style variable name to JSON key.
  60. 1 def self.attribute_map
  61. 193 {
  62. :'business_address' => :'businessAddress',
  63. :'business_contact' => :'businessContact',
  64. :'message_volume' => :'messageVolume',
  65. :'use_case' => :'useCase',
  66. :'use_case_summary' => :'useCaseSummary',
  67. :'production_message_content' => :'productionMessageContent',
  68. :'opt_in_workflow' => :'optInWorkflow',
  69. :'additional_information' => :'additionalInformation',
  70. :'isv_reseller' => :'isvReseller',
  71. :'privacy_policy_url' => :'privacyPolicyUrl',
  72. :'terms_and_conditions_url' => :'termsAndConditionsUrl',
  73. :'business_dba' => :'businessDba',
  74. :'business_registration_number' => :'businessRegistrationNumber',
  75. :'business_registration_type' => :'businessRegistrationType',
  76. :'business_registration_issuing_country' => :'businessRegistrationIssuingCountry',
  77. :'business_entity_type' => :'businessEntityType'
  78. }
  79. end
  80. # Returns attribute mapping this model knows about
  81. 1 def self.acceptable_attribute_map
  82. 28 attribute_map
  83. end
  84. # Returns all the JSON keys this model knows about
  85. 1 def self.acceptable_attributes
  86. 1 acceptable_attribute_map.values
  87. end
  88. # Attribute type mapping.
  89. 1 def self.openapi_types
  90. 3 {
  91. :'business_address' => :'Address',
  92. :'business_contact' => :'Contact',
  93. :'message_volume' => :'Integer',
  94. :'use_case' => :'String',
  95. :'use_case_summary' => :'String',
  96. :'production_message_content' => :'String',
  97. :'opt_in_workflow' => :'OptInWorkflow',
  98. :'additional_information' => :'String',
  99. :'isv_reseller' => :'String',
  100. :'privacy_policy_url' => :'String',
  101. :'terms_and_conditions_url' => :'String',
  102. :'business_dba' => :'String',
  103. :'business_registration_number' => :'String',
  104. :'business_registration_type' => :'BusinessRegistrationTypeEnum',
  105. :'business_registration_issuing_country' => :'String',
  106. :'business_entity_type' => :'BusinessEntityTypeEnum'
  107. }
  108. end
  109. # List of attributes with nullable: true
  110. 1 def self.openapi_nullable
  111. 1 Set.new([
  112. :'additional_information',
  113. :'isv_reseller',
  114. :'business_registration_number',
  115. :'business_registration_type',
  116. :'business_registration_issuing_country',
  117. ])
  118. end
  119. # Initializes the object
  120. # @param [Hash] attributes Model attributes in the form of hash
  121. 1 def initialize(attributes = {})
  122. 28 if (!attributes.is_a?(Hash))
  123. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::TfvSubmissionInfo` initialize method'
  124. end
  125. # check to see if the attribute exists and convert string to symbol for hash key
  126. 27 acceptable_attribute_map = self.class.acceptable_attribute_map
  127. 27 attributes = attributes.each_with_object({}) { |(k, v), h|
  128. 100 if (!acceptable_attribute_map.key?(k.to_sym))
  129. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::TfvSubmissionInfo`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  130. end
  131. 99 h[k.to_sym] = v
  132. }
  133. 26 if attributes.key?(:'business_address')
  134. 6 self.business_address = attributes[:'business_address']
  135. end
  136. 26 if attributes.key?(:'business_contact')
  137. 5 self.business_contact = attributes[:'business_contact']
  138. end
  139. 26 if attributes.key?(:'message_volume')
  140. 8 self.message_volume = attributes[:'message_volume']
  141. end
  142. 23 if attributes.key?(:'use_case')
  143. 7 self.use_case = attributes[:'use_case']
  144. end
  145. 21 if attributes.key?(:'use_case_summary')
  146. 7 self.use_case_summary = attributes[:'use_case_summary']
  147. end
  148. 19 if attributes.key?(:'production_message_content')
  149. 7 self.production_message_content = attributes[:'production_message_content']
  150. end
  151. 17 if attributes.key?(:'opt_in_workflow')
  152. 5 self.opt_in_workflow = attributes[:'opt_in_workflow']
  153. end
  154. 17 if attributes.key?(:'additional_information')
  155. 6 self.additional_information = attributes[:'additional_information']
  156. end
  157. 16 if attributes.key?(:'isv_reseller')
  158. 6 self.isv_reseller = attributes[:'isv_reseller']
  159. end
  160. 15 if attributes.key?(:'privacy_policy_url')
  161. 7 self.privacy_policy_url = attributes[:'privacy_policy_url']
  162. end
  163. 13 if attributes.key?(:'terms_and_conditions_url')
  164. 7 self.terms_and_conditions_url = attributes[:'terms_and_conditions_url']
  165. end
  166. 11 if attributes.key?(:'business_dba')
  167. 7 self.business_dba = attributes[:'business_dba']
  168. end
  169. 9 if attributes.key?(:'business_registration_number')
  170. 6 self.business_registration_number = attributes[:'business_registration_number']
  171. end
  172. 8 if attributes.key?(:'business_registration_type')
  173. 5 self.business_registration_type = attributes[:'business_registration_type']
  174. end
  175. 8 if attributes.key?(:'business_registration_issuing_country')
  176. 5 self.business_registration_issuing_country = attributes[:'business_registration_issuing_country']
  177. end
  178. 8 if attributes.key?(:'business_entity_type')
  179. 5 self.business_entity_type = attributes[:'business_entity_type']
  180. end
  181. end
  182. # Show invalid properties with the reasons. Usually used together with valid?
  183. # @return Array for valid properties with the reasons
  184. 1 def list_invalid_properties
  185. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  186. invalid_properties = Array.new
  187. if !@message_volume.nil? && @message_volume > 10000000
  188. invalid_properties.push('invalid value for "message_volume", must be smaller than or equal to 10000000.')
  189. end
  190. if !@message_volume.nil? && @message_volume < 10
  191. invalid_properties.push('invalid value for "message_volume", must be greater than or equal to 10.')
  192. end
  193. if !@use_case.nil? && @use_case.to_s.length > 500
  194. invalid_properties.push('invalid value for "use_case", the character length must be smaller than or equal to 500.')
  195. end
  196. if !@use_case.nil? && @use_case.to_s.length < 0
  197. invalid_properties.push('invalid value for "use_case", the character length must be greater than or equal to 0.')
  198. end
  199. if !@use_case_summary.nil? && @use_case_summary.to_s.length > 500
  200. invalid_properties.push('invalid value for "use_case_summary", the character length must be smaller than or equal to 500.')
  201. end
  202. if !@use_case_summary.nil? && @use_case_summary.to_s.length < 0
  203. invalid_properties.push('invalid value for "use_case_summary", the character length must be greater than or equal to 0.')
  204. end
  205. if !@production_message_content.nil? && @production_message_content.to_s.length > 500
  206. invalid_properties.push('invalid value for "production_message_content", the character length must be smaller than or equal to 500.')
  207. end
  208. if !@production_message_content.nil? && @production_message_content.to_s.length < 0
  209. invalid_properties.push('invalid value for "production_message_content", the character length must be greater than or equal to 0.')
  210. end
  211. if !@additional_information.nil? && @additional_information.to_s.length > 500
  212. invalid_properties.push('invalid value for "additional_information", the character length must be smaller than or equal to 500.')
  213. end
  214. if !@additional_information.nil? && @additional_information.to_s.length < 0
  215. invalid_properties.push('invalid value for "additional_information", the character length must be greater than or equal to 0.')
  216. end
  217. if !@isv_reseller.nil? && @isv_reseller.to_s.length > 500
  218. invalid_properties.push('invalid value for "isv_reseller", the character length must be smaller than or equal to 500.')
  219. end
  220. if !@isv_reseller.nil? && @isv_reseller.to_s.length < 0
  221. invalid_properties.push('invalid value for "isv_reseller", the character length must be greater than or equal to 0.')
  222. end
  223. if !@privacy_policy_url.nil? && @privacy_policy_url.to_s.length > 500
  224. invalid_properties.push('invalid value for "privacy_policy_url", the character length must be smaller than or equal to 500.')
  225. end
  226. if !@terms_and_conditions_url.nil? && @terms_and_conditions_url.to_s.length > 500
  227. invalid_properties.push('invalid value for "terms_and_conditions_url", the character length must be smaller than or equal to 500.')
  228. end
  229. if !@business_dba.nil? && @business_dba.to_s.length > 500
  230. invalid_properties.push('invalid value for "business_dba", the character length must be smaller than or equal to 500.')
  231. end
  232. if !@business_registration_number.nil? && @business_registration_number.to_s.length > 500
  233. invalid_properties.push('invalid value for "business_registration_number", the character length must be smaller than or equal to 500.')
  234. end
  235. invalid_properties
  236. end
  237. # Check to see if the all the properties in the model are valid
  238. # @return true if the model is valid
  239. 1 def valid?
  240. warn '[DEPRECATED] the `valid?` method is obsolete'
  241. return false if !@message_volume.nil? && @message_volume > 10000000
  242. return false if !@message_volume.nil? && @message_volume < 10
  243. return false if !@use_case.nil? && @use_case.to_s.length > 500
  244. return false if !@use_case.nil? && @use_case.to_s.length < 0
  245. return false if !@use_case_summary.nil? && @use_case_summary.to_s.length > 500
  246. return false if !@use_case_summary.nil? && @use_case_summary.to_s.length < 0
  247. return false if !@production_message_content.nil? && @production_message_content.to_s.length > 500
  248. return false if !@production_message_content.nil? && @production_message_content.to_s.length < 0
  249. return false if !@additional_information.nil? && @additional_information.to_s.length > 500
  250. return false if !@additional_information.nil? && @additional_information.to_s.length < 0
  251. return false if !@isv_reseller.nil? && @isv_reseller.to_s.length > 500
  252. return false if !@isv_reseller.nil? && @isv_reseller.to_s.length < 0
  253. return false if !@privacy_policy_url.nil? && @privacy_policy_url.to_s.length > 500
  254. return false if !@terms_and_conditions_url.nil? && @terms_and_conditions_url.to_s.length > 500
  255. return false if !@business_dba.nil? && @business_dba.to_s.length > 500
  256. return false if !@business_registration_number.nil? && @business_registration_number.to_s.length > 500
  257. true
  258. end
  259. # Custom attribute writer method with validation
  260. # @param [Object] message_volume Value to be assigned
  261. 1 def message_volume=(message_volume)
  262. 8 if message_volume.nil?
  263. 1 fail ArgumentError, 'message_volume cannot be nil'
  264. end
  265. 7 if message_volume > 10000000
  266. 1 fail ArgumentError, 'invalid value for "message_volume", must be smaller than or equal to 10000000.'
  267. end
  268. 6 if message_volume < 10
  269. 1 fail ArgumentError, 'invalid value for "message_volume", must be greater than or equal to 10.'
  270. end
  271. 5 @message_volume = message_volume
  272. end
  273. # Custom attribute writer method with validation
  274. # @param [Object] use_case Value to be assigned
  275. 1 def use_case=(use_case)
  276. 7 if use_case.nil?
  277. 1 fail ArgumentError, 'use_case cannot be nil'
  278. end
  279. 6 if use_case.to_s.length > 500
  280. 1 fail ArgumentError, 'invalid value for "use_case", the character length must be smaller than or equal to 500.'
  281. end
  282. 5 if use_case.to_s.length < 0
  283. fail ArgumentError, 'invalid value for "use_case", the character length must be greater than or equal to 0.'
  284. end
  285. 5 @use_case = use_case
  286. end
  287. # Custom attribute writer method with validation
  288. # @param [Object] use_case_summary Value to be assigned
  289. 1 def use_case_summary=(use_case_summary)
  290. 7 if use_case_summary.nil?
  291. 1 fail ArgumentError, 'use_case_summary cannot be nil'
  292. end
  293. 6 if use_case_summary.to_s.length > 500
  294. 1 fail ArgumentError, 'invalid value for "use_case_summary", the character length must be smaller than or equal to 500.'
  295. end
  296. 5 if use_case_summary.to_s.length < 0
  297. fail ArgumentError, 'invalid value for "use_case_summary", the character length must be greater than or equal to 0.'
  298. end
  299. 5 @use_case_summary = use_case_summary
  300. end
  301. # Custom attribute writer method with validation
  302. # @param [Object] production_message_content Value to be assigned
  303. 1 def production_message_content=(production_message_content)
  304. 7 if production_message_content.nil?
  305. 1 fail ArgumentError, 'production_message_content cannot be nil'
  306. end
  307. 6 if production_message_content.to_s.length > 500
  308. 1 fail ArgumentError, 'invalid value for "production_message_content", the character length must be smaller than or equal to 500.'
  309. end
  310. 5 if production_message_content.to_s.length < 0
  311. fail ArgumentError, 'invalid value for "production_message_content", the character length must be greater than or equal to 0.'
  312. end
  313. 5 @production_message_content = production_message_content
  314. end
  315. # Custom attribute writer method with validation
  316. # @param [Object] additional_information Value to be assigned
  317. 1 def additional_information=(additional_information)
  318. 6 if !additional_information.nil? && additional_information.to_s.length > 500
  319. 1 fail ArgumentError, 'invalid value for "additional_information", the character length must be smaller than or equal to 500.'
  320. end
  321. 5 if !additional_information.nil? && additional_information.to_s.length < 0
  322. fail ArgumentError, 'invalid value for "additional_information", the character length must be greater than or equal to 0.'
  323. end
  324. 5 @additional_information = additional_information
  325. end
  326. # Custom attribute writer method with validation
  327. # @param [Object] isv_reseller Value to be assigned
  328. 1 def isv_reseller=(isv_reseller)
  329. 6 if !isv_reseller.nil? && isv_reseller.to_s.length > 500
  330. 1 fail ArgumentError, 'invalid value for "isv_reseller", the character length must be smaller than or equal to 500.'
  331. end
  332. 5 if !isv_reseller.nil? && isv_reseller.to_s.length < 0
  333. fail ArgumentError, 'invalid value for "isv_reseller", the character length must be greater than or equal to 0.'
  334. end
  335. 5 @isv_reseller = isv_reseller
  336. end
  337. # Custom attribute writer method with validation
  338. # @param [Object] privacy_policy_url Value to be assigned
  339. 1 def privacy_policy_url=(privacy_policy_url)
  340. 7 if privacy_policy_url.nil?
  341. 1 fail ArgumentError, 'privacy_policy_url cannot be nil'
  342. end
  343. 6 if privacy_policy_url.to_s.length > 500
  344. 1 fail ArgumentError, 'invalid value for "privacy_policy_url", the character length must be smaller than or equal to 500.'
  345. end
  346. 5 @privacy_policy_url = privacy_policy_url
  347. end
  348. # Custom attribute writer method with validation
  349. # @param [Object] terms_and_conditions_url Value to be assigned
  350. 1 def terms_and_conditions_url=(terms_and_conditions_url)
  351. 7 if terms_and_conditions_url.nil?
  352. 1 fail ArgumentError, 'terms_and_conditions_url cannot be nil'
  353. end
  354. 6 if terms_and_conditions_url.to_s.length > 500
  355. 1 fail ArgumentError, 'invalid value for "terms_and_conditions_url", the character length must be smaller than or equal to 500.'
  356. end
  357. 5 @terms_and_conditions_url = terms_and_conditions_url
  358. end
  359. # Custom attribute writer method with validation
  360. # @param [Object] business_dba Value to be assigned
  361. 1 def business_dba=(business_dba)
  362. 7 if business_dba.nil?
  363. 1 fail ArgumentError, 'business_dba cannot be nil'
  364. end
  365. 6 if business_dba.to_s.length > 500
  366. 1 fail ArgumentError, 'invalid value for "business_dba", the character length must be smaller than or equal to 500.'
  367. end
  368. 5 @business_dba = business_dba
  369. end
  370. # Custom attribute writer method with validation
  371. # @param [Object] business_registration_number Value to be assigned
  372. 1 def business_registration_number=(business_registration_number)
  373. 6 if !business_registration_number.nil? && business_registration_number.to_s.length > 500
  374. 1 fail ArgumentError, 'invalid value for "business_registration_number", the character length must be smaller than or equal to 500.'
  375. end
  376. 5 @business_registration_number = business_registration_number
  377. end
  378. # Checks equality by comparing each attribute.
  379. # @param [Object] Object to be compared
  380. 1 def ==(o)
  381. 2 return true if self.equal?(o)
  382. 2 self.class == o.class &&
  383. business_address == o.business_address &&
  384. business_contact == o.business_contact &&
  385. message_volume == o.message_volume &&
  386. use_case == o.use_case &&
  387. use_case_summary == o.use_case_summary &&
  388. production_message_content == o.production_message_content &&
  389. opt_in_workflow == o.opt_in_workflow &&
  390. additional_information == o.additional_information &&
  391. isv_reseller == o.isv_reseller &&
  392. privacy_policy_url == o.privacy_policy_url &&
  393. terms_and_conditions_url == o.terms_and_conditions_url &&
  394. business_dba == o.business_dba &&
  395. business_registration_number == o.business_registration_number &&
  396. business_registration_type == o.business_registration_type &&
  397. business_registration_issuing_country == o.business_registration_issuing_country &&
  398. business_entity_type == o.business_entity_type
  399. end
  400. # @see the `==` method
  401. # @param [Object] Object to be compared
  402. 1 def eql?(o)
  403. 2 self == o
  404. end
  405. # Calculates hash code according to all attributes.
  406. # @return [Integer] Hash code
  407. 1 def hash
  408. [business_address, business_contact, message_volume, use_case, use_case_summary, production_message_content, opt_in_workflow, additional_information, isv_reseller, privacy_policy_url, terms_and_conditions_url, business_dba, business_registration_number, business_registration_type, business_registration_issuing_country, business_entity_type].hash
  409. end
  410. # Builds the object from hash
  411. # @param [Hash] attributes Model attributes in the form of hash
  412. # @return [Object] Returns the model itself
  413. 1 def self.build_from_hash(attributes)
  414. 3 return nil unless attributes.is_a?(Hash)
  415. 3 attributes = attributes.transform_keys(&:to_sym)
  416. 3 transformed_hash = {}
  417. 3 openapi_types.each_pair do |key, type|
  418. 48 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  419. transformed_hash["#{key}"] = nil
  420. 48 elsif type =~ /\AArray<(.*)>/i
  421. # check to ensure the input is an array given that the attribute
  422. # is documented as an array but the input is not
  423. if attributes[attribute_map[key]].is_a?(Array)
  424. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  425. end
  426. 48 elsif !attributes[attribute_map[key]].nil?
  427. 33 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  428. end
  429. end
  430. 3 new(transformed_hash)
  431. end
  432. # Returns the object in the form of hash
  433. # @return [Hash] Returns the object in the form of hash
  434. 1 def to_hash
  435. 2 hash = {}
  436. 2 self.class.attribute_map.each_pair do |attr, param|
  437. 32 value = self.send(attr)
  438. 32 if value.nil?
  439. is_nullable = self.class.openapi_nullable.include?(attr)
  440. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  441. end
  442. 32 hash[param] = _to_hash(value)
  443. end
  444. 2 hash
  445. end
  446. end
  447. end

lib/bandwidth-sdk/models/tfv_submission_wrapper.rb

81.97% lines covered

61 relevant lines. 50 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class TfvSubmissionWrapper < ApiModelBase
  13. 1 attr_accessor :submission
  14. # Attribute mapping from ruby-style variable name to JSON key.
  15. 1 def self.attribute_map
  16. 17 {
  17. :'submission' => :'submission'
  18. }
  19. end
  20. # Returns attribute mapping this model knows about
  21. 1 def self.acceptable_attribute_map
  22. 9 attribute_map
  23. end
  24. # Returns all the JSON keys this model knows about
  25. 1 def self.acceptable_attributes
  26. 1 acceptable_attribute_map.values
  27. end
  28. # Attribute type mapping.
  29. 1 def self.openapi_types
  30. 1 {
  31. :'submission' => :'VerificationUpdateRequest'
  32. }
  33. end
  34. # List of attributes with nullable: true
  35. 1 def self.openapi_nullable
  36. 1 Set.new([
  37. ])
  38. end
  39. # Initializes the object
  40. # @param [Hash] attributes Model attributes in the form of hash
  41. 1 def initialize(attributes = {})
  42. 9 if (!attributes.is_a?(Hash))
  43. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::TfvSubmissionWrapper` initialize method'
  44. end
  45. # check to see if the attribute exists and convert string to symbol for hash key
  46. 8 acceptable_attribute_map = self.class.acceptable_attribute_map
  47. 8 attributes = attributes.each_with_object({}) { |(k, v), h|
  48. 6 if (!acceptable_attribute_map.key?(k.to_sym))
  49. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::TfvSubmissionWrapper`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  50. end
  51. 5 h[k.to_sym] = v
  52. }
  53. 7 if attributes.key?(:'submission')
  54. 5 self.submission = attributes[:'submission']
  55. end
  56. end
  57. # Show invalid properties with the reasons. Usually used together with valid?
  58. # @return Array for valid properties with the reasons
  59. 1 def list_invalid_properties
  60. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  61. invalid_properties = Array.new
  62. invalid_properties
  63. end
  64. # Check to see if the all the properties in the model are valid
  65. # @return true if the model is valid
  66. 1 def valid?
  67. warn '[DEPRECATED] the `valid?` method is obsolete'
  68. true
  69. end
  70. # Checks equality by comparing each attribute.
  71. # @param [Object] Object to be compared
  72. 1 def ==(o)
  73. 2 return true if self.equal?(o)
  74. 2 self.class == o.class &&
  75. submission == o.submission
  76. end
  77. # @see the `==` method
  78. # @param [Object] Object to be compared
  79. 1 def eql?(o)
  80. 2 self == o
  81. end
  82. # Calculates hash code according to all attributes.
  83. # @return [Integer] Hash code
  84. 1 def hash
  85. [submission].hash
  86. end
  87. # Builds the object from hash
  88. # @param [Hash] attributes Model attributes in the form of hash
  89. # @return [Object] Returns the model itself
  90. 1 def self.build_from_hash(attributes)
  91. 1 return nil unless attributes.is_a?(Hash)
  92. 1 attributes = attributes.transform_keys(&:to_sym)
  93. 1 transformed_hash = {}
  94. 1 openapi_types.each_pair do |key, type|
  95. 1 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  96. transformed_hash["#{key}"] = nil
  97. 1 elsif type =~ /\AArray<(.*)>/i
  98. # check to ensure the input is an array given that the attribute
  99. # is documented as an array but the input is not
  100. if attributes[attribute_map[key]].is_a?(Array)
  101. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  102. end
  103. 1 elsif !attributes[attribute_map[key]].nil?
  104. 1 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  105. end
  106. end
  107. 1 new(transformed_hash)
  108. end
  109. # Returns the object in the form of hash
  110. # @return [Hash] Returns the object in the form of hash
  111. 1 def to_hash
  112. 3 hash = {}
  113. 3 self.class.attribute_map.each_pair do |attr, param|
  114. 3 value = self.send(attr)
  115. 3 if value.nil?
  116. is_nullable = self.class.openapi_nullable.include?(attr)
  117. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  118. end
  119. 3 hash[param] = _to_hash(value)
  120. end
  121. 3 hash
  122. end
  123. end
  124. end

lib/bandwidth-sdk/models/thumbnail_alignment_enum.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class ThumbnailAlignmentEnum
  13. 1 LEFT = 'LEFT'.freeze
  14. 1 RIGHT = 'RIGHT'.freeze
  15. 1 def self.all_vars
  16. 6 @all_vars ||= [LEFT, RIGHT].freeze
  17. end
  18. # Builds the enum from string
  19. # @param [String] The enum value in the form of the string
  20. # @return [String] The enum value
  21. 1 def self.build_from_hash(value)
  22. 5 new.build_from_hash(value)
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def build_from_hash(value)
  28. 5 return value if ThumbnailAlignmentEnum.all_vars.include?(value)
  29. 1 raise "Invalid ENUM value #{value} for class #ThumbnailAlignmentEnum"
  30. end
  31. end
  32. end

lib/bandwidth-sdk/models/transcribe_recording.rb

77.31% lines covered

119 relevant lines. 92 lines covered and 27 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class TranscribeRecording < ApiModelBase
  13. # The URL to send the [TranscriptionAvailable](/docs/voice/webhooks/transcriptionAvailable) event to. You should not include sensitive or personally-identifiable information in the callbackUrl field! Always use the proper username and password fields for authorization.
  14. 1 attr_accessor :callback_url
  15. 1 attr_accessor :callback_method
  16. # Basic auth username.
  17. 1 attr_accessor :username
  18. # Basic auth password.
  19. 1 attr_accessor :password
  20. # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.
  21. 1 attr_accessor :tag
  22. # This is the timeout (in seconds) to use when delivering the webhook to `callbackUrl`. Can be any numeric value (including decimals) between 1 and 25.
  23. 1 attr_accessor :callback_timeout
  24. # A boolean value to indicate that the recording may not be in English, and the transcription service will need to detect the dominant language the recording is in and transcribe accordingly. Current supported languages are English, French, and Spanish.
  25. 1 attr_accessor :detect_language
  26. 1 class EnumAttributeValidator
  27. 1 attr_reader :datatype
  28. 1 attr_reader :allowable_values
  29. 1 def initialize(datatype, allowable_values)
  30. @allowable_values = allowable_values.map do |value|
  31. case datatype.to_s
  32. when /Integer/i
  33. value.to_i
  34. when /Float/i
  35. value.to_f
  36. else
  37. value
  38. end
  39. end
  40. end
  41. 1 def valid?(value)
  42. !value || allowable_values.include?(value)
  43. end
  44. end
  45. # Attribute mapping from ruby-style variable name to JSON key.
  46. 1 def self.attribute_map
  47. 45 {
  48. :'callback_url' => :'callbackUrl',
  49. :'callback_method' => :'callbackMethod',
  50. :'username' => :'username',
  51. :'password' => :'password',
  52. :'tag' => :'tag',
  53. :'callback_timeout' => :'callbackTimeout',
  54. :'detect_language' => :'detectLanguage'
  55. }
  56. end
  57. # Returns attribute mapping this model knows about
  58. 1 def self.acceptable_attribute_map
  59. 13 attribute_map
  60. end
  61. # Returns all the JSON keys this model knows about
  62. 1 def self.acceptable_attributes
  63. 1 acceptable_attribute_map.values
  64. end
  65. # Attribute type mapping.
  66. 1 def self.openapi_types
  67. 1 {
  68. :'callback_url' => :'String',
  69. :'callback_method' => :'CallbackMethodEnum',
  70. :'username' => :'String',
  71. :'password' => :'String',
  72. :'tag' => :'String',
  73. :'callback_timeout' => :'Float',
  74. :'detect_language' => :'Boolean'
  75. }
  76. end
  77. # List of attributes with nullable: true
  78. 1 def self.openapi_nullable
  79. 3 Set.new([
  80. :'callback_method',
  81. :'username',
  82. :'password',
  83. :'tag',
  84. :'callback_timeout',
  85. :'detect_language'
  86. ])
  87. end
  88. # Initializes the object
  89. # @param [Hash] attributes Model attributes in the form of hash
  90. 1 def initialize(attributes = {})
  91. 13 if (!attributes.is_a?(Hash))
  92. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::TranscribeRecording` initialize method'
  93. end
  94. # check to see if the attribute exists and convert string to symbol for hash key
  95. 12 acceptable_attribute_map = self.class.acceptable_attribute_map
  96. 12 attributes = attributes.each_with_object({}) { |(k, v), h|
  97. 35 if (!acceptable_attribute_map.key?(k.to_sym))
  98. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::TranscribeRecording`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  99. end
  100. 34 h[k.to_sym] = v
  101. }
  102. 11 if attributes.key?(:'callback_url')
  103. 5 self.callback_url = attributes[:'callback_url']
  104. end
  105. 11 if attributes.key?(:'callback_method')
  106. 4 self.callback_method = attributes[:'callback_method']
  107. else
  108. 7 self.callback_method = 'POST'
  109. end
  110. 11 if attributes.key?(:'username')
  111. 5 self.username = attributes[:'username']
  112. end
  113. 10 if attributes.key?(:'password')
  114. 5 self.password = attributes[:'password']
  115. end
  116. 9 if attributes.key?(:'tag')
  117. 5 self.tag = attributes[:'tag']
  118. end
  119. 9 if attributes.key?(:'callback_timeout')
  120. 6 self.callback_timeout = attributes[:'callback_timeout']
  121. else
  122. 3 self.callback_timeout = 15
  123. end
  124. 7 if attributes.key?(:'detect_language')
  125. 4 self.detect_language = attributes[:'detect_language']
  126. else
  127. 3 self.detect_language = false
  128. end
  129. end
  130. # Show invalid properties with the reasons. Usually used together with valid?
  131. # @return Array for valid properties with the reasons
  132. 1 def list_invalid_properties
  133. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  134. invalid_properties = Array.new
  135. if !@username.nil? && @username.to_s.length > 1024
  136. invalid_properties.push('invalid value for "username", the character length must be smaller than or equal to 1024.')
  137. end
  138. if !@password.nil? && @password.to_s.length > 1024
  139. invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 1024.')
  140. end
  141. if !@callback_timeout.nil? && @callback_timeout > 25
  142. invalid_properties.push('invalid value for "callback_timeout", must be smaller than or equal to 25.')
  143. end
  144. if !@callback_timeout.nil? && @callback_timeout < 1
  145. invalid_properties.push('invalid value for "callback_timeout", must be greater than or equal to 1.')
  146. end
  147. invalid_properties
  148. end
  149. # Check to see if the all the properties in the model are valid
  150. # @return true if the model is valid
  151. 1 def valid?
  152. warn '[DEPRECATED] the `valid?` method is obsolete'
  153. return false if !@username.nil? && @username.to_s.length > 1024
  154. return false if !@password.nil? && @password.to_s.length > 1024
  155. return false if !@callback_timeout.nil? && @callback_timeout > 25
  156. return false if !@callback_timeout.nil? && @callback_timeout < 1
  157. true
  158. end
  159. # Custom attribute writer method with validation
  160. # @param [Object] username Value to be assigned
  161. 1 def username=(username)
  162. 5 if !username.nil? && username.to_s.length > 1024
  163. 1 fail ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 1024.'
  164. end
  165. 4 @username = username
  166. end
  167. # Custom attribute writer method with validation
  168. # @param [Object] password Value to be assigned
  169. 1 def password=(password)
  170. 5 if !password.nil? && password.to_s.length > 1024
  171. 1 fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 1024.'
  172. end
  173. 4 @password = password
  174. end
  175. # Custom attribute writer method with validation
  176. # @param [Object] callback_timeout Value to be assigned
  177. 1 def callback_timeout=(callback_timeout)
  178. 9 if !callback_timeout.nil? && callback_timeout > 25
  179. 1 fail ArgumentError, 'invalid value for "callback_timeout", must be smaller than or equal to 25.'
  180. end
  181. 8 if !callback_timeout.nil? && callback_timeout < 1
  182. 1 fail ArgumentError, 'invalid value for "callback_timeout", must be greater than or equal to 1.'
  183. end
  184. 7 @callback_timeout = callback_timeout
  185. end
  186. # Checks equality by comparing each attribute.
  187. # @param [Object] Object to be compared
  188. 1 def ==(o)
  189. 2 return true if self.equal?(o)
  190. 2 self.class == o.class &&
  191. callback_url == o.callback_url &&
  192. callback_method == o.callback_method &&
  193. username == o.username &&
  194. password == o.password &&
  195. tag == o.tag &&
  196. callback_timeout == o.callback_timeout &&
  197. detect_language == o.detect_language
  198. end
  199. # @see the `==` method
  200. # @param [Object] Object to be compared
  201. 1 def eql?(o)
  202. 2 self == o
  203. end
  204. # Calculates hash code according to all attributes.
  205. # @return [Integer] Hash code
  206. 1 def hash
  207. [callback_url, callback_method, username, password, tag, callback_timeout, detect_language].hash
  208. end
  209. # Builds the object from hash
  210. # @param [Hash] attributes Model attributes in the form of hash
  211. # @return [Object] Returns the model itself
  212. 1 def self.build_from_hash(attributes)
  213. 1 return nil unless attributes.is_a?(Hash)
  214. 1 attributes = attributes.transform_keys(&:to_sym)
  215. 1 transformed_hash = {}
  216. 1 openapi_types.each_pair do |key, type|
  217. 7 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  218. transformed_hash["#{key}"] = nil
  219. 7 elsif type =~ /\AArray<(.*)>/i
  220. # check to ensure the input is an array given that the attribute
  221. # is documented as an array but the input is not
  222. if attributes[attribute_map[key]].is_a?(Array)
  223. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  224. end
  225. 7 elsif !attributes[attribute_map[key]].nil?
  226. 7 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  227. end
  228. end
  229. 1 new(transformed_hash)
  230. end
  231. # Returns the object in the form of hash
  232. # @return [Hash] Returns the object in the form of hash
  233. 1 def to_hash
  234. 3 hash = {}
  235. 3 self.class.attribute_map.each_pair do |attr, param|
  236. 21 value = self.send(attr)
  237. 21 if value.nil?
  238. 2 is_nullable = self.class.openapi_nullable.include?(attr)
  239. 2 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  240. end
  241. 19 hash[param] = _to_hash(value)
  242. end
  243. 3 hash
  244. end
  245. end
  246. end

lib/bandwidth-sdk/models/transcription.rb

82.81% lines covered

64 relevant lines. 53 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class Transcription < ApiModelBase
  13. # The transcribed text
  14. 1 attr_accessor :text
  15. # The confidence on the recognized content, ranging from `0.0` to `1.0` with `1.0` being the highest confidence.
  16. 1 attr_accessor :confidence
  17. # Attribute mapping from ruby-style variable name to JSON key.
  18. 1 def self.attribute_map
  19. 51 {
  20. :'text' => :'text',
  21. :'confidence' => :'confidence'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 14 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 1 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 4 {
  35. :'text' => :'String',
  36. :'confidence' => :'Float'
  37. }
  38. end
  39. # List of attributes with nullable: true
  40. 1 def self.openapi_nullable
  41. 1 Set.new([
  42. ])
  43. end
  44. # Initializes the object
  45. # @param [Hash] attributes Model attributes in the form of hash
  46. 1 def initialize(attributes = {})
  47. 14 if (!attributes.is_a?(Hash))
  48. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::Transcription` initialize method'
  49. end
  50. # check to see if the attribute exists and convert string to symbol for hash key
  51. 13 acceptable_attribute_map = self.class.acceptable_attribute_map
  52. 13 attributes = attributes.each_with_object({}) { |(k, v), h|
  53. 21 if (!acceptable_attribute_map.key?(k.to_sym))
  54. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::Transcription`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  55. end
  56. 20 h[k.to_sym] = v
  57. }
  58. 12 if attributes.key?(:'text')
  59. 10 self.text = attributes[:'text']
  60. end
  61. 12 if attributes.key?(:'confidence')
  62. 10 self.confidence = attributes[:'confidence']
  63. end
  64. end
  65. # Show invalid properties with the reasons. Usually used together with valid?
  66. # @return Array for valid properties with the reasons
  67. 1 def list_invalid_properties
  68. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  69. invalid_properties = Array.new
  70. invalid_properties
  71. end
  72. # Check to see if the all the properties in the model are valid
  73. # @return true if the model is valid
  74. 1 def valid?
  75. warn '[DEPRECATED] the `valid?` method is obsolete'
  76. true
  77. end
  78. # Checks equality by comparing each attribute.
  79. # @param [Object] Object to be compared
  80. 1 def ==(o)
  81. 2 return true if self.equal?(o)
  82. 2 self.class == o.class &&
  83. text == o.text &&
  84. confidence == o.confidence
  85. end
  86. # @see the `==` method
  87. # @param [Object] Object to be compared
  88. 1 def eql?(o)
  89. 2 self == o
  90. end
  91. # Calculates hash code according to all attributes.
  92. # @return [Integer] Hash code
  93. 1 def hash
  94. [text, confidence].hash
  95. end
  96. # Builds the object from hash
  97. # @param [Hash] attributes Model attributes in the form of hash
  98. # @return [Object] Returns the model itself
  99. 1 def self.build_from_hash(attributes)
  100. 4 return nil unless attributes.is_a?(Hash)
  101. 4 attributes = attributes.transform_keys(&:to_sym)
  102. 4 transformed_hash = {}
  103. 4 openapi_types.each_pair do |key, type|
  104. 8 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  105. transformed_hash["#{key}"] = nil
  106. 8 elsif type =~ /\AArray<(.*)>/i
  107. # check to ensure the input is an array given that the attribute
  108. # is documented as an array but the input is not
  109. if attributes[attribute_map[key]].is_a?(Array)
  110. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  111. end
  112. 8 elsif !attributes[attribute_map[key]].nil?
  113. 8 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  114. end
  115. end
  116. 4 new(transformed_hash)
  117. end
  118. # Returns the object in the form of hash
  119. # @return [Hash] Returns the object in the form of hash
  120. 1 def to_hash
  121. 4 hash = {}
  122. 4 self.class.attribute_map.each_pair do |attr, param|
  123. 8 value = self.send(attr)
  124. 8 if value.nil?
  125. is_nullable = self.class.openapi_nullable.include?(attr)
  126. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  127. end
  128. 8 hash[param] = _to_hash(value)
  129. end
  130. 4 hash
  131. end
  132. end
  133. end

lib/bandwidth-sdk/models/transcription_available_callback.rb

87.12% lines covered

132 relevant lines. 115 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # The Transcription Available event is sent when the recording transcription is available to be downloaded.
  13. 1 class TranscriptionAvailableCallback < ApiModelBase
  14. # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect.
  15. 1 attr_accessor :event_type
  16. # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.
  17. 1 attr_accessor :event_time
  18. # The user account associated with the call.
  19. 1 attr_accessor :account_id
  20. # The id of the application associated with the call.
  21. 1 attr_accessor :application_id
  22. # The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555).
  23. 1 attr_accessor :from
  24. # The phone number that received the call, in E.164 format (e.g. +15555555555).
  25. 1 attr_accessor :to
  26. 1 attr_accessor :direction
  27. # The call id associated with the event.
  28. 1 attr_accessor :call_id
  29. # The URL of the call associated with the event.
  30. 1 attr_accessor :call_url
  31. # The URL that can be used to download the recording. Only present if the recording is finished and may be downloaded.
  32. 1 attr_accessor :media_url
  33. # (optional) If the event is related to the B leg of a <Transfer>, the call id of the original call leg that executed the <Transfer>. Otherwise, this field will not be present.
  34. 1 attr_accessor :parent_call_id
  35. # The unique ID of this recording
  36. 1 attr_accessor :recording_id
  37. # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format.
  38. 1 attr_accessor :enqueued_time
  39. # Time the call was started, in ISO 8601 format.
  40. 1 attr_accessor :start_time
  41. # The time that the recording ended in ISO-8601 format
  42. 1 attr_accessor :end_time
  43. # The duration of the recording in ISO-8601 format
  44. 1 attr_accessor :duration
  45. 1 attr_accessor :file_format
  46. # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.
  47. 1 attr_accessor :tag
  48. 1 attr_accessor :transcription
  49. # The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555).
  50. 1 attr_accessor :transfer_caller_id
  51. # The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555).
  52. 1 attr_accessor :transfer_to
  53. 1 class EnumAttributeValidator
  54. 1 attr_reader :datatype
  55. 1 attr_reader :allowable_values
  56. 1 def initialize(datatype, allowable_values)
  57. @allowable_values = allowable_values.map do |value|
  58. case datatype.to_s
  59. when /Integer/i
  60. value.to_i
  61. when /Float/i
  62. value.to_f
  63. else
  64. value
  65. end
  66. end
  67. end
  68. 1 def valid?(value)
  69. !value || allowable_values.include?(value)
  70. end
  71. end
  72. # Attribute mapping from ruby-style variable name to JSON key.
  73. 1 def self.attribute_map
  74. 95 {
  75. :'event_type' => :'eventType',
  76. :'event_time' => :'eventTime',
  77. :'account_id' => :'accountId',
  78. :'application_id' => :'applicationId',
  79. :'from' => :'from',
  80. :'to' => :'to',
  81. :'direction' => :'direction',
  82. :'call_id' => :'callId',
  83. :'call_url' => :'callUrl',
  84. :'media_url' => :'mediaUrl',
  85. :'parent_call_id' => :'parentCallId',
  86. :'recording_id' => :'recordingId',
  87. :'enqueued_time' => :'enqueuedTime',
  88. :'start_time' => :'startTime',
  89. :'end_time' => :'endTime',
  90. :'duration' => :'duration',
  91. :'file_format' => :'fileFormat',
  92. :'tag' => :'tag',
  93. :'transcription' => :'transcription',
  94. :'transfer_caller_id' => :'transferCallerId',
  95. :'transfer_to' => :'transferTo'
  96. }
  97. end
  98. # Returns attribute mapping this model knows about
  99. 1 def self.acceptable_attribute_map
  100. 8 attribute_map
  101. end
  102. # Returns all the JSON keys this model knows about
  103. 1 def self.acceptable_attributes
  104. 1 acceptable_attribute_map.values
  105. end
  106. # Attribute type mapping.
  107. 1 def self.openapi_types
  108. 1 {
  109. :'event_type' => :'String',
  110. :'event_time' => :'Time',
  111. :'account_id' => :'String',
  112. :'application_id' => :'String',
  113. :'from' => :'String',
  114. :'to' => :'String',
  115. :'direction' => :'CallDirectionEnum',
  116. :'call_id' => :'String',
  117. :'call_url' => :'String',
  118. :'media_url' => :'String',
  119. :'parent_call_id' => :'String',
  120. :'recording_id' => :'String',
  121. :'enqueued_time' => :'Time',
  122. :'start_time' => :'Time',
  123. :'end_time' => :'Time',
  124. :'duration' => :'String',
  125. :'file_format' => :'FileFormatEnum',
  126. :'tag' => :'String',
  127. :'transcription' => :'Transcription',
  128. :'transfer_caller_id' => :'String',
  129. :'transfer_to' => :'String'
  130. }
  131. end
  132. # List of attributes with nullable: true
  133. 1 def self.openapi_nullable
  134. 1 Set.new([
  135. :'media_url',
  136. :'enqueued_time',
  137. :'tag',
  138. ])
  139. end
  140. # Initializes the object
  141. # @param [Hash] attributes Model attributes in the form of hash
  142. 1 def initialize(attributes = {})
  143. 8 if (!attributes.is_a?(Hash))
  144. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::TranscriptionAvailableCallback` initialize method'
  145. end
  146. # check to see if the attribute exists and convert string to symbol for hash key
  147. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  148. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  149. 85 if (!acceptable_attribute_map.key?(k.to_sym))
  150. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::TranscriptionAvailableCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  151. end
  152. 84 h[k.to_sym] = v
  153. }
  154. 6 if attributes.key?(:'event_type')
  155. 4 self.event_type = attributes[:'event_type']
  156. end
  157. 6 if attributes.key?(:'event_time')
  158. 4 self.event_time = attributes[:'event_time']
  159. end
  160. 6 if attributes.key?(:'account_id')
  161. 4 self.account_id = attributes[:'account_id']
  162. end
  163. 6 if attributes.key?(:'application_id')
  164. 4 self.application_id = attributes[:'application_id']
  165. end
  166. 6 if attributes.key?(:'from')
  167. 4 self.from = attributes[:'from']
  168. end
  169. 6 if attributes.key?(:'to')
  170. 4 self.to = attributes[:'to']
  171. end
  172. 6 if attributes.key?(:'direction')
  173. 4 self.direction = attributes[:'direction']
  174. end
  175. 6 if attributes.key?(:'call_id')
  176. 4 self.call_id = attributes[:'call_id']
  177. end
  178. 6 if attributes.key?(:'call_url')
  179. 4 self.call_url = attributes[:'call_url']
  180. end
  181. 6 if attributes.key?(:'media_url')
  182. 4 self.media_url = attributes[:'media_url']
  183. end
  184. 6 if attributes.key?(:'parent_call_id')
  185. 4 self.parent_call_id = attributes[:'parent_call_id']
  186. end
  187. 6 if attributes.key?(:'recording_id')
  188. 4 self.recording_id = attributes[:'recording_id']
  189. end
  190. 6 if attributes.key?(:'enqueued_time')
  191. 4 self.enqueued_time = attributes[:'enqueued_time']
  192. end
  193. 6 if attributes.key?(:'start_time')
  194. 4 self.start_time = attributes[:'start_time']
  195. end
  196. 6 if attributes.key?(:'end_time')
  197. 4 self.end_time = attributes[:'end_time']
  198. end
  199. 6 if attributes.key?(:'duration')
  200. 4 self.duration = attributes[:'duration']
  201. end
  202. 6 if attributes.key?(:'file_format')
  203. 4 self.file_format = attributes[:'file_format']
  204. end
  205. 6 if attributes.key?(:'tag')
  206. 4 self.tag = attributes[:'tag']
  207. end
  208. 6 if attributes.key?(:'transcription')
  209. 4 self.transcription = attributes[:'transcription']
  210. end
  211. 6 if attributes.key?(:'transfer_caller_id')
  212. 4 self.transfer_caller_id = attributes[:'transfer_caller_id']
  213. end
  214. 6 if attributes.key?(:'transfer_to')
  215. 4 self.transfer_to = attributes[:'transfer_to']
  216. end
  217. end
  218. # Show invalid properties with the reasons. Usually used together with valid?
  219. # @return Array for valid properties with the reasons
  220. 1 def list_invalid_properties
  221. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  222. invalid_properties = Array.new
  223. invalid_properties
  224. end
  225. # Check to see if the all the properties in the model are valid
  226. # @return true if the model is valid
  227. 1 def valid?
  228. warn '[DEPRECATED] the `valid?` method is obsolete'
  229. true
  230. end
  231. # Checks equality by comparing each attribute.
  232. # @param [Object] Object to be compared
  233. 1 def ==(o)
  234. 2 return true if self.equal?(o)
  235. 2 self.class == o.class &&
  236. event_type == o.event_type &&
  237. event_time == o.event_time &&
  238. account_id == o.account_id &&
  239. application_id == o.application_id &&
  240. from == o.from &&
  241. to == o.to &&
  242. direction == o.direction &&
  243. call_id == o.call_id &&
  244. call_url == o.call_url &&
  245. media_url == o.media_url &&
  246. parent_call_id == o.parent_call_id &&
  247. recording_id == o.recording_id &&
  248. enqueued_time == o.enqueued_time &&
  249. start_time == o.start_time &&
  250. end_time == o.end_time &&
  251. duration == o.duration &&
  252. file_format == o.file_format &&
  253. tag == o.tag &&
  254. transcription == o.transcription &&
  255. transfer_caller_id == o.transfer_caller_id &&
  256. transfer_to == o.transfer_to
  257. end
  258. # @see the `==` method
  259. # @param [Object] Object to be compared
  260. 1 def eql?(o)
  261. 2 self == o
  262. end
  263. # Calculates hash code according to all attributes.
  264. # @return [Integer] Hash code
  265. 1 def hash
  266. [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, media_url, parent_call_id, recording_id, enqueued_time, start_time, end_time, duration, file_format, tag, transcription, transfer_caller_id, transfer_to].hash
  267. end
  268. # Builds the object from hash
  269. # @param [Hash] attributes Model attributes in the form of hash
  270. # @return [Object] Returns the model itself
  271. 1 def self.build_from_hash(attributes)
  272. 1 return nil unless attributes.is_a?(Hash)
  273. 1 attributes = attributes.transform_keys(&:to_sym)
  274. 1 transformed_hash = {}
  275. 1 openapi_types.each_pair do |key, type|
  276. 21 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  277. transformed_hash["#{key}"] = nil
  278. 21 elsif type =~ /\AArray<(.*)>/i
  279. # check to ensure the input is an array given that the attribute
  280. # is documented as an array but the input is not
  281. if attributes[attribute_map[key]].is_a?(Array)
  282. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  283. end
  284. 21 elsif !attributes[attribute_map[key]].nil?
  285. 21 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  286. end
  287. end
  288. 1 new(transformed_hash)
  289. end
  290. # Returns the object in the form of hash
  291. # @return [Hash] Returns the object in the form of hash
  292. 1 def to_hash
  293. 2 hash = {}
  294. 2 self.class.attribute_map.each_pair do |attr, param|
  295. 42 value = self.send(attr)
  296. 42 if value.nil?
  297. is_nullable = self.class.openapi_nullable.include?(attr)
  298. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  299. end
  300. 42 hash[param] = _to_hash(value)
  301. end
  302. 2 hash
  303. end
  304. end
  305. end

lib/bandwidth-sdk/models/transfer_answer_callback.rb

85.09% lines covered

114 relevant lines. 97 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # When processing a <Transfer> verb, this event is sent when a called party (B-leg) answers. The event is sent to the endpoint specified in the transferAnswerUrl attribute of the <PhoneNumber> tag that answered. BXML returned by this callback will be executed for the called party only. After all BXML has been executed, the called party will be bridged to the original call. Most BXML verbs are allowed in response to a transferAnswer event, but some are not allowed.
  13. 1 class TransferAnswerCallback < ApiModelBase
  14. # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect.
  15. 1 attr_accessor :event_type
  16. # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.
  17. 1 attr_accessor :event_time
  18. # The user account associated with the call.
  19. 1 attr_accessor :account_id
  20. # The id of the application associated with the call.
  21. 1 attr_accessor :application_id
  22. # The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555).
  23. 1 attr_accessor :from
  24. # The phone number that received the call, in E.164 format (e.g. +15555555555).
  25. 1 attr_accessor :to
  26. 1 attr_accessor :direction
  27. # The call id associated with the event.
  28. 1 attr_accessor :call_id
  29. # The URL of the call associated with the event.
  30. 1 attr_accessor :call_url
  31. # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format.
  32. 1 attr_accessor :enqueued_time
  33. # Time the call was started, in ISO 8601 format.
  34. 1 attr_accessor :start_time
  35. # Time the call was answered, in ISO 8601 format.
  36. 1 attr_accessor :answer_time
  37. # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.
  38. 1 attr_accessor :tag
  39. # The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555).
  40. 1 attr_accessor :transfer_caller_id
  41. # The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555).
  42. 1 attr_accessor :transfer_to
  43. 1 class EnumAttributeValidator
  44. 1 attr_reader :datatype
  45. 1 attr_reader :allowable_values
  46. 1 def initialize(datatype, allowable_values)
  47. @allowable_values = allowable_values.map do |value|
  48. case datatype.to_s
  49. when /Integer/i
  50. value.to_i
  51. when /Float/i
  52. value.to_f
  53. else
  54. value
  55. end
  56. end
  57. end
  58. 1 def valid?(value)
  59. !value || allowable_values.include?(value)
  60. end
  61. end
  62. # Attribute mapping from ruby-style variable name to JSON key.
  63. 1 def self.attribute_map
  64. 71 {
  65. :'event_type' => :'eventType',
  66. :'event_time' => :'eventTime',
  67. :'account_id' => :'accountId',
  68. :'application_id' => :'applicationId',
  69. :'from' => :'from',
  70. :'to' => :'to',
  71. :'direction' => :'direction',
  72. :'call_id' => :'callId',
  73. :'call_url' => :'callUrl',
  74. :'enqueued_time' => :'enqueuedTime',
  75. :'start_time' => :'startTime',
  76. :'answer_time' => :'answerTime',
  77. :'tag' => :'tag',
  78. :'transfer_caller_id' => :'transferCallerId',
  79. :'transfer_to' => :'transferTo'
  80. }
  81. end
  82. # Returns attribute mapping this model knows about
  83. 1 def self.acceptable_attribute_map
  84. 8 attribute_map
  85. end
  86. # Returns all the JSON keys this model knows about
  87. 1 def self.acceptable_attributes
  88. 1 acceptable_attribute_map.values
  89. end
  90. # Attribute type mapping.
  91. 1 def self.openapi_types
  92. 1 {
  93. :'event_type' => :'String',
  94. :'event_time' => :'Time',
  95. :'account_id' => :'String',
  96. :'application_id' => :'String',
  97. :'from' => :'String',
  98. :'to' => :'String',
  99. :'direction' => :'CallDirectionEnum',
  100. :'call_id' => :'String',
  101. :'call_url' => :'String',
  102. :'enqueued_time' => :'Time',
  103. :'start_time' => :'Time',
  104. :'answer_time' => :'Time',
  105. :'tag' => :'String',
  106. :'transfer_caller_id' => :'String',
  107. :'transfer_to' => :'String'
  108. }
  109. end
  110. # List of attributes with nullable: true
  111. 1 def self.openapi_nullable
  112. 1 Set.new([
  113. :'enqueued_time',
  114. :'answer_time',
  115. :'tag',
  116. ])
  117. end
  118. # Initializes the object
  119. # @param [Hash] attributes Model attributes in the form of hash
  120. 1 def initialize(attributes = {})
  121. 8 if (!attributes.is_a?(Hash))
  122. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::TransferAnswerCallback` initialize method'
  123. end
  124. # check to see if the attribute exists and convert string to symbol for hash key
  125. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  126. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  127. 61 if (!acceptable_attribute_map.key?(k.to_sym))
  128. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::TransferAnswerCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  129. end
  130. 60 h[k.to_sym] = v
  131. }
  132. 6 if attributes.key?(:'event_type')
  133. 4 self.event_type = attributes[:'event_type']
  134. end
  135. 6 if attributes.key?(:'event_time')
  136. 4 self.event_time = attributes[:'event_time']
  137. end
  138. 6 if attributes.key?(:'account_id')
  139. 4 self.account_id = attributes[:'account_id']
  140. end
  141. 6 if attributes.key?(:'application_id')
  142. 4 self.application_id = attributes[:'application_id']
  143. end
  144. 6 if attributes.key?(:'from')
  145. 4 self.from = attributes[:'from']
  146. end
  147. 6 if attributes.key?(:'to')
  148. 4 self.to = attributes[:'to']
  149. end
  150. 6 if attributes.key?(:'direction')
  151. 4 self.direction = attributes[:'direction']
  152. end
  153. 6 if attributes.key?(:'call_id')
  154. 4 self.call_id = attributes[:'call_id']
  155. end
  156. 6 if attributes.key?(:'call_url')
  157. 4 self.call_url = attributes[:'call_url']
  158. end
  159. 6 if attributes.key?(:'enqueued_time')
  160. 4 self.enqueued_time = attributes[:'enqueued_time']
  161. end
  162. 6 if attributes.key?(:'start_time')
  163. 4 self.start_time = attributes[:'start_time']
  164. end
  165. 6 if attributes.key?(:'answer_time')
  166. 4 self.answer_time = attributes[:'answer_time']
  167. end
  168. 6 if attributes.key?(:'tag')
  169. 4 self.tag = attributes[:'tag']
  170. end
  171. 6 if attributes.key?(:'transfer_caller_id')
  172. 4 self.transfer_caller_id = attributes[:'transfer_caller_id']
  173. end
  174. 6 if attributes.key?(:'transfer_to')
  175. 4 self.transfer_to = attributes[:'transfer_to']
  176. end
  177. end
  178. # Show invalid properties with the reasons. Usually used together with valid?
  179. # @return Array for valid properties with the reasons
  180. 1 def list_invalid_properties
  181. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  182. invalid_properties = Array.new
  183. invalid_properties
  184. end
  185. # Check to see if the all the properties in the model are valid
  186. # @return true if the model is valid
  187. 1 def valid?
  188. warn '[DEPRECATED] the `valid?` method is obsolete'
  189. true
  190. end
  191. # Checks equality by comparing each attribute.
  192. # @param [Object] Object to be compared
  193. 1 def ==(o)
  194. 2 return true if self.equal?(o)
  195. 2 self.class == o.class &&
  196. event_type == o.event_type &&
  197. event_time == o.event_time &&
  198. account_id == o.account_id &&
  199. application_id == o.application_id &&
  200. from == o.from &&
  201. to == o.to &&
  202. direction == o.direction &&
  203. call_id == o.call_id &&
  204. call_url == o.call_url &&
  205. enqueued_time == o.enqueued_time &&
  206. start_time == o.start_time &&
  207. answer_time == o.answer_time &&
  208. tag == o.tag &&
  209. transfer_caller_id == o.transfer_caller_id &&
  210. transfer_to == o.transfer_to
  211. end
  212. # @see the `==` method
  213. # @param [Object] Object to be compared
  214. 1 def eql?(o)
  215. 2 self == o
  216. end
  217. # Calculates hash code according to all attributes.
  218. # @return [Integer] Hash code
  219. 1 def hash
  220. [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, enqueued_time, start_time, answer_time, tag, transfer_caller_id, transfer_to].hash
  221. end
  222. # Builds the object from hash
  223. # @param [Hash] attributes Model attributes in the form of hash
  224. # @return [Object] Returns the model itself
  225. 1 def self.build_from_hash(attributes)
  226. 1 return nil unless attributes.is_a?(Hash)
  227. 1 attributes = attributes.transform_keys(&:to_sym)
  228. 1 transformed_hash = {}
  229. 1 openapi_types.each_pair do |key, type|
  230. 15 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  231. transformed_hash["#{key}"] = nil
  232. 15 elsif type =~ /\AArray<(.*)>/i
  233. # check to ensure the input is an array given that the attribute
  234. # is documented as an array but the input is not
  235. if attributes[attribute_map[key]].is_a?(Array)
  236. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  237. end
  238. 15 elsif !attributes[attribute_map[key]].nil?
  239. 15 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  240. end
  241. end
  242. 1 new(transformed_hash)
  243. end
  244. # Returns the object in the form of hash
  245. # @return [Hash] Returns the object in the form of hash
  246. 1 def to_hash
  247. 2 hash = {}
  248. 2 self.class.attribute_map.each_pair do |attr, param|
  249. 30 value = self.send(attr)
  250. 30 if value.nil?
  251. is_nullable = self.class.openapi_nullable.include?(attr)
  252. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  253. end
  254. 30 hash[param] = _to_hash(value)
  255. end
  256. 2 hash
  257. end
  258. end
  259. end

lib/bandwidth-sdk/models/transfer_complete_callback.rb

86.18% lines covered

123 relevant lines. 106 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # This event is sent to the transferCompleteUrl of the A-leg's <Transfer> verb when the transferred call (B-leg) completes. In a simultaneous ringing scenario, only one B-leg succeeds and this event corresponds to that successful leg. If none of the calls were answered, the transferComplete event corresponds to one of the legs.
  13. 1 class TransferCompleteCallback < ApiModelBase
  14. # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect.
  15. 1 attr_accessor :event_type
  16. # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.
  17. 1 attr_accessor :event_time
  18. # The user account associated with the call.
  19. 1 attr_accessor :account_id
  20. # The id of the application associated with the call.
  21. 1 attr_accessor :application_id
  22. # The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555).
  23. 1 attr_accessor :from
  24. # The phone number that received the call, in E.164 format (e.g. +15555555555).
  25. 1 attr_accessor :to
  26. 1 attr_accessor :direction
  27. # The call id associated with the event.
  28. 1 attr_accessor :call_id
  29. # The URL of the call associated with the event.
  30. 1 attr_accessor :call_url
  31. # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format.
  32. 1 attr_accessor :enqueued_time
  33. # Time the call was started, in ISO 8601 format.
  34. 1 attr_accessor :start_time
  35. # Time the call was answered, in ISO 8601 format.
  36. 1 attr_accessor :answer_time
  37. # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.
  38. 1 attr_accessor :tag
  39. # The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555).
  40. 1 attr_accessor :transfer_caller_id
  41. # The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555).
  42. 1 attr_accessor :transfer_to
  43. # Reason the call failed - hangup, busy, timeout, cancel, rejected, callback-error, invalid-bxml, application-error, account-limit, node-capacity-exceeded, error, or unknown.
  44. 1 attr_accessor :cause
  45. # Text explaining the reason that caused the call to fail in case of errors.
  46. 1 attr_accessor :error_message
  47. # Bandwidth's internal id that references the error event.
  48. 1 attr_accessor :error_id
  49. 1 class EnumAttributeValidator
  50. 1 attr_reader :datatype
  51. 1 attr_reader :allowable_values
  52. 1 def initialize(datatype, allowable_values)
  53. @allowable_values = allowable_values.map do |value|
  54. case datatype.to_s
  55. when /Integer/i
  56. value.to_i
  57. when /Float/i
  58. value.to_f
  59. else
  60. value
  61. end
  62. end
  63. end
  64. 1 def valid?(value)
  65. !value || allowable_values.include?(value)
  66. end
  67. end
  68. # Attribute mapping from ruby-style variable name to JSON key.
  69. 1 def self.attribute_map
  70. 83 {
  71. :'event_type' => :'eventType',
  72. :'event_time' => :'eventTime',
  73. :'account_id' => :'accountId',
  74. :'application_id' => :'applicationId',
  75. :'from' => :'from',
  76. :'to' => :'to',
  77. :'direction' => :'direction',
  78. :'call_id' => :'callId',
  79. :'call_url' => :'callUrl',
  80. :'enqueued_time' => :'enqueuedTime',
  81. :'start_time' => :'startTime',
  82. :'answer_time' => :'answerTime',
  83. :'tag' => :'tag',
  84. :'transfer_caller_id' => :'transferCallerId',
  85. :'transfer_to' => :'transferTo',
  86. :'cause' => :'cause',
  87. :'error_message' => :'errorMessage',
  88. :'error_id' => :'errorId'
  89. }
  90. end
  91. # Returns attribute mapping this model knows about
  92. 1 def self.acceptable_attribute_map
  93. 8 attribute_map
  94. end
  95. # Returns all the JSON keys this model knows about
  96. 1 def self.acceptable_attributes
  97. 1 acceptable_attribute_map.values
  98. end
  99. # Attribute type mapping.
  100. 1 def self.openapi_types
  101. 1 {
  102. :'event_type' => :'String',
  103. :'event_time' => :'Time',
  104. :'account_id' => :'String',
  105. :'application_id' => :'String',
  106. :'from' => :'String',
  107. :'to' => :'String',
  108. :'direction' => :'CallDirectionEnum',
  109. :'call_id' => :'String',
  110. :'call_url' => :'String',
  111. :'enqueued_time' => :'Time',
  112. :'start_time' => :'Time',
  113. :'answer_time' => :'Time',
  114. :'tag' => :'String',
  115. :'transfer_caller_id' => :'String',
  116. :'transfer_to' => :'String',
  117. :'cause' => :'String',
  118. :'error_message' => :'String',
  119. :'error_id' => :'String'
  120. }
  121. end
  122. # List of attributes with nullable: true
  123. 1 def self.openapi_nullable
  124. 1 Set.new([
  125. :'enqueued_time',
  126. :'answer_time',
  127. :'tag',
  128. :'error_message',
  129. :'error_id'
  130. ])
  131. end
  132. # Initializes the object
  133. # @param [Hash] attributes Model attributes in the form of hash
  134. 1 def initialize(attributes = {})
  135. 8 if (!attributes.is_a?(Hash))
  136. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::TransferCompleteCallback` initialize method'
  137. end
  138. # check to see if the attribute exists and convert string to symbol for hash key
  139. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  140. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  141. 73 if (!acceptable_attribute_map.key?(k.to_sym))
  142. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::TransferCompleteCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  143. end
  144. 72 h[k.to_sym] = v
  145. }
  146. 6 if attributes.key?(:'event_type')
  147. 4 self.event_type = attributes[:'event_type']
  148. end
  149. 6 if attributes.key?(:'event_time')
  150. 4 self.event_time = attributes[:'event_time']
  151. end
  152. 6 if attributes.key?(:'account_id')
  153. 4 self.account_id = attributes[:'account_id']
  154. end
  155. 6 if attributes.key?(:'application_id')
  156. 4 self.application_id = attributes[:'application_id']
  157. end
  158. 6 if attributes.key?(:'from')
  159. 4 self.from = attributes[:'from']
  160. end
  161. 6 if attributes.key?(:'to')
  162. 4 self.to = attributes[:'to']
  163. end
  164. 6 if attributes.key?(:'direction')
  165. 4 self.direction = attributes[:'direction']
  166. end
  167. 6 if attributes.key?(:'call_id')
  168. 4 self.call_id = attributes[:'call_id']
  169. end
  170. 6 if attributes.key?(:'call_url')
  171. 4 self.call_url = attributes[:'call_url']
  172. end
  173. 6 if attributes.key?(:'enqueued_time')
  174. 4 self.enqueued_time = attributes[:'enqueued_time']
  175. end
  176. 6 if attributes.key?(:'start_time')
  177. 4 self.start_time = attributes[:'start_time']
  178. end
  179. 6 if attributes.key?(:'answer_time')
  180. 4 self.answer_time = attributes[:'answer_time']
  181. end
  182. 6 if attributes.key?(:'tag')
  183. 4 self.tag = attributes[:'tag']
  184. end
  185. 6 if attributes.key?(:'transfer_caller_id')
  186. 4 self.transfer_caller_id = attributes[:'transfer_caller_id']
  187. end
  188. 6 if attributes.key?(:'transfer_to')
  189. 4 self.transfer_to = attributes[:'transfer_to']
  190. end
  191. 6 if attributes.key?(:'cause')
  192. 4 self.cause = attributes[:'cause']
  193. end
  194. 6 if attributes.key?(:'error_message')
  195. 4 self.error_message = attributes[:'error_message']
  196. end
  197. 6 if attributes.key?(:'error_id')
  198. 4 self.error_id = attributes[:'error_id']
  199. end
  200. end
  201. # Show invalid properties with the reasons. Usually used together with valid?
  202. # @return Array for valid properties with the reasons
  203. 1 def list_invalid_properties
  204. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  205. invalid_properties = Array.new
  206. invalid_properties
  207. end
  208. # Check to see if the all the properties in the model are valid
  209. # @return true if the model is valid
  210. 1 def valid?
  211. warn '[DEPRECATED] the `valid?` method is obsolete'
  212. true
  213. end
  214. # Checks equality by comparing each attribute.
  215. # @param [Object] Object to be compared
  216. 1 def ==(o)
  217. 2 return true if self.equal?(o)
  218. 2 self.class == o.class &&
  219. event_type == o.event_type &&
  220. event_time == o.event_time &&
  221. account_id == o.account_id &&
  222. application_id == o.application_id &&
  223. from == o.from &&
  224. to == o.to &&
  225. direction == o.direction &&
  226. call_id == o.call_id &&
  227. call_url == o.call_url &&
  228. enqueued_time == o.enqueued_time &&
  229. start_time == o.start_time &&
  230. answer_time == o.answer_time &&
  231. tag == o.tag &&
  232. transfer_caller_id == o.transfer_caller_id &&
  233. transfer_to == o.transfer_to &&
  234. cause == o.cause &&
  235. error_message == o.error_message &&
  236. error_id == o.error_id
  237. end
  238. # @see the `==` method
  239. # @param [Object] Object to be compared
  240. 1 def eql?(o)
  241. 2 self == o
  242. end
  243. # Calculates hash code according to all attributes.
  244. # @return [Integer] Hash code
  245. 1 def hash
  246. [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, enqueued_time, start_time, answer_time, tag, transfer_caller_id, transfer_to, cause, error_message, error_id].hash
  247. end
  248. # Builds the object from hash
  249. # @param [Hash] attributes Model attributes in the form of hash
  250. # @return [Object] Returns the model itself
  251. 1 def self.build_from_hash(attributes)
  252. 1 return nil unless attributes.is_a?(Hash)
  253. 1 attributes = attributes.transform_keys(&:to_sym)
  254. 1 transformed_hash = {}
  255. 1 openapi_types.each_pair do |key, type|
  256. 18 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  257. transformed_hash["#{key}"] = nil
  258. 18 elsif type =~ /\AArray<(.*)>/i
  259. # check to ensure the input is an array given that the attribute
  260. # is documented as an array but the input is not
  261. if attributes[attribute_map[key]].is_a?(Array)
  262. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  263. end
  264. 18 elsif !attributes[attribute_map[key]].nil?
  265. 18 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  266. end
  267. end
  268. 1 new(transformed_hash)
  269. end
  270. # Returns the object in the form of hash
  271. # @return [Hash] Returns the object in the form of hash
  272. 1 def to_hash
  273. 2 hash = {}
  274. 2 self.class.attribute_map.each_pair do |attr, param|
  275. 36 value = self.send(attr)
  276. 36 if value.nil?
  277. is_nullable = self.class.openapi_nullable.include?(attr)
  278. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  279. end
  280. 36 hash[param] = _to_hash(value)
  281. end
  282. 2 hash
  283. end
  284. end
  285. end

lib/bandwidth-sdk/models/transfer_disconnect_callback.rb

86.82% lines covered

129 relevant lines. 112 lines covered and 17 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # This event is sent to the transferDisconnectUrl of each <PhoneNumber> tag when its respective call leg ends for any reason. The event is sent in the normal case, when the transferred leg is answered and later hung up, but is also sent if the new leg was never answered in the first place, if it was rejected, and if the original call leg hung up before the transferred leg.
  13. 1 class TransferDisconnectCallback < ApiModelBase
  14. # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect.
  15. 1 attr_accessor :event_type
  16. # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution.
  17. 1 attr_accessor :event_time
  18. # The user account associated with the call.
  19. 1 attr_accessor :account_id
  20. # The id of the application associated with the call.
  21. 1 attr_accessor :application_id
  22. # The provided identifier of the caller. Must be a phone number in E.164 format (e.g. +15555555555).
  23. 1 attr_accessor :from
  24. # The phone number that received the call, in E.164 format (e.g. +15555555555).
  25. 1 attr_accessor :to
  26. 1 attr_accessor :direction
  27. # The call id associated with the event.
  28. 1 attr_accessor :call_id
  29. # The URL of the call associated with the event.
  30. 1 attr_accessor :call_url
  31. # (optional) If the event is related to the B leg of a <Transfer>, the call id of the original call leg that executed the <Transfer>. Otherwise, this field will not be present.
  32. 1 attr_accessor :parent_call_id
  33. # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format.
  34. 1 attr_accessor :enqueued_time
  35. # Time the call was started, in ISO 8601 format.
  36. 1 attr_accessor :start_time
  37. # Time the call was answered, in ISO 8601 format.
  38. 1 attr_accessor :answer_time
  39. # The time that the recording ended in ISO-8601 format
  40. 1 attr_accessor :end_time
  41. # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present.
  42. 1 attr_accessor :tag
  43. # The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555).
  44. 1 attr_accessor :transfer_caller_id
  45. # The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555).
  46. 1 attr_accessor :transfer_to
  47. # Reason the call failed - hangup, busy, timeout, cancel, rejected, callback-error, invalid-bxml, application-error, account-limit, node-capacity-exceeded, error, or unknown.
  48. 1 attr_accessor :cause
  49. # Text explaining the reason that caused the call to fail in case of errors.
  50. 1 attr_accessor :error_message
  51. # Bandwidth's internal id that references the error event.
  52. 1 attr_accessor :error_id
  53. 1 class EnumAttributeValidator
  54. 1 attr_reader :datatype
  55. 1 attr_reader :allowable_values
  56. 1 def initialize(datatype, allowable_values)
  57. @allowable_values = allowable_values.map do |value|
  58. case datatype.to_s
  59. when /Integer/i
  60. value.to_i
  61. when /Float/i
  62. value.to_f
  63. else
  64. value
  65. end
  66. end
  67. end
  68. 1 def valid?(value)
  69. !value || allowable_values.include?(value)
  70. end
  71. end
  72. # Attribute mapping from ruby-style variable name to JSON key.
  73. 1 def self.attribute_map
  74. 91 {
  75. :'event_type' => :'eventType',
  76. :'event_time' => :'eventTime',
  77. :'account_id' => :'accountId',
  78. :'application_id' => :'applicationId',
  79. :'from' => :'from',
  80. :'to' => :'to',
  81. :'direction' => :'direction',
  82. :'call_id' => :'callId',
  83. :'call_url' => :'callUrl',
  84. :'parent_call_id' => :'parentCallId',
  85. :'enqueued_time' => :'enqueuedTime',
  86. :'start_time' => :'startTime',
  87. :'answer_time' => :'answerTime',
  88. :'end_time' => :'endTime',
  89. :'tag' => :'tag',
  90. :'transfer_caller_id' => :'transferCallerId',
  91. :'transfer_to' => :'transferTo',
  92. :'cause' => :'cause',
  93. :'error_message' => :'errorMessage',
  94. :'error_id' => :'errorId'
  95. }
  96. end
  97. # Returns attribute mapping this model knows about
  98. 1 def self.acceptable_attribute_map
  99. 8 attribute_map
  100. end
  101. # Returns all the JSON keys this model knows about
  102. 1 def self.acceptable_attributes
  103. 1 acceptable_attribute_map.values
  104. end
  105. # Attribute type mapping.
  106. 1 def self.openapi_types
  107. 1 {
  108. :'event_type' => :'String',
  109. :'event_time' => :'Time',
  110. :'account_id' => :'String',
  111. :'application_id' => :'String',
  112. :'from' => :'String',
  113. :'to' => :'String',
  114. :'direction' => :'CallDirectionEnum',
  115. :'call_id' => :'String',
  116. :'call_url' => :'String',
  117. :'parent_call_id' => :'String',
  118. :'enqueued_time' => :'Time',
  119. :'start_time' => :'Time',
  120. :'answer_time' => :'Time',
  121. :'end_time' => :'Time',
  122. :'tag' => :'String',
  123. :'transfer_caller_id' => :'String',
  124. :'transfer_to' => :'String',
  125. :'cause' => :'String',
  126. :'error_message' => :'String',
  127. :'error_id' => :'String'
  128. }
  129. end
  130. # List of attributes with nullable: true
  131. 1 def self.openapi_nullable
  132. 1 Set.new([
  133. :'enqueued_time',
  134. :'answer_time',
  135. :'tag',
  136. :'error_message',
  137. :'error_id'
  138. ])
  139. end
  140. # Initializes the object
  141. # @param [Hash] attributes Model attributes in the form of hash
  142. 1 def initialize(attributes = {})
  143. 8 if (!attributes.is_a?(Hash))
  144. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::TransferDisconnectCallback` initialize method'
  145. end
  146. # check to see if the attribute exists and convert string to symbol for hash key
  147. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  148. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  149. 81 if (!acceptable_attribute_map.key?(k.to_sym))
  150. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::TransferDisconnectCallback`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  151. end
  152. 80 h[k.to_sym] = v
  153. }
  154. 6 if attributes.key?(:'event_type')
  155. 4 self.event_type = attributes[:'event_type']
  156. end
  157. 6 if attributes.key?(:'event_time')
  158. 4 self.event_time = attributes[:'event_time']
  159. end
  160. 6 if attributes.key?(:'account_id')
  161. 4 self.account_id = attributes[:'account_id']
  162. end
  163. 6 if attributes.key?(:'application_id')
  164. 4 self.application_id = attributes[:'application_id']
  165. end
  166. 6 if attributes.key?(:'from')
  167. 4 self.from = attributes[:'from']
  168. end
  169. 6 if attributes.key?(:'to')
  170. 4 self.to = attributes[:'to']
  171. end
  172. 6 if attributes.key?(:'direction')
  173. 4 self.direction = attributes[:'direction']
  174. end
  175. 6 if attributes.key?(:'call_id')
  176. 4 self.call_id = attributes[:'call_id']
  177. end
  178. 6 if attributes.key?(:'call_url')
  179. 4 self.call_url = attributes[:'call_url']
  180. end
  181. 6 if attributes.key?(:'parent_call_id')
  182. 4 self.parent_call_id = attributes[:'parent_call_id']
  183. end
  184. 6 if attributes.key?(:'enqueued_time')
  185. 4 self.enqueued_time = attributes[:'enqueued_time']
  186. end
  187. 6 if attributes.key?(:'start_time')
  188. 4 self.start_time = attributes[:'start_time']
  189. end
  190. 6 if attributes.key?(:'answer_time')
  191. 4 self.answer_time = attributes[:'answer_time']
  192. end
  193. 6 if attributes.key?(:'end_time')
  194. 4 self.end_time = attributes[:'end_time']
  195. end
  196. 6 if attributes.key?(:'tag')
  197. 4 self.tag = attributes[:'tag']
  198. end
  199. 6 if attributes.key?(:'transfer_caller_id')
  200. 4 self.transfer_caller_id = attributes[:'transfer_caller_id']
  201. end
  202. 6 if attributes.key?(:'transfer_to')
  203. 4 self.transfer_to = attributes[:'transfer_to']
  204. end
  205. 6 if attributes.key?(:'cause')
  206. 4 self.cause = attributes[:'cause']
  207. end
  208. 6 if attributes.key?(:'error_message')
  209. 4 self.error_message = attributes[:'error_message']
  210. end
  211. 6 if attributes.key?(:'error_id')
  212. 4 self.error_id = attributes[:'error_id']
  213. end
  214. end
  215. # Show invalid properties with the reasons. Usually used together with valid?
  216. # @return Array for valid properties with the reasons
  217. 1 def list_invalid_properties
  218. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  219. invalid_properties = Array.new
  220. invalid_properties
  221. end
  222. # Check to see if the all the properties in the model are valid
  223. # @return true if the model is valid
  224. 1 def valid?
  225. warn '[DEPRECATED] the `valid?` method is obsolete'
  226. true
  227. end
  228. # Checks equality by comparing each attribute.
  229. # @param [Object] Object to be compared
  230. 1 def ==(o)
  231. 2 return true if self.equal?(o)
  232. 2 self.class == o.class &&
  233. event_type == o.event_type &&
  234. event_time == o.event_time &&
  235. account_id == o.account_id &&
  236. application_id == o.application_id &&
  237. from == o.from &&
  238. to == o.to &&
  239. direction == o.direction &&
  240. call_id == o.call_id &&
  241. call_url == o.call_url &&
  242. parent_call_id == o.parent_call_id &&
  243. enqueued_time == o.enqueued_time &&
  244. start_time == o.start_time &&
  245. answer_time == o.answer_time &&
  246. end_time == o.end_time &&
  247. tag == o.tag &&
  248. transfer_caller_id == o.transfer_caller_id &&
  249. transfer_to == o.transfer_to &&
  250. cause == o.cause &&
  251. error_message == o.error_message &&
  252. error_id == o.error_id
  253. end
  254. # @see the `==` method
  255. # @param [Object] Object to be compared
  256. 1 def eql?(o)
  257. 2 self == o
  258. end
  259. # Calculates hash code according to all attributes.
  260. # @return [Integer] Hash code
  261. 1 def hash
  262. [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, parent_call_id, enqueued_time, start_time, answer_time, end_time, tag, transfer_caller_id, transfer_to, cause, error_message, error_id].hash
  263. end
  264. # Builds the object from hash
  265. # @param [Hash] attributes Model attributes in the form of hash
  266. # @return [Object] Returns the model itself
  267. 1 def self.build_from_hash(attributes)
  268. 1 return nil unless attributes.is_a?(Hash)
  269. 1 attributes = attributes.transform_keys(&:to_sym)
  270. 1 transformed_hash = {}
  271. 1 openapi_types.each_pair do |key, type|
  272. 20 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  273. transformed_hash["#{key}"] = nil
  274. 20 elsif type =~ /\AArray<(.*)>/i
  275. # check to ensure the input is an array given that the attribute
  276. # is documented as an array but the input is not
  277. if attributes[attribute_map[key]].is_a?(Array)
  278. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  279. end
  280. 20 elsif !attributes[attribute_map[key]].nil?
  281. 20 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  282. end
  283. end
  284. 1 new(transformed_hash)
  285. end
  286. # Returns the object in the form of hash
  287. # @return [Hash] Returns the object in the form of hash
  288. 1 def to_hash
  289. 2 hash = {}
  290. 2 self.class.attribute_map.each_pair do |attr, param|
  291. 40 value = self.send(attr)
  292. 40 if value.nil?
  293. is_nullable = self.class.openapi_nullable.include?(attr)
  294. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  295. end
  296. 40 hash[param] = _to_hash(value)
  297. end
  298. 2 hash
  299. end
  300. end
  301. end

lib/bandwidth-sdk/models/update_call.rb

78.1% lines covered

137 relevant lines. 107 lines covered and 30 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class UpdateCall < ApiModelBase
  13. 1 attr_accessor :state
  14. # The URL to send the [Redirect](/docs/voice/bxml/redirect) event to which will provide new BXML. Required if `state` is `active`. Not allowed if `state` is `completed`.
  15. 1 attr_accessor :redirect_url
  16. 1 attr_accessor :redirect_method
  17. # Basic auth username.
  18. 1 attr_accessor :username
  19. # Basic auth password.
  20. 1 attr_accessor :password
  21. # A fallback url which, if provided, will be used to retry the redirect callback delivery in case `redirectUrl` fails to respond.
  22. 1 attr_accessor :redirect_fallback_url
  23. 1 attr_accessor :redirect_fallback_method
  24. # Basic auth username.
  25. 1 attr_accessor :fallback_username
  26. # Basic auth password.
  27. 1 attr_accessor :fallback_password
  28. # A custom string that will be sent with this and all future callbacks unless overwritten by a future `tag` attribute or [`<Tag>`](/docs/voice/bxml/tag) verb, or cleared. May be cleared by setting `tag=\"\"`. Max length 4096 characters. Not allowed if `state` is `completed`.
  29. 1 attr_accessor :tag
  30. 1 class EnumAttributeValidator
  31. 1 attr_reader :datatype
  32. 1 attr_reader :allowable_values
  33. 1 def initialize(datatype, allowable_values)
  34. @allowable_values = allowable_values.map do |value|
  35. case datatype.to_s
  36. when /Integer/i
  37. value.to_i
  38. when /Float/i
  39. value.to_f
  40. else
  41. value
  42. end
  43. end
  44. end
  45. 1 def valid?(value)
  46. !value || allowable_values.include?(value)
  47. end
  48. end
  49. # Attribute mapping from ruby-style variable name to JSON key.
  50. 1 def self.attribute_map
  51. 59 {
  52. :'state' => :'state',
  53. :'redirect_url' => :'redirectUrl',
  54. :'redirect_method' => :'redirectMethod',
  55. :'username' => :'username',
  56. :'password' => :'password',
  57. :'redirect_fallback_url' => :'redirectFallbackUrl',
  58. :'redirect_fallback_method' => :'redirectFallbackMethod',
  59. :'fallback_username' => :'fallbackUsername',
  60. :'fallback_password' => :'fallbackPassword',
  61. :'tag' => :'tag'
  62. }
  63. end
  64. # Returns attribute mapping this model knows about
  65. 1 def self.acceptable_attribute_map
  66. 15 attribute_map
  67. end
  68. # Returns all the JSON keys this model knows about
  69. 1 def self.acceptable_attributes
  70. 1 acceptable_attribute_map.values
  71. end
  72. # Attribute type mapping.
  73. 1 def self.openapi_types
  74. 1 {
  75. :'state' => :'CallStateEnum',
  76. :'redirect_url' => :'String',
  77. :'redirect_method' => :'RedirectMethodEnum',
  78. :'username' => :'String',
  79. :'password' => :'String',
  80. :'redirect_fallback_url' => :'String',
  81. :'redirect_fallback_method' => :'RedirectMethodEnum',
  82. :'fallback_username' => :'String',
  83. :'fallback_password' => :'String',
  84. :'tag' => :'String'
  85. }
  86. end
  87. # List of attributes with nullable: true
  88. 1 def self.openapi_nullable
  89. 7 Set.new([
  90. :'state',
  91. :'redirect_url',
  92. :'redirect_method',
  93. :'username',
  94. :'password',
  95. :'redirect_fallback_url',
  96. :'redirect_fallback_method',
  97. :'fallback_username',
  98. :'fallback_password',
  99. :'tag'
  100. ])
  101. end
  102. # Initializes the object
  103. # @param [Hash] attributes Model attributes in the form of hash
  104. 1 def initialize(attributes = {})
  105. 15 if (!attributes.is_a?(Hash))
  106. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::UpdateCall` initialize method'
  107. end
  108. # check to see if the attribute exists and convert string to symbol for hash key
  109. 14 acceptable_attribute_map = self.class.acceptable_attribute_map
  110. 14 attributes = attributes.each_with_object({}) { |(k, v), h|
  111. 49 if (!acceptable_attribute_map.key?(k.to_sym))
  112. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::UpdateCall`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  113. end
  114. 48 h[k.to_sym] = v
  115. }
  116. 13 if attributes.key?(:'state')
  117. 6 self.state = attributes[:'state']
  118. else
  119. 7 self.state = 'active'
  120. end
  121. 13 if attributes.key?(:'redirect_url')
  122. 5 self.redirect_url = attributes[:'redirect_url']
  123. end
  124. 13 if attributes.key?(:'redirect_method')
  125. 4 self.redirect_method = attributes[:'redirect_method']
  126. else
  127. 9 self.redirect_method = 'POST'
  128. end
  129. 13 if attributes.key?(:'username')
  130. 5 self.username = attributes[:'username']
  131. end
  132. 12 if attributes.key?(:'password')
  133. 5 self.password = attributes[:'password']
  134. end
  135. 11 if attributes.key?(:'redirect_fallback_url')
  136. 4 self.redirect_fallback_url = attributes[:'redirect_fallback_url']
  137. end
  138. 11 if attributes.key?(:'redirect_fallback_method')
  139. 4 self.redirect_fallback_method = attributes[:'redirect_fallback_method']
  140. else
  141. 7 self.redirect_fallback_method = 'POST'
  142. end
  143. 11 if attributes.key?(:'fallback_username')
  144. 5 self.fallback_username = attributes[:'fallback_username']
  145. end
  146. 10 if attributes.key?(:'fallback_password')
  147. 5 self.fallback_password = attributes[:'fallback_password']
  148. end
  149. 9 if attributes.key?(:'tag')
  150. 5 self.tag = attributes[:'tag']
  151. end
  152. end
  153. # Show invalid properties with the reasons. Usually used together with valid?
  154. # @return Array for valid properties with the reasons
  155. 1 def list_invalid_properties
  156. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  157. invalid_properties = Array.new
  158. if !@username.nil? && @username.to_s.length > 1024
  159. invalid_properties.push('invalid value for "username", the character length must be smaller than or equal to 1024.')
  160. end
  161. if !@password.nil? && @password.to_s.length > 1024
  162. invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 1024.')
  163. end
  164. if !@fallback_username.nil? && @fallback_username.to_s.length > 1024
  165. invalid_properties.push('invalid value for "fallback_username", the character length must be smaller than or equal to 1024.')
  166. end
  167. if !@fallback_password.nil? && @fallback_password.to_s.length > 1024
  168. invalid_properties.push('invalid value for "fallback_password", the character length must be smaller than or equal to 1024.')
  169. end
  170. if !@tag.nil? && @tag.to_s.length > 4096
  171. invalid_properties.push('invalid value for "tag", the character length must be smaller than or equal to 4096.')
  172. end
  173. invalid_properties
  174. end
  175. # Check to see if the all the properties in the model are valid
  176. # @return true if the model is valid
  177. 1 def valid?
  178. warn '[DEPRECATED] the `valid?` method is obsolete'
  179. return false if !@username.nil? && @username.to_s.length > 1024
  180. return false if !@password.nil? && @password.to_s.length > 1024
  181. return false if !@fallback_username.nil? && @fallback_username.to_s.length > 1024
  182. return false if !@fallback_password.nil? && @fallback_password.to_s.length > 1024
  183. return false if !@tag.nil? && @tag.to_s.length > 4096
  184. true
  185. end
  186. # Custom attribute writer method with validation
  187. # @param [Object] username Value to be assigned
  188. 1 def username=(username)
  189. 5 if !username.nil? && username.to_s.length > 1024
  190. 1 fail ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 1024.'
  191. end
  192. 4 @username = username
  193. end
  194. # Custom attribute writer method with validation
  195. # @param [Object] password Value to be assigned
  196. 1 def password=(password)
  197. 5 if !password.nil? && password.to_s.length > 1024
  198. 1 fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 1024.'
  199. end
  200. 4 @password = password
  201. end
  202. # Custom attribute writer method with validation
  203. # @param [Object] fallback_username Value to be assigned
  204. 1 def fallback_username=(fallback_username)
  205. 5 if !fallback_username.nil? && fallback_username.to_s.length > 1024
  206. 1 fail ArgumentError, 'invalid value for "fallback_username", the character length must be smaller than or equal to 1024.'
  207. end
  208. 4 @fallback_username = fallback_username
  209. end
  210. # Custom attribute writer method with validation
  211. # @param [Object] fallback_password Value to be assigned
  212. 1 def fallback_password=(fallback_password)
  213. 5 if !fallback_password.nil? && fallback_password.to_s.length > 1024
  214. 1 fail ArgumentError, 'invalid value for "fallback_password", the character length must be smaller than or equal to 1024.'
  215. end
  216. 4 @fallback_password = fallback_password
  217. end
  218. # Custom attribute writer method with validation
  219. # @param [Object] tag Value to be assigned
  220. 1 def tag=(tag)
  221. 5 if !tag.nil? && tag.to_s.length > 4096
  222. 1 fail ArgumentError, 'invalid value for "tag", the character length must be smaller than or equal to 4096.'
  223. end
  224. 4 @tag = tag
  225. end
  226. # Checks equality by comparing each attribute.
  227. # @param [Object] Object to be compared
  228. 1 def ==(o)
  229. 2 return true if self.equal?(o)
  230. 2 self.class == o.class &&
  231. state == o.state &&
  232. redirect_url == o.redirect_url &&
  233. redirect_method == o.redirect_method &&
  234. username == o.username &&
  235. password == o.password &&
  236. redirect_fallback_url == o.redirect_fallback_url &&
  237. redirect_fallback_method == o.redirect_fallback_method &&
  238. fallback_username == o.fallback_username &&
  239. fallback_password == o.fallback_password &&
  240. tag == o.tag
  241. end
  242. # @see the `==` method
  243. # @param [Object] Object to be compared
  244. 1 def eql?(o)
  245. 2 self == o
  246. end
  247. # Calculates hash code according to all attributes.
  248. # @return [Integer] Hash code
  249. 1 def hash
  250. [state, redirect_url, redirect_method, username, password, redirect_fallback_url, redirect_fallback_method, fallback_username, fallback_password, tag].hash
  251. end
  252. # Builds the object from hash
  253. # @param [Hash] attributes Model attributes in the form of hash
  254. # @return [Object] Returns the model itself
  255. 1 def self.build_from_hash(attributes)
  256. 1 return nil unless attributes.is_a?(Hash)
  257. 1 attributes = attributes.transform_keys(&:to_sym)
  258. 1 transformed_hash = {}
  259. 1 openapi_types.each_pair do |key, type|
  260. 10 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  261. transformed_hash["#{key}"] = nil
  262. 10 elsif type =~ /\AArray<(.*)>/i
  263. # check to ensure the input is an array given that the attribute
  264. # is documented as an array but the input is not
  265. if attributes[attribute_map[key]].is_a?(Array)
  266. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  267. end
  268. 10 elsif !attributes[attribute_map[key]].nil?
  269. 10 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  270. end
  271. end
  272. 1 new(transformed_hash)
  273. end
  274. # Returns the object in the form of hash
  275. # @return [Hash] Returns the object in the form of hash
  276. 1 def to_hash
  277. 3 hash = {}
  278. 3 self.class.attribute_map.each_pair do |attr, param|
  279. 30 value = self.send(attr)
  280. 30 if value.nil?
  281. 6 is_nullable = self.class.openapi_nullable.include?(attr)
  282. 6 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  283. end
  284. 24 hash[param] = _to_hash(value)
  285. end
  286. 3 hash
  287. end
  288. end
  289. end

lib/bandwidth-sdk/models/update_call_recording.rb

73.75% lines covered

80 relevant lines. 59 lines covered and 21 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class UpdateCallRecording < ApiModelBase
  13. 1 attr_accessor :state
  14. 1 class EnumAttributeValidator
  15. 1 attr_reader :datatype
  16. 1 attr_reader :allowable_values
  17. 1 def initialize(datatype, allowable_values)
  18. @allowable_values = allowable_values.map do |value|
  19. case datatype.to_s
  20. when /Integer/i
  21. value.to_i
  22. when /Float/i
  23. value.to_f
  24. else
  25. value
  26. end
  27. end
  28. end
  29. 1 def valid?(value)
  30. !value || allowable_values.include?(value)
  31. end
  32. end
  33. # Attribute mapping from ruby-style variable name to JSON key.
  34. 1 def self.attribute_map
  35. 18 {
  36. :'state' => :'state'
  37. }
  38. end
  39. # Returns attribute mapping this model knows about
  40. 1 def self.acceptable_attribute_map
  41. 10 attribute_map
  42. end
  43. # Returns all the JSON keys this model knows about
  44. 1 def self.acceptable_attributes
  45. 1 acceptable_attribute_map.values
  46. end
  47. # Attribute type mapping.
  48. 1 def self.openapi_types
  49. 1 {
  50. :'state' => :'RecordingStateEnum'
  51. }
  52. end
  53. # List of attributes with nullable: true
  54. 1 def self.openapi_nullable
  55. 1 Set.new([
  56. ])
  57. end
  58. # Initializes the object
  59. # @param [Hash] attributes Model attributes in the form of hash
  60. 1 def initialize(attributes = {})
  61. 10 if (!attributes.is_a?(Hash))
  62. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::UpdateCallRecording` initialize method'
  63. end
  64. # check to see if the attribute exists and convert string to symbol for hash key
  65. 9 acceptable_attribute_map = self.class.acceptable_attribute_map
  66. 9 attributes = attributes.each_with_object({}) { |(k, v), h|
  67. 9 if (!acceptable_attribute_map.key?(k.to_sym))
  68. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::UpdateCallRecording`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  69. end
  70. 8 h[k.to_sym] = v
  71. }
  72. 8 if attributes.key?(:'state')
  73. 8 self.state = attributes[:'state']
  74. else
  75. self.state = nil
  76. end
  77. end
  78. # Show invalid properties with the reasons. Usually used together with valid?
  79. # @return Array for valid properties with the reasons
  80. 1 def list_invalid_properties
  81. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  82. invalid_properties = Array.new
  83. if @state.nil?
  84. invalid_properties.push('invalid value for "state", state cannot be nil.')
  85. end
  86. invalid_properties
  87. end
  88. # Check to see if the all the properties in the model are valid
  89. # @return true if the model is valid
  90. 1 def valid?
  91. warn '[DEPRECATED] the `valid?` method is obsolete'
  92. return false if @state.nil?
  93. true
  94. end
  95. # Custom attribute writer method with validation
  96. # @param [Object] state Value to be assigned
  97. 1 def state=(state)
  98. 8 if state.nil?
  99. 1 fail ArgumentError, 'state cannot be nil'
  100. end
  101. 7 @state = state
  102. end
  103. # Checks equality by comparing each attribute.
  104. # @param [Object] Object to be compared
  105. 1 def ==(o)
  106. 2 return true if self.equal?(o)
  107. 2 self.class == o.class &&
  108. state == o.state
  109. end
  110. # @see the `==` method
  111. # @param [Object] Object to be compared
  112. 1 def eql?(o)
  113. 2 self == o
  114. end
  115. # Calculates hash code according to all attributes.
  116. # @return [Integer] Hash code
  117. 1 def hash
  118. [state].hash
  119. end
  120. # Builds the object from hash
  121. # @param [Hash] attributes Model attributes in the form of hash
  122. # @return [Object] Returns the model itself
  123. 1 def self.build_from_hash(attributes)
  124. 1 return nil unless attributes.is_a?(Hash)
  125. 1 attributes = attributes.transform_keys(&:to_sym)
  126. 1 transformed_hash = {}
  127. 1 openapi_types.each_pair do |key, type|
  128. 1 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  129. transformed_hash["#{key}"] = nil
  130. 1 elsif type =~ /\AArray<(.*)>/i
  131. # check to ensure the input is an array given that the attribute
  132. # is documented as an array but the input is not
  133. if attributes[attribute_map[key]].is_a?(Array)
  134. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  135. end
  136. 1 elsif !attributes[attribute_map[key]].nil?
  137. 1 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  138. end
  139. end
  140. 1 new(transformed_hash)
  141. end
  142. # Returns the object in the form of hash
  143. # @return [Hash] Returns the object in the form of hash
  144. 1 def to_hash
  145. 3 hash = {}
  146. 3 self.class.attribute_map.each_pair do |attr, param|
  147. 3 value = self.send(attr)
  148. 3 if value.nil?
  149. is_nullable = self.class.openapi_nullable.include?(attr)
  150. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  151. end
  152. 3 hash[param] = _to_hash(value)
  153. end
  154. 3 hash
  155. end
  156. end
  157. end

lib/bandwidth-sdk/models/update_conference.rb

77.17% lines covered

127 relevant lines. 98 lines covered and 29 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class UpdateConference < ApiModelBase
  13. 1 attr_accessor :status
  14. # The URL to send the [conferenceRedirect](/docs/voice/webhooks/conferenceRedirect) event which will provide new BXML. Not allowed if `state` is `completed`, but required if `state` is `active`.
  15. 1 attr_accessor :redirect_url
  16. 1 attr_accessor :redirect_method
  17. # Basic auth username.
  18. 1 attr_accessor :username
  19. # Basic auth password.
  20. 1 attr_accessor :password
  21. # A fallback url which, if provided, will be used to retry the `conferenceRedirect` webhook delivery in case `redirectUrl` fails to respond. Not allowed if `state` is `completed`.
  22. 1 attr_accessor :redirect_fallback_url
  23. 1 attr_accessor :redirect_fallback_method
  24. # Basic auth username.
  25. 1 attr_accessor :fallback_username
  26. # Basic auth password.
  27. 1 attr_accessor :fallback_password
  28. 1 class EnumAttributeValidator
  29. 1 attr_reader :datatype
  30. 1 attr_reader :allowable_values
  31. 1 def initialize(datatype, allowable_values)
  32. @allowable_values = allowable_values.map do |value|
  33. case datatype.to_s
  34. when /Integer/i
  35. value.to_i
  36. when /Float/i
  37. value.to_f
  38. else
  39. value
  40. end
  41. end
  42. end
  43. 1 def valid?(value)
  44. !value || allowable_values.include?(value)
  45. end
  46. end
  47. # Attribute mapping from ruby-style variable name to JSON key.
  48. 1 def self.attribute_map
  49. 53 {
  50. :'status' => :'status',
  51. :'redirect_url' => :'redirectUrl',
  52. :'redirect_method' => :'redirectMethod',
  53. :'username' => :'username',
  54. :'password' => :'password',
  55. :'redirect_fallback_url' => :'redirectFallbackUrl',
  56. :'redirect_fallback_method' => :'redirectFallbackMethod',
  57. :'fallback_username' => :'fallbackUsername',
  58. :'fallback_password' => :'fallbackPassword'
  59. }
  60. end
  61. # Returns attribute mapping this model knows about
  62. 1 def self.acceptable_attribute_map
  63. 13 attribute_map
  64. end
  65. # Returns all the JSON keys this model knows about
  66. 1 def self.acceptable_attributes
  67. 1 acceptable_attribute_map.values
  68. end
  69. # Attribute type mapping.
  70. 1 def self.openapi_types
  71. 1 {
  72. :'status' => :'ConferenceStateEnum',
  73. :'redirect_url' => :'String',
  74. :'redirect_method' => :'RedirectMethodEnum',
  75. :'username' => :'String',
  76. :'password' => :'String',
  77. :'redirect_fallback_url' => :'String',
  78. :'redirect_fallback_method' => :'RedirectMethodEnum',
  79. :'fallback_username' => :'String',
  80. :'fallback_password' => :'String'
  81. }
  82. end
  83. # List of attributes with nullable: true
  84. 1 def self.openapi_nullable
  85. 1 Set.new([
  86. :'status',
  87. :'redirect_url',
  88. :'redirect_method',
  89. :'username',
  90. :'password',
  91. :'redirect_fallback_url',
  92. :'redirect_fallback_method',
  93. :'fallback_username',
  94. :'fallback_password'
  95. ])
  96. end
  97. # Initializes the object
  98. # @param [Hash] attributes Model attributes in the form of hash
  99. 1 def initialize(attributes = {})
  100. 13 if (!attributes.is_a?(Hash))
  101. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::UpdateConference` initialize method'
  102. end
  103. # check to see if the attribute exists and convert string to symbol for hash key
  104. 12 acceptable_attribute_map = self.class.acceptable_attribute_map
  105. 12 attributes = attributes.each_with_object({}) { |(k, v), h|
  106. 50 if (!acceptable_attribute_map.key?(k.to_sym))
  107. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::UpdateConference`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  108. end
  109. 49 h[k.to_sym] = v
  110. }
  111. 11 if attributes.key?(:'status')
  112. 5 self.status = attributes[:'status']
  113. else
  114. 6 self.status = 'active'
  115. end
  116. 11 if attributes.key?(:'redirect_url')
  117. 5 self.redirect_url = attributes[:'redirect_url']
  118. end
  119. 11 if attributes.key?(:'redirect_method')
  120. 5 self.redirect_method = attributes[:'redirect_method']
  121. else
  122. 6 self.redirect_method = 'POST'
  123. end
  124. 11 if attributes.key?(:'username')
  125. 6 self.username = attributes[:'username']
  126. end
  127. 10 if attributes.key?(:'password')
  128. 6 self.password = attributes[:'password']
  129. end
  130. 9 if attributes.key?(:'redirect_fallback_url')
  131. 5 self.redirect_fallback_url = attributes[:'redirect_fallback_url']
  132. end
  133. 9 if attributes.key?(:'redirect_fallback_method')
  134. 5 self.redirect_fallback_method = attributes[:'redirect_fallback_method']
  135. else
  136. 4 self.redirect_fallback_method = 'POST'
  137. end
  138. 9 if attributes.key?(:'fallback_username')
  139. 6 self.fallback_username = attributes[:'fallback_username']
  140. end
  141. 8 if attributes.key?(:'fallback_password')
  142. 6 self.fallback_password = attributes[:'fallback_password']
  143. end
  144. end
  145. # Show invalid properties with the reasons. Usually used together with valid?
  146. # @return Array for valid properties with the reasons
  147. 1 def list_invalid_properties
  148. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  149. invalid_properties = Array.new
  150. if !@username.nil? && @username.to_s.length > 1024
  151. invalid_properties.push('invalid value for "username", the character length must be smaller than or equal to 1024.')
  152. end
  153. if !@password.nil? && @password.to_s.length > 1024
  154. invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 1024.')
  155. end
  156. if !@fallback_username.nil? && @fallback_username.to_s.length > 1024
  157. invalid_properties.push('invalid value for "fallback_username", the character length must be smaller than or equal to 1024.')
  158. end
  159. if !@fallback_password.nil? && @fallback_password.to_s.length > 1024
  160. invalid_properties.push('invalid value for "fallback_password", the character length must be smaller than or equal to 1024.')
  161. end
  162. invalid_properties
  163. end
  164. # Check to see if the all the properties in the model are valid
  165. # @return true if the model is valid
  166. 1 def valid?
  167. warn '[DEPRECATED] the `valid?` method is obsolete'
  168. return false if !@username.nil? && @username.to_s.length > 1024
  169. return false if !@password.nil? && @password.to_s.length > 1024
  170. return false if !@fallback_username.nil? && @fallback_username.to_s.length > 1024
  171. return false if !@fallback_password.nil? && @fallback_password.to_s.length > 1024
  172. true
  173. end
  174. # Custom attribute writer method with validation
  175. # @param [Object] username Value to be assigned
  176. 1 def username=(username)
  177. 6 if !username.nil? && username.to_s.length > 1024
  178. 1 fail ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 1024.'
  179. end
  180. 5 @username = username
  181. end
  182. # Custom attribute writer method with validation
  183. # @param [Object] password Value to be assigned
  184. 1 def password=(password)
  185. 6 if !password.nil? && password.to_s.length > 1024
  186. 1 fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 1024.'
  187. end
  188. 5 @password = password
  189. end
  190. # Custom attribute writer method with validation
  191. # @param [Object] fallback_username Value to be assigned
  192. 1 def fallback_username=(fallback_username)
  193. 6 if !fallback_username.nil? && fallback_username.to_s.length > 1024
  194. 1 fail ArgumentError, 'invalid value for "fallback_username", the character length must be smaller than or equal to 1024.'
  195. end
  196. 5 @fallback_username = fallback_username
  197. end
  198. # Custom attribute writer method with validation
  199. # @param [Object] fallback_password Value to be assigned
  200. 1 def fallback_password=(fallback_password)
  201. 6 if !fallback_password.nil? && fallback_password.to_s.length > 1024
  202. 1 fail ArgumentError, 'invalid value for "fallback_password", the character length must be smaller than or equal to 1024.'
  203. end
  204. 5 @fallback_password = fallback_password
  205. end
  206. # Checks equality by comparing each attribute.
  207. # @param [Object] Object to be compared
  208. 1 def ==(o)
  209. 2 return true if self.equal?(o)
  210. 2 self.class == o.class &&
  211. status == o.status &&
  212. redirect_url == o.redirect_url &&
  213. redirect_method == o.redirect_method &&
  214. username == o.username &&
  215. password == o.password &&
  216. redirect_fallback_url == o.redirect_fallback_url &&
  217. redirect_fallback_method == o.redirect_fallback_method &&
  218. fallback_username == o.fallback_username &&
  219. fallback_password == o.fallback_password
  220. end
  221. # @see the `==` method
  222. # @param [Object] Object to be compared
  223. 1 def eql?(o)
  224. 2 self == o
  225. end
  226. # Calculates hash code according to all attributes.
  227. # @return [Integer] Hash code
  228. 1 def hash
  229. [status, redirect_url, redirect_method, username, password, redirect_fallback_url, redirect_fallback_method, fallback_username, fallback_password].hash
  230. end
  231. # Builds the object from hash
  232. # @param [Hash] attributes Model attributes in the form of hash
  233. # @return [Object] Returns the model itself
  234. 1 def self.build_from_hash(attributes)
  235. 1 return nil unless attributes.is_a?(Hash)
  236. 1 attributes = attributes.transform_keys(&:to_sym)
  237. 1 transformed_hash = {}
  238. 1 openapi_types.each_pair do |key, type|
  239. 9 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  240. transformed_hash["#{key}"] = nil
  241. 9 elsif type =~ /\AArray<(.*)>/i
  242. # check to ensure the input is an array given that the attribute
  243. # is documented as an array but the input is not
  244. if attributes[attribute_map[key]].is_a?(Array)
  245. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  246. end
  247. 9 elsif !attributes[attribute_map[key]].nil?
  248. 9 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  249. end
  250. end
  251. 1 new(transformed_hash)
  252. end
  253. # Returns the object in the form of hash
  254. # @return [Hash] Returns the object in the form of hash
  255. 1 def to_hash
  256. 3 hash = {}
  257. 3 self.class.attribute_map.each_pair do |attr, param|
  258. 27 value = self.send(attr)
  259. 27 if value.nil?
  260. is_nullable = self.class.openapi_nullable.include?(attr)
  261. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  262. end
  263. 27 hash[param] = _to_hash(value)
  264. end
  265. 3 hash
  266. end
  267. end
  268. end

lib/bandwidth-sdk/models/update_conference_member.rb

89.71% lines covered

68 relevant lines. 61 lines covered and 7 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class UpdateConferenceMember < ApiModelBase
  13. # Whether or not this member is currently muted. Members who are muted are still able to hear other participants. Updates this member's mute status. Has no effect if omitted.
  14. 1 attr_accessor :mute
  15. # Whether or not this member is currently on hold. Members who are on hold are not able to hear or speak in the conference. Updates this member's hold status. Has no effect if omitted.
  16. 1 attr_accessor :hold
  17. # If this member had a value set for `callIdsToCoach` in its [Conference](/docs/voice/bxml/conference) verb or this list was added with a previous PUT request to modify the member, this is that list of calls. Modifies the calls that this member is coaching. Has no effect if omitted. See the documentation for the [Conference](/docs/voice/bxml/conference) verb for more details about coaching. Note that this will not add the matching calls to the conference; each call must individually execute a Conference verb to join.
  18. 1 attr_accessor :call_ids_to_coach
  19. # Attribute mapping from ruby-style variable name to JSON key.
  20. 1 def self.attribute_map
  21. 25 {
  22. :'mute' => :'mute',
  23. :'hold' => :'hold',
  24. :'call_ids_to_coach' => :'callIdsToCoach'
  25. }
  26. end
  27. # Returns attribute mapping this model knows about
  28. 1 def self.acceptable_attribute_map
  29. 9 attribute_map
  30. end
  31. # Returns all the JSON keys this model knows about
  32. 1 def self.acceptable_attributes
  33. 1 acceptable_attribute_map.values
  34. end
  35. # Attribute type mapping.
  36. 1 def self.openapi_types
  37. 1 {
  38. :'mute' => :'Boolean',
  39. :'hold' => :'Boolean',
  40. :'call_ids_to_coach' => :'Array<String>'
  41. }
  42. end
  43. # List of attributes with nullable: true
  44. 1 def self.openapi_nullable
  45. 3 Set.new([
  46. :'call_ids_to_coach'
  47. ])
  48. end
  49. # Initializes the object
  50. # @param [Hash] attributes Model attributes in the form of hash
  51. 1 def initialize(attributes = {})
  52. 9 if (!attributes.is_a?(Hash))
  53. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::UpdateConferenceMember` initialize method'
  54. end
  55. # check to see if the attribute exists and convert string to symbol for hash key
  56. 8 acceptable_attribute_map = self.class.acceptable_attribute_map
  57. 8 attributes = attributes.each_with_object({}) { |(k, v), h|
  58. 14 if (!acceptable_attribute_map.key?(k.to_sym))
  59. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::UpdateConferenceMember`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  60. end
  61. 13 h[k.to_sym] = v
  62. }
  63. 7 if attributes.key?(:'mute')
  64. 5 self.mute = attributes[:'mute']
  65. end
  66. 7 if attributes.key?(:'hold')
  67. 4 self.hold = attributes[:'hold']
  68. end
  69. 7 if attributes.key?(:'call_ids_to_coach')
  70. 4 if (value = attributes[:'call_ids_to_coach']).is_a?(Array)
  71. 4 self.call_ids_to_coach = value
  72. end
  73. end
  74. end
  75. # Show invalid properties with the reasons. Usually used together with valid?
  76. # @return Array for valid properties with the reasons
  77. 1 def list_invalid_properties
  78. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  79. invalid_properties = Array.new
  80. invalid_properties
  81. end
  82. # Check to see if the all the properties in the model are valid
  83. # @return true if the model is valid
  84. 1 def valid?
  85. warn '[DEPRECATED] the `valid?` method is obsolete'
  86. true
  87. end
  88. # Checks equality by comparing each attribute.
  89. # @param [Object] Object to be compared
  90. 1 def ==(o)
  91. 2 return true if self.equal?(o)
  92. 2 self.class == o.class &&
  93. mute == o.mute &&
  94. hold == o.hold &&
  95. call_ids_to_coach == o.call_ids_to_coach
  96. end
  97. # @see the `==` method
  98. # @param [Object] Object to be compared
  99. 1 def eql?(o)
  100. 2 self == o
  101. end
  102. # Calculates hash code according to all attributes.
  103. # @return [Integer] Hash code
  104. 1 def hash
  105. [mute, hold, call_ids_to_coach].hash
  106. end
  107. # Builds the object from hash
  108. # @param [Hash] attributes Model attributes in the form of hash
  109. # @return [Object] Returns the model itself
  110. 1 def self.build_from_hash(attributes)
  111. 1 return nil unless attributes.is_a?(Hash)
  112. 1 attributes = attributes.transform_keys(&:to_sym)
  113. 1 transformed_hash = {}
  114. 1 openapi_types.each_pair do |key, type|
  115. 3 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  116. transformed_hash["#{key}"] = nil
  117. 3 elsif type =~ /\AArray<(.*)>/i
  118. # check to ensure the input is an array given that the attribute
  119. # is documented as an array but the input is not
  120. 1 if attributes[attribute_map[key]].is_a?(Array)
  121. 2 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  122. end
  123. 2 elsif !attributes[attribute_map[key]].nil?
  124. 2 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  125. end
  126. end
  127. 1 new(transformed_hash)
  128. end
  129. # Returns the object in the form of hash
  130. # @return [Hash] Returns the object in the form of hash
  131. 1 def to_hash
  132. 3 hash = {}
  133. 3 self.class.attribute_map.each_pair do |attr, param|
  134. 9 value = self.send(attr)
  135. 9 if value.nil?
  136. 2 is_nullable = self.class.openapi_nullable.include?(attr)
  137. 2 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  138. end
  139. 7 hash[param] = _to_hash(value)
  140. end
  141. 3 hash
  142. end
  143. end
  144. end

lib/bandwidth-sdk/models/verification_denial_webhook.rb

82.88% lines covered

111 relevant lines. 92 lines covered and 19 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class VerificationDenialWebhook < ApiModelBase
  13. # User's account ID.
  14. 1 attr_accessor :account_id
  15. # An optional list of denial reasons in addition to declineReasonDescription when multiple reasons apply.
  16. 1 attr_accessor :additional_denial_reasons
  17. # Explanation for why a verification request was declined.
  18. 1 attr_accessor :decline_reason_description
  19. # Reason code for denial.
  20. 1 attr_accessor :denial_status_code
  21. # Unique identifier (UUID) generated by Bandwidth to assist in tracking the verification status of a toll-free number.
  22. 1 attr_accessor :internal_ticket_number
  23. # Toll-free telephone number in E.164 format.
  24. 1 attr_accessor :phone_number
  25. # Whether a Toll-Free Verification request qualifies for resubmission via PUT.
  26. 1 attr_accessor :resubmit_allowed
  27. 1 attr_accessor :status
  28. # Whether a Toll-Free Verification is blocked. This attribute will only be defined when the number is blocked.
  29. 1 attr_accessor :blocked
  30. # The reason why the Toll-Free Verification is blocked. This attribute will only be defined when the number is blocked.
  31. 1 attr_accessor :blocked_reason
  32. # Attribute mapping from ruby-style variable name to JSON key.
  33. 1 def self.attribute_map
  34. 55 {
  35. :'account_id' => :'accountId',
  36. :'additional_denial_reasons' => :'additionalDenialReasons',
  37. :'decline_reason_description' => :'declineReasonDescription',
  38. :'denial_status_code' => :'denialStatusCode',
  39. :'internal_ticket_number' => :'internalTicketNumber',
  40. :'phone_number' => :'phoneNumber',
  41. :'resubmit_allowed' => :'resubmitAllowed',
  42. :'status' => :'status',
  43. :'blocked' => :'blocked',
  44. :'blocked_reason' => :'blockedReason'
  45. }
  46. end
  47. # Returns attribute mapping this model knows about
  48. 1 def self.acceptable_attribute_map
  49. 12 attribute_map
  50. end
  51. # Returns all the JSON keys this model knows about
  52. 1 def self.acceptable_attributes
  53. 1 acceptable_attribute_map.values
  54. end
  55. # Attribute type mapping.
  56. 1 def self.openapi_types
  57. 1 {
  58. :'account_id' => :'String',
  59. :'additional_denial_reasons' => :'Array<AdditionalDenialReason>',
  60. :'decline_reason_description' => :'String',
  61. :'denial_status_code' => :'Integer',
  62. :'internal_ticket_number' => :'String',
  63. :'phone_number' => :'String',
  64. :'resubmit_allowed' => :'Boolean',
  65. :'status' => :'String',
  66. :'blocked' => :'Boolean',
  67. :'blocked_reason' => :'String'
  68. }
  69. end
  70. # List of attributes with nullable: true
  71. 1 def self.openapi_nullable
  72. 1 Set.new([
  73. ])
  74. end
  75. # Initializes the object
  76. # @param [Hash] attributes Model attributes in the form of hash
  77. 1 def initialize(attributes = {})
  78. 12 if (!attributes.is_a?(Hash))
  79. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::VerificationDenialWebhook` initialize method'
  80. end
  81. # check to see if the attribute exists and convert string to symbol for hash key
  82. 11 acceptable_attribute_map = self.class.acceptable_attribute_map
  83. 11 attributes = attributes.each_with_object({}) { |(k, v), h|
  84. 45 if (!acceptable_attribute_map.key?(k.to_sym))
  85. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::VerificationDenialWebhook`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  86. end
  87. 44 h[k.to_sym] = v
  88. }
  89. 10 if attributes.key?(:'account_id')
  90. 4 self.account_id = attributes[:'account_id']
  91. end
  92. 10 if attributes.key?(:'additional_denial_reasons')
  93. 4 if (value = attributes[:'additional_denial_reasons']).is_a?(Array)
  94. 4 self.additional_denial_reasons = value
  95. end
  96. end
  97. 10 if attributes.key?(:'decline_reason_description')
  98. 4 self.decline_reason_description = attributes[:'decline_reason_description']
  99. end
  100. 10 if attributes.key?(:'denial_status_code')
  101. 4 self.denial_status_code = attributes[:'denial_status_code']
  102. end
  103. 10 if attributes.key?(:'internal_ticket_number')
  104. 4 self.internal_ticket_number = attributes[:'internal_ticket_number']
  105. end
  106. 10 if attributes.key?(:'phone_number')
  107. 8 self.phone_number = attributes[:'phone_number']
  108. end
  109. 6 if attributes.key?(:'resubmit_allowed')
  110. 4 self.resubmit_allowed = attributes[:'resubmit_allowed']
  111. end
  112. 6 if attributes.key?(:'status')
  113. 4 self.status = attributes[:'status']
  114. else
  115. 2 self.status = 'UNVERIFIED'
  116. end
  117. 6 if attributes.key?(:'blocked')
  118. 4 self.blocked = attributes[:'blocked']
  119. end
  120. 6 if attributes.key?(:'blocked_reason')
  121. 4 self.blocked_reason = attributes[:'blocked_reason']
  122. end
  123. end
  124. # Show invalid properties with the reasons. Usually used together with valid?
  125. # @return Array for valid properties with the reasons
  126. 1 def list_invalid_properties
  127. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  128. invalid_properties = Array.new
  129. if !@phone_number.nil? && @phone_number.to_s.length > 12
  130. invalid_properties.push('invalid value for "phone_number", the character length must be smaller than or equal to 12.')
  131. end
  132. if !@phone_number.nil? && @phone_number.to_s.length < 12
  133. invalid_properties.push('invalid value for "phone_number", the character length must be greater than or equal to 12.')
  134. end
  135. pattern = Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
  136. if !@phone_number.nil? && @phone_number !~ pattern
  137. invalid_properties.push("invalid value for \"phone_number\", must conform to the pattern #{pattern}.")
  138. end
  139. invalid_properties
  140. end
  141. # Check to see if the all the properties in the model are valid
  142. # @return true if the model is valid
  143. 1 def valid?
  144. warn '[DEPRECATED] the `valid?` method is obsolete'
  145. return false if !@phone_number.nil? && @phone_number.to_s.length > 12
  146. return false if !@phone_number.nil? && @phone_number.to_s.length < 12
  147. return false if !@phone_number.nil? && @phone_number !~ Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
  148. true
  149. end
  150. # Custom attribute writer method with validation
  151. # @param [Object] phone_number Value to be assigned
  152. 1 def phone_number=(phone_number)
  153. 8 if phone_number.nil?
  154. 1 fail ArgumentError, 'phone_number cannot be nil'
  155. end
  156. 7 if phone_number.to_s.length > 12
  157. 1 fail ArgumentError, 'invalid value for "phone_number", the character length must be smaller than or equal to 12.'
  158. end
  159. 6 if phone_number.to_s.length < 12
  160. 1 fail ArgumentError, 'invalid value for "phone_number", the character length must be greater than or equal to 12.'
  161. end
  162. 5 pattern = Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
  163. 5 if phone_number !~ pattern
  164. 1 fail ArgumentError, "invalid value for \"phone_number\", must conform to the pattern #{pattern}."
  165. end
  166. 4 @phone_number = phone_number
  167. end
  168. # Checks equality by comparing each attribute.
  169. # @param [Object] Object to be compared
  170. 1 def ==(o)
  171. 2 return true if self.equal?(o)
  172. 2 self.class == o.class &&
  173. account_id == o.account_id &&
  174. additional_denial_reasons == o.additional_denial_reasons &&
  175. decline_reason_description == o.decline_reason_description &&
  176. denial_status_code == o.denial_status_code &&
  177. internal_ticket_number == o.internal_ticket_number &&
  178. phone_number == o.phone_number &&
  179. resubmit_allowed == o.resubmit_allowed &&
  180. status == o.status &&
  181. blocked == o.blocked &&
  182. blocked_reason == o.blocked_reason
  183. end
  184. # @see the `==` method
  185. # @param [Object] Object to be compared
  186. 1 def eql?(o)
  187. 2 self == o
  188. end
  189. # Calculates hash code according to all attributes.
  190. # @return [Integer] Hash code
  191. 1 def hash
  192. [account_id, additional_denial_reasons, decline_reason_description, denial_status_code, internal_ticket_number, phone_number, resubmit_allowed, status, blocked, blocked_reason].hash
  193. end
  194. # Builds the object from hash
  195. # @param [Hash] attributes Model attributes in the form of hash
  196. # @return [Object] Returns the model itself
  197. 1 def self.build_from_hash(attributes)
  198. 1 return nil unless attributes.is_a?(Hash)
  199. 1 attributes = attributes.transform_keys(&:to_sym)
  200. 1 transformed_hash = {}
  201. 1 openapi_types.each_pair do |key, type|
  202. 10 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  203. transformed_hash["#{key}"] = nil
  204. 10 elsif type =~ /\AArray<(.*)>/i
  205. # check to ensure the input is an array given that the attribute
  206. # is documented as an array but the input is not
  207. 1 if attributes[attribute_map[key]].is_a?(Array)
  208. 2 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  209. end
  210. 9 elsif !attributes[attribute_map[key]].nil?
  211. 9 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  212. end
  213. end
  214. 1 new(transformed_hash)
  215. end
  216. # Returns the object in the form of hash
  217. # @return [Hash] Returns the object in the form of hash
  218. 1 def to_hash
  219. 2 hash = {}
  220. 2 self.class.attribute_map.each_pair do |attr, param|
  221. 20 value = self.send(attr)
  222. 20 if value.nil?
  223. is_nullable = self.class.openapi_nullable.include?(attr)
  224. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  225. end
  226. 20 hash[param] = _to_hash(value)
  227. end
  228. 2 hash
  229. end
  230. end
  231. end

lib/bandwidth-sdk/models/verification_request.rb

64.13% lines covered

329 relevant lines. 211 lines covered and 118 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class VerificationRequest < ApiModelBase
  13. 1 attr_accessor :business_address
  14. 1 attr_accessor :business_contact
  15. # Estimated monthly volume of messages from the toll-free number.
  16. 1 attr_accessor :message_volume
  17. 1 attr_accessor :phone_numbers
  18. # The category of the use case.
  19. 1 attr_accessor :use_case
  20. # A general idea of the use case and customer.
  21. 1 attr_accessor :use_case_summary
  22. # Example of message content.
  23. 1 attr_accessor :production_message_content
  24. 1 attr_accessor :opt_in_workflow
  25. # Any additional information.
  26. 1 attr_accessor :additional_information
  27. # ISV name.
  28. 1 attr_accessor :isv_reseller
  29. # The Toll-Free Verification request privacy policy URL.
  30. 1 attr_accessor :privacy_policy_url
  31. # The Toll-Free Verification request terms and conditions policy URL.
  32. 1 attr_accessor :terms_and_conditions_url
  33. # The company 'Doing Business As'.
  34. 1 attr_accessor :business_dba
  35. # Government-issued business identifying number. **Note: As of October 19th, 2026 this field will be required when `businessEntityType` is _not_ `SOLE_PROPRIETOR`. If this field is provided, `businessRegistrationType` and `businessRegistrationIssuingCountry` are also required.**
  36. 1 attr_accessor :business_registration_number
  37. 1 attr_accessor :business_registration_type
  38. # The country issuing the business registration in ISO-3166-1 alpha-3 format. Alpha-2 format is accepted by the API, but alpha-3 is highly encouraged. **Note: As of October 19th, 2026 this field will be required when `businessRegistrationNumber` is provided.** | Registration Type | Supported Countries | |----------------------|------------------------------------| | EIN | USA | | CBN | CAN | | NEQ | CAN | | PROVINCIAL_NUMBER | CAN | | CRN | GBR, HKG | | VAT | GBR, IRL, BRA, NLD | | ACN | AUS | | ABN | AUS | | BRN | HKG | | SIREN | FRA | | SIRET | FRA | | NZBN | NZL | | UST_IDNR | DEU | | CIF | ESP | | NIF | ESP | | CNPJ | BRA | | UID | CHE | | OTHER | Must Provide Country Code |
  39. 1 attr_accessor :business_registration_issuing_country
  40. 1 attr_accessor :business_entity_type
  41. # A message that gets sent to users requesting help.
  42. 1 attr_accessor :help_message_response
  43. # Indicates whether the content is age-gated.
  44. 1 attr_accessor :age_gated_content
  45. # The token provided by Campaign Verify to validate your political use case. Only required for 527 political organizations. If you are not a 527 political organization, this field should be omitted. Supplying an empty string will likely result in rejection.
  46. 1 attr_accessor :cv_token
  47. 1 class EnumAttributeValidator
  48. 1 attr_reader :datatype
  49. 1 attr_reader :allowable_values
  50. 1 def initialize(datatype, allowable_values)
  51. @allowable_values = allowable_values.map do |value|
  52. case datatype.to_s
  53. when /Integer/i
  54. value.to_i
  55. when /Float/i
  56. value.to_f
  57. else
  58. value
  59. end
  60. end
  61. end
  62. 1 def valid?(value)
  63. !value || allowable_values.include?(value)
  64. end
  65. end
  66. # Attribute mapping from ruby-style variable name to JSON key.
  67. 1 def self.attribute_map
  68. 110 {
  69. :'business_address' => :'businessAddress',
  70. :'business_contact' => :'businessContact',
  71. :'message_volume' => :'messageVolume',
  72. :'phone_numbers' => :'phoneNumbers',
  73. :'use_case' => :'useCase',
  74. :'use_case_summary' => :'useCaseSummary',
  75. :'production_message_content' => :'productionMessageContent',
  76. :'opt_in_workflow' => :'optInWorkflow',
  77. :'additional_information' => :'additionalInformation',
  78. :'isv_reseller' => :'isvReseller',
  79. :'privacy_policy_url' => :'privacyPolicyUrl',
  80. :'terms_and_conditions_url' => :'termsAndConditionsUrl',
  81. :'business_dba' => :'businessDba',
  82. :'business_registration_number' => :'businessRegistrationNumber',
  83. :'business_registration_type' => :'businessRegistrationType',
  84. :'business_registration_issuing_country' => :'businessRegistrationIssuingCountry',
  85. :'business_entity_type' => :'businessEntityType',
  86. :'help_message_response' => :'helpMessageResponse',
  87. :'age_gated_content' => :'ageGatedContent',
  88. :'cv_token' => :'cvToken'
  89. }
  90. end
  91. # Returns attribute mapping this model knows about
  92. 1 def self.acceptable_attribute_map
  93. 26 attribute_map
  94. end
  95. # Returns all the JSON keys this model knows about
  96. 1 def self.acceptable_attributes
  97. 1 acceptable_attribute_map.values
  98. end
  99. # Attribute type mapping.
  100. 1 def self.openapi_types
  101. 1 {
  102. :'business_address' => :'Address',
  103. :'business_contact' => :'Contact',
  104. :'message_volume' => :'Integer',
  105. :'phone_numbers' => :'Array<String>',
  106. :'use_case' => :'String',
  107. :'use_case_summary' => :'String',
  108. :'production_message_content' => :'String',
  109. :'opt_in_workflow' => :'OptInWorkflow',
  110. :'additional_information' => :'String',
  111. :'isv_reseller' => :'String',
  112. :'privacy_policy_url' => :'String',
  113. :'terms_and_conditions_url' => :'String',
  114. :'business_dba' => :'String',
  115. :'business_registration_number' => :'String',
  116. :'business_registration_type' => :'BusinessRegistrationTypeEnum',
  117. :'business_registration_issuing_country' => :'String',
  118. :'business_entity_type' => :'BusinessEntityTypeEnum',
  119. :'help_message_response' => :'String',
  120. :'age_gated_content' => :'Boolean',
  121. :'cv_token' => :'String'
  122. }
  123. end
  124. # List of attributes with nullable: true
  125. 1 def self.openapi_nullable
  126. 7 Set.new([
  127. :'additional_information',
  128. :'isv_reseller',
  129. :'business_registration_number',
  130. :'business_registration_type',
  131. :'business_registration_issuing_country',
  132. :'help_message_response',
  133. :'cv_token'
  134. ])
  135. end
  136. # Initializes the object
  137. # @param [Hash] attributes Model attributes in the form of hash
  138. 1 def initialize(attributes = {})
  139. 26 if (!attributes.is_a?(Hash))
  140. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::VerificationRequest` initialize method'
  141. end
  142. # check to see if the attribute exists and convert string to symbol for hash key
  143. 25 acceptable_attribute_map = self.class.acceptable_attribute_map
  144. 25 attributes = attributes.each_with_object({}) { |(k, v), h|
  145. 453 if (!acceptable_attribute_map.key?(k.to_sym))
  146. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::VerificationRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  147. end
  148. 452 h[k.to_sym] = v
  149. }
  150. 24 if attributes.key?(:'business_address')
  151. 24 self.business_address = attributes[:'business_address']
  152. else
  153. self.business_address = nil
  154. end
  155. 24 if attributes.key?(:'business_contact')
  156. 24 self.business_contact = attributes[:'business_contact']
  157. else
  158. self.business_contact = nil
  159. end
  160. 24 if attributes.key?(:'message_volume')
  161. 24 self.message_volume = attributes[:'message_volume']
  162. else
  163. self.message_volume = nil
  164. end
  165. 24 if attributes.key?(:'phone_numbers')
  166. 24 if (value = attributes[:'phone_numbers']).is_a?(Array)
  167. 24 self.phone_numbers = value
  168. end
  169. else
  170. self.phone_numbers = nil
  171. end
  172. 24 if attributes.key?(:'use_case')
  173. 24 self.use_case = attributes[:'use_case']
  174. else
  175. self.use_case = nil
  176. end
  177. 24 if attributes.key?(:'use_case_summary')
  178. 24 self.use_case_summary = attributes[:'use_case_summary']
  179. else
  180. self.use_case_summary = nil
  181. end
  182. 24 if attributes.key?(:'production_message_content')
  183. 24 self.production_message_content = attributes[:'production_message_content']
  184. else
  185. self.production_message_content = nil
  186. end
  187. 24 if attributes.key?(:'opt_in_workflow')
  188. 24 self.opt_in_workflow = attributes[:'opt_in_workflow']
  189. else
  190. self.opt_in_workflow = nil
  191. end
  192. 24 if attributes.key?(:'additional_information')
  193. 22 self.additional_information = attributes[:'additional_information']
  194. end
  195. 24 if attributes.key?(:'isv_reseller')
  196. 22 self.isv_reseller = attributes[:'isv_reseller']
  197. end
  198. 24 if attributes.key?(:'privacy_policy_url')
  199. 21 self.privacy_policy_url = attributes[:'privacy_policy_url']
  200. end
  201. 24 if attributes.key?(:'terms_and_conditions_url')
  202. 21 self.terms_and_conditions_url = attributes[:'terms_and_conditions_url']
  203. end
  204. 24 if attributes.key?(:'business_dba')
  205. 21 self.business_dba = attributes[:'business_dba']
  206. end
  207. 24 if attributes.key?(:'business_registration_number')
  208. 22 self.business_registration_number = attributes[:'business_registration_number']
  209. end
  210. 24 if attributes.key?(:'business_registration_type')
  211. 22 self.business_registration_type = attributes[:'business_registration_type']
  212. end
  213. 24 if attributes.key?(:'business_registration_issuing_country')
  214. 22 self.business_registration_issuing_country = attributes[:'business_registration_issuing_country']
  215. end
  216. 24 if attributes.key?(:'business_entity_type')
  217. 24 self.business_entity_type = attributes[:'business_entity_type']
  218. else
  219. self.business_entity_type = nil
  220. end
  221. 24 if attributes.key?(:'help_message_response')
  222. 21 self.help_message_response = attributes[:'help_message_response']
  223. end
  224. 24 if attributes.key?(:'age_gated_content')
  225. 21 self.age_gated_content = attributes[:'age_gated_content']
  226. end
  227. 24 if attributes.key?(:'cv_token')
  228. 21 self.cv_token = attributes[:'cv_token']
  229. end
  230. end
  231. # Show invalid properties with the reasons. Usually used together with valid?
  232. # @return Array for valid properties with the reasons
  233. 1 def list_invalid_properties
  234. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  235. invalid_properties = Array.new
  236. if @business_address.nil?
  237. invalid_properties.push('invalid value for "business_address", business_address cannot be nil.')
  238. end
  239. if @business_contact.nil?
  240. invalid_properties.push('invalid value for "business_contact", business_contact cannot be nil.')
  241. end
  242. if @message_volume.nil?
  243. invalid_properties.push('invalid value for "message_volume", message_volume cannot be nil.')
  244. end
  245. if @message_volume > 10000000
  246. invalid_properties.push('invalid value for "message_volume", must be smaller than or equal to 10000000.')
  247. end
  248. if @message_volume < 10
  249. invalid_properties.push('invalid value for "message_volume", must be greater than or equal to 10.')
  250. end
  251. if @phone_numbers.nil?
  252. invalid_properties.push('invalid value for "phone_numbers", phone_numbers cannot be nil.')
  253. end
  254. if @phone_numbers.length > 10
  255. invalid_properties.push('invalid value for "phone_numbers", number of items must be less than or equal to 10.')
  256. end
  257. if @phone_numbers.length < 1
  258. invalid_properties.push('invalid value for "phone_numbers", number of items must be greater than or equal to 1.')
  259. end
  260. if @use_case.nil?
  261. invalid_properties.push('invalid value for "use_case", use_case cannot be nil.')
  262. end
  263. if @use_case.to_s.length > 500
  264. invalid_properties.push('invalid value for "use_case", the character length must be smaller than or equal to 500.')
  265. end
  266. if @use_case.to_s.length < 0
  267. invalid_properties.push('invalid value for "use_case", the character length must be greater than or equal to 0.')
  268. end
  269. if @use_case_summary.nil?
  270. invalid_properties.push('invalid value for "use_case_summary", use_case_summary cannot be nil.')
  271. end
  272. if @use_case_summary.to_s.length > 500
  273. invalid_properties.push('invalid value for "use_case_summary", the character length must be smaller than or equal to 500.')
  274. end
  275. if @use_case_summary.to_s.length < 0
  276. invalid_properties.push('invalid value for "use_case_summary", the character length must be greater than or equal to 0.')
  277. end
  278. if @production_message_content.nil?
  279. invalid_properties.push('invalid value for "production_message_content", production_message_content cannot be nil.')
  280. end
  281. if @production_message_content.to_s.length > 500
  282. invalid_properties.push('invalid value for "production_message_content", the character length must be smaller than or equal to 500.')
  283. end
  284. if @production_message_content.to_s.length < 0
  285. invalid_properties.push('invalid value for "production_message_content", the character length must be greater than or equal to 0.')
  286. end
  287. if @opt_in_workflow.nil?
  288. invalid_properties.push('invalid value for "opt_in_workflow", opt_in_workflow cannot be nil.')
  289. end
  290. if !@additional_information.nil? && @additional_information.to_s.length > 500
  291. invalid_properties.push('invalid value for "additional_information", the character length must be smaller than or equal to 500.')
  292. end
  293. if !@additional_information.nil? && @additional_information.to_s.length < 0
  294. invalid_properties.push('invalid value for "additional_information", the character length must be greater than or equal to 0.')
  295. end
  296. if !@isv_reseller.nil? && @isv_reseller.to_s.length > 500
  297. invalid_properties.push('invalid value for "isv_reseller", the character length must be smaller than or equal to 500.')
  298. end
  299. if !@isv_reseller.nil? && @isv_reseller.to_s.length < 0
  300. invalid_properties.push('invalid value for "isv_reseller", the character length must be greater than or equal to 0.')
  301. end
  302. if !@privacy_policy_url.nil? && @privacy_policy_url.to_s.length > 500
  303. invalid_properties.push('invalid value for "privacy_policy_url", the character length must be smaller than or equal to 500.')
  304. end
  305. if !@terms_and_conditions_url.nil? && @terms_and_conditions_url.to_s.length > 500
  306. invalid_properties.push('invalid value for "terms_and_conditions_url", the character length must be smaller than or equal to 500.')
  307. end
  308. if !@business_dba.nil? && @business_dba.to_s.length > 500
  309. invalid_properties.push('invalid value for "business_dba", the character length must be smaller than or equal to 500.')
  310. end
  311. if !@business_registration_number.nil? && @business_registration_number.to_s.length > 500
  312. invalid_properties.push('invalid value for "business_registration_number", the character length must be smaller than or equal to 500.')
  313. end
  314. if @business_entity_type.nil?
  315. invalid_properties.push('invalid value for "business_entity_type", business_entity_type cannot be nil.')
  316. end
  317. if !@help_message_response.nil? && @help_message_response.to_s.length > 500
  318. invalid_properties.push('invalid value for "help_message_response", the character length must be smaller than or equal to 500.')
  319. end
  320. if !@cv_token.nil? && @cv_token.to_s.length > 500
  321. invalid_properties.push('invalid value for "cv_token", the character length must be smaller than or equal to 500.')
  322. end
  323. if !@cv_token.nil? && @cv_token.to_s.length < 0
  324. invalid_properties.push('invalid value for "cv_token", the character length must be greater than or equal to 0.')
  325. end
  326. invalid_properties
  327. end
  328. # Check to see if the all the properties in the model are valid
  329. # @return true if the model is valid
  330. 1 def valid?
  331. warn '[DEPRECATED] the `valid?` method is obsolete'
  332. return false if @business_address.nil?
  333. return false if @business_contact.nil?
  334. return false if @message_volume.nil?
  335. return false if @message_volume > 10000000
  336. return false if @message_volume < 10
  337. return false if @phone_numbers.nil?
  338. return false if @phone_numbers.length > 10
  339. return false if @phone_numbers.length < 1
  340. return false if @use_case.nil?
  341. return false if @use_case.to_s.length > 500
  342. return false if @use_case.to_s.length < 0
  343. return false if @use_case_summary.nil?
  344. return false if @use_case_summary.to_s.length > 500
  345. return false if @use_case_summary.to_s.length < 0
  346. return false if @production_message_content.nil?
  347. return false if @production_message_content.to_s.length > 500
  348. return false if @production_message_content.to_s.length < 0
  349. return false if @opt_in_workflow.nil?
  350. return false if !@additional_information.nil? && @additional_information.to_s.length > 500
  351. return false if !@additional_information.nil? && @additional_information.to_s.length < 0
  352. return false if !@isv_reseller.nil? && @isv_reseller.to_s.length > 500
  353. return false if !@isv_reseller.nil? && @isv_reseller.to_s.length < 0
  354. return false if !@privacy_policy_url.nil? && @privacy_policy_url.to_s.length > 500
  355. return false if !@terms_and_conditions_url.nil? && @terms_and_conditions_url.to_s.length > 500
  356. return false if !@business_dba.nil? && @business_dba.to_s.length > 500
  357. return false if !@business_registration_number.nil? && @business_registration_number.to_s.length > 500
  358. return false if @business_entity_type.nil?
  359. return false if !@help_message_response.nil? && @help_message_response.to_s.length > 500
  360. return false if !@cv_token.nil? && @cv_token.to_s.length > 500
  361. return false if !@cv_token.nil? && @cv_token.to_s.length < 0
  362. true
  363. end
  364. # Custom attribute writer method with validation
  365. # @param [Object] business_address Value to be assigned
  366. 1 def business_address=(business_address)
  367. 25 if business_address.nil?
  368. 1 fail ArgumentError, 'business_address cannot be nil'
  369. end
  370. 24 @business_address = business_address
  371. end
  372. # Custom attribute writer method with validation
  373. # @param [Object] business_contact Value to be assigned
  374. 1 def business_contact=(business_contact)
  375. 25 if business_contact.nil?
  376. 1 fail ArgumentError, 'business_contact cannot be nil'
  377. end
  378. 24 @business_contact = business_contact
  379. end
  380. # Custom attribute writer method with validation
  381. # @param [Object] message_volume Value to be assigned
  382. 1 def message_volume=(message_volume)
  383. 27 if message_volume.nil?
  384. 1 fail ArgumentError, 'message_volume cannot be nil'
  385. end
  386. 26 if message_volume > 10000000
  387. 1 fail ArgumentError, 'invalid value for "message_volume", must be smaller than or equal to 10000000.'
  388. end
  389. 25 if message_volume < 10
  390. 1 fail ArgumentError, 'invalid value for "message_volume", must be greater than or equal to 10.'
  391. end
  392. 24 @message_volume = message_volume
  393. end
  394. # Custom attribute writer method with validation
  395. # @param [Object] phone_numbers Value to be assigned
  396. 1 def phone_numbers=(phone_numbers)
  397. 27 if phone_numbers.nil?
  398. 1 fail ArgumentError, 'phone_numbers cannot be nil'
  399. end
  400. 26 if phone_numbers.length > 10
  401. 1 fail ArgumentError, 'invalid value for "phone_numbers", number of items must be less than or equal to 10.'
  402. end
  403. 25 if phone_numbers.length < 1
  404. 1 fail ArgumentError, 'invalid value for "phone_numbers", number of items must be greater than or equal to 1.'
  405. end
  406. 24 @phone_numbers = phone_numbers
  407. end
  408. # Custom attribute writer method with validation
  409. # @param [Object] use_case Value to be assigned
  410. 1 def use_case=(use_case)
  411. 26 if use_case.nil?
  412. 1 fail ArgumentError, 'use_case cannot be nil'
  413. end
  414. 25 if use_case.to_s.length > 500
  415. 1 fail ArgumentError, 'invalid value for "use_case", the character length must be smaller than or equal to 500.'
  416. end
  417. 24 if use_case.to_s.length < 0
  418. fail ArgumentError, 'invalid value for "use_case", the character length must be greater than or equal to 0.'
  419. end
  420. 24 @use_case = use_case
  421. end
  422. # Custom attribute writer method with validation
  423. # @param [Object] use_case_summary Value to be assigned
  424. 1 def use_case_summary=(use_case_summary)
  425. 26 if use_case_summary.nil?
  426. 1 fail ArgumentError, 'use_case_summary cannot be nil'
  427. end
  428. 25 if use_case_summary.to_s.length > 500
  429. 1 fail ArgumentError, 'invalid value for "use_case_summary", the character length must be smaller than or equal to 500.'
  430. end
  431. 24 if use_case_summary.to_s.length < 0
  432. fail ArgumentError, 'invalid value for "use_case_summary", the character length must be greater than or equal to 0.'
  433. end
  434. 24 @use_case_summary = use_case_summary
  435. end
  436. # Custom attribute writer method with validation
  437. # @param [Object] production_message_content Value to be assigned
  438. 1 def production_message_content=(production_message_content)
  439. 26 if production_message_content.nil?
  440. 1 fail ArgumentError, 'production_message_content cannot be nil'
  441. end
  442. 25 if production_message_content.to_s.length > 500
  443. 1 fail ArgumentError, 'invalid value for "production_message_content", the character length must be smaller than or equal to 500.'
  444. end
  445. 24 if production_message_content.to_s.length < 0
  446. fail ArgumentError, 'invalid value for "production_message_content", the character length must be greater than or equal to 0.'
  447. end
  448. 24 @production_message_content = production_message_content
  449. end
  450. # Custom attribute writer method with validation
  451. # @param [Object] opt_in_workflow Value to be assigned
  452. 1 def opt_in_workflow=(opt_in_workflow)
  453. 25 if opt_in_workflow.nil?
  454. 1 fail ArgumentError, 'opt_in_workflow cannot be nil'
  455. end
  456. 24 @opt_in_workflow = opt_in_workflow
  457. end
  458. # Custom attribute writer method with validation
  459. # @param [Object] additional_information Value to be assigned
  460. 1 def additional_information=(additional_information)
  461. 23 if !additional_information.nil? && additional_information.to_s.length > 500
  462. 1 fail ArgumentError, 'invalid value for "additional_information", the character length must be smaller than or equal to 500.'
  463. end
  464. 22 if !additional_information.nil? && additional_information.to_s.length < 0
  465. fail ArgumentError, 'invalid value for "additional_information", the character length must be greater than or equal to 0.'
  466. end
  467. 22 @additional_information = additional_information
  468. end
  469. # Custom attribute writer method with validation
  470. # @param [Object] isv_reseller Value to be assigned
  471. 1 def isv_reseller=(isv_reseller)
  472. 23 if !isv_reseller.nil? && isv_reseller.to_s.length > 500
  473. 1 fail ArgumentError, 'invalid value for "isv_reseller", the character length must be smaller than or equal to 500.'
  474. end
  475. 22 if !isv_reseller.nil? && isv_reseller.to_s.length < 0
  476. fail ArgumentError, 'invalid value for "isv_reseller", the character length must be greater than or equal to 0.'
  477. end
  478. 22 @isv_reseller = isv_reseller
  479. end
  480. # Custom attribute writer method with validation
  481. # @param [Object] privacy_policy_url Value to be assigned
  482. 1 def privacy_policy_url=(privacy_policy_url)
  483. 23 if privacy_policy_url.nil?
  484. 1 fail ArgumentError, 'privacy_policy_url cannot be nil'
  485. end
  486. 22 if privacy_policy_url.to_s.length > 500
  487. 1 fail ArgumentError, 'invalid value for "privacy_policy_url", the character length must be smaller than or equal to 500.'
  488. end
  489. 21 @privacy_policy_url = privacy_policy_url
  490. end
  491. # Custom attribute writer method with validation
  492. # @param [Object] terms_and_conditions_url Value to be assigned
  493. 1 def terms_and_conditions_url=(terms_and_conditions_url)
  494. 23 if terms_and_conditions_url.nil?
  495. 1 fail ArgumentError, 'terms_and_conditions_url cannot be nil'
  496. end
  497. 22 if terms_and_conditions_url.to_s.length > 500
  498. 1 fail ArgumentError, 'invalid value for "terms_and_conditions_url", the character length must be smaller than or equal to 500.'
  499. end
  500. 21 @terms_and_conditions_url = terms_and_conditions_url
  501. end
  502. # Custom attribute writer method with validation
  503. # @param [Object] business_dba Value to be assigned
  504. 1 def business_dba=(business_dba)
  505. 23 if business_dba.nil?
  506. 1 fail ArgumentError, 'business_dba cannot be nil'
  507. end
  508. 22 if business_dba.to_s.length > 500
  509. 1 fail ArgumentError, 'invalid value for "business_dba", the character length must be smaller than or equal to 500.'
  510. end
  511. 21 @business_dba = business_dba
  512. end
  513. # Custom attribute writer method with validation
  514. # @param [Object] business_registration_number Value to be assigned
  515. 1 def business_registration_number=(business_registration_number)
  516. 23 if !business_registration_number.nil? && business_registration_number.to_s.length > 500
  517. 1 fail ArgumentError, 'invalid value for "business_registration_number", the character length must be smaller than or equal to 500.'
  518. end
  519. 22 @business_registration_number = business_registration_number
  520. end
  521. # Custom attribute writer method with validation
  522. # @param [Object] business_entity_type Value to be assigned
  523. 1 def business_entity_type=(business_entity_type)
  524. 25 if business_entity_type.nil?
  525. 1 fail ArgumentError, 'business_entity_type cannot be nil'
  526. end
  527. 24 @business_entity_type = business_entity_type
  528. end
  529. # Custom attribute writer method with validation
  530. # @param [Object] help_message_response Value to be assigned
  531. 1 def help_message_response=(help_message_response)
  532. 22 if !help_message_response.nil? && help_message_response.to_s.length > 500
  533. 1 fail ArgumentError, 'invalid value for "help_message_response", the character length must be smaller than or equal to 500.'
  534. end
  535. 21 @help_message_response = help_message_response
  536. end
  537. # Custom attribute writer method with validation
  538. # @param [Object] cv_token Value to be assigned
  539. 1 def cv_token=(cv_token)
  540. 22 if !cv_token.nil? && cv_token.to_s.length > 500
  541. 1 fail ArgumentError, 'invalid value for "cv_token", the character length must be smaller than or equal to 500.'
  542. end
  543. 21 if !cv_token.nil? && cv_token.to_s.length < 0
  544. fail ArgumentError, 'invalid value for "cv_token", the character length must be greater than or equal to 0.'
  545. end
  546. 21 @cv_token = cv_token
  547. end
  548. # Checks equality by comparing each attribute.
  549. # @param [Object] Object to be compared
  550. 1 def ==(o)
  551. 2 return true if self.equal?(o)
  552. 2 self.class == o.class &&
  553. business_address == o.business_address &&
  554. business_contact == o.business_contact &&
  555. message_volume == o.message_volume &&
  556. phone_numbers == o.phone_numbers &&
  557. use_case == o.use_case &&
  558. use_case_summary == o.use_case_summary &&
  559. production_message_content == o.production_message_content &&
  560. opt_in_workflow == o.opt_in_workflow &&
  561. additional_information == o.additional_information &&
  562. isv_reseller == o.isv_reseller &&
  563. privacy_policy_url == o.privacy_policy_url &&
  564. terms_and_conditions_url == o.terms_and_conditions_url &&
  565. business_dba == o.business_dba &&
  566. business_registration_number == o.business_registration_number &&
  567. business_registration_type == o.business_registration_type &&
  568. business_registration_issuing_country == o.business_registration_issuing_country &&
  569. business_entity_type == o.business_entity_type &&
  570. help_message_response == o.help_message_response &&
  571. age_gated_content == o.age_gated_content &&
  572. cv_token == o.cv_token
  573. end
  574. # @see the `==` method
  575. # @param [Object] Object to be compared
  576. 1 def eql?(o)
  577. 2 self == o
  578. end
  579. # Calculates hash code according to all attributes.
  580. # @return [Integer] Hash code
  581. 1 def hash
  582. [business_address, business_contact, message_volume, phone_numbers, use_case, use_case_summary, production_message_content, opt_in_workflow, additional_information, isv_reseller, privacy_policy_url, terms_and_conditions_url, business_dba, business_registration_number, business_registration_type, business_registration_issuing_country, business_entity_type, help_message_response, age_gated_content, cv_token].hash
  583. end
  584. # Builds the object from hash
  585. # @param [Hash] attributes Model attributes in the form of hash
  586. # @return [Object] Returns the model itself
  587. 1 def self.build_from_hash(attributes)
  588. 1 return nil unless attributes.is_a?(Hash)
  589. 1 attributes = attributes.transform_keys(&:to_sym)
  590. 1 transformed_hash = {}
  591. 1 openapi_types.each_pair do |key, type|
  592. 20 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  593. transformed_hash["#{key}"] = nil
  594. 20 elsif type =~ /\AArray<(.*)>/i
  595. # check to ensure the input is an array given that the attribute
  596. # is documented as an array but the input is not
  597. 1 if attributes[attribute_map[key]].is_a?(Array)
  598. 2 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  599. end
  600. 19 elsif !attributes[attribute_map[key]].nil?
  601. 19 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  602. end
  603. end
  604. 1 new(transformed_hash)
  605. end
  606. # Returns the object in the form of hash
  607. # @return [Hash] Returns the object in the form of hash
  608. 1 def to_hash
  609. 3 hash = {}
  610. 3 self.class.attribute_map.each_pair do |attr, param|
  611. 60 value = self.send(attr)
  612. 60 if value.nil?
  613. 6 is_nullable = self.class.openapi_nullable.include?(attr)
  614. 6 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  615. end
  616. 54 hash[param] = _to_hash(value)
  617. end
  618. 3 hash
  619. end
  620. end
  621. end

lib/bandwidth-sdk/models/verification_update_request.rb

64.55% lines covered

299 relevant lines. 193 lines covered and 106 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class VerificationUpdateRequest < ApiModelBase
  13. 1 attr_accessor :business_address
  14. 1 attr_accessor :business_contact
  15. # Estimated monthly volume of messages from the toll-free number.
  16. 1 attr_accessor :message_volume
  17. # The category of the use case.
  18. 1 attr_accessor :use_case
  19. # A general idea of the use case and customer.
  20. 1 attr_accessor :use_case_summary
  21. # Example of message content.
  22. 1 attr_accessor :production_message_content
  23. 1 attr_accessor :opt_in_workflow
  24. # Any additional information.
  25. 1 attr_accessor :additional_information
  26. # ISV name.
  27. 1 attr_accessor :isv_reseller
  28. # The Toll-Free Verification request privacy policy URL.
  29. 1 attr_accessor :privacy_policy_url
  30. # The Toll-Free Verification request terms and conditions policy URL.
  31. 1 attr_accessor :terms_and_conditions_url
  32. # The company 'Doing Business As'.
  33. 1 attr_accessor :business_dba
  34. # Government-issued business identifying number. **Note: As of October 19th, 2026 this field will be required when `businessEntityType` is _not_ `SOLE_PROPRIETOR`. If this field is provided, `businessRegistrationType` and `businessRegistrationIssuingCountry` are also required.**
  35. 1 attr_accessor :business_registration_number
  36. 1 attr_accessor :business_registration_type
  37. 1 attr_accessor :business_entity_type
  38. # The country issuing the business registration in ISO-3166-1 alpha-3 format. Alpha-2 format is accepted by the API, but alpha-3 is highly encouraged. **Note: As of October 19th, 2026 this field will be required when `businessRegistrationNumber` is provided.** | Registration Type | Supported Countries | |----------------------|------------------------------------| | EIN | USA | | CBN | CAN | | NEQ | CAN | | PROVINCIAL_NUMBER | CAN | | CRN | GBR, HKG | | VAT | GBR, IRL, BRA, NLD | | ACN | AUS | | ABN | AUS | | BRN | HKG | | SIREN | FRA | | SIRET | FRA | | NZBN | NZL | | UST_IDNR | DEU | | CIF | ESP | | NIF | ESP | | CNPJ | BRA | | UID | CHE | | OTHER | Must Provide Country Code |
  39. 1 attr_accessor :business_registration_issuing_country
  40. # A message that gets sent to users requesting help.
  41. 1 attr_accessor :help_message_response
  42. # Indicates whether the content is age-gated.
  43. 1 attr_accessor :age_gated_content
  44. # The token provided by Campaign Verify to validate your political use case. Only required for 527 political organizations. If you are not a 527 political organization, this field should be omitted. Supplying an empty string will likely result in rejection.
  45. 1 attr_accessor :cv_token
  46. 1 class EnumAttributeValidator
  47. 1 attr_reader :datatype
  48. 1 attr_reader :allowable_values
  49. 1 def initialize(datatype, allowable_values)
  50. @allowable_values = allowable_values.map do |value|
  51. case datatype.to_s
  52. when /Integer/i
  53. value.to_i
  54. when /Float/i
  55. value.to_f
  56. else
  57. value
  58. end
  59. end
  60. end
  61. 1 def valid?(value)
  62. !value || allowable_values.include?(value)
  63. end
  64. end
  65. # Attribute mapping from ruby-style variable name to JSON key.
  66. 1 def self.attribute_map
  67. 163 {
  68. :'business_address' => :'businessAddress',
  69. :'business_contact' => :'businessContact',
  70. :'message_volume' => :'messageVolume',
  71. :'use_case' => :'useCase',
  72. :'use_case_summary' => :'useCaseSummary',
  73. :'production_message_content' => :'productionMessageContent',
  74. :'opt_in_workflow' => :'optInWorkflow',
  75. :'additional_information' => :'additionalInformation',
  76. :'isv_reseller' => :'isvReseller',
  77. :'privacy_policy_url' => :'privacyPolicyUrl',
  78. :'terms_and_conditions_url' => :'termsAndConditionsUrl',
  79. :'business_dba' => :'businessDba',
  80. :'business_registration_number' => :'businessRegistrationNumber',
  81. :'business_registration_type' => :'businessRegistrationType',
  82. :'business_entity_type' => :'businessEntityType',
  83. :'business_registration_issuing_country' => :'businessRegistrationIssuingCountry',
  84. :'help_message_response' => :'helpMessageResponse',
  85. :'age_gated_content' => :'ageGatedContent',
  86. :'cv_token' => :'cvToken'
  87. }
  88. end
  89. # Returns attribute mapping this model knows about
  90. 1 def self.acceptable_attribute_map
  91. 25 attribute_map
  92. end
  93. # Returns all the JSON keys this model knows about
  94. 1 def self.acceptable_attributes
  95. 1 acceptable_attribute_map.values
  96. end
  97. # Attribute type mapping.
  98. 1 def self.openapi_types
  99. 2 {
  100. :'business_address' => :'Address',
  101. :'business_contact' => :'Contact',
  102. :'message_volume' => :'Integer',
  103. :'use_case' => :'String',
  104. :'use_case_summary' => :'String',
  105. :'production_message_content' => :'String',
  106. :'opt_in_workflow' => :'OptInWorkflow',
  107. :'additional_information' => :'String',
  108. :'isv_reseller' => :'String',
  109. :'privacy_policy_url' => :'String',
  110. :'terms_and_conditions_url' => :'String',
  111. :'business_dba' => :'String',
  112. :'business_registration_number' => :'String',
  113. :'business_registration_type' => :'BusinessRegistrationTypeEnum',
  114. :'business_entity_type' => :'BusinessEntityTypeEnum',
  115. :'business_registration_issuing_country' => :'String',
  116. :'help_message_response' => :'String',
  117. :'age_gated_content' => :'Boolean',
  118. :'cv_token' => :'String'
  119. }
  120. end
  121. # List of attributes with nullable: true
  122. 1 def self.openapi_nullable
  123. 7 Set.new([
  124. :'additional_information',
  125. :'isv_reseller',
  126. :'business_registration_number',
  127. :'business_registration_type',
  128. :'business_registration_issuing_country',
  129. :'help_message_response',
  130. :'cv_token'
  131. ])
  132. end
  133. # Initializes the object
  134. # @param [Hash] attributes Model attributes in the form of hash
  135. 1 def initialize(attributes = {})
  136. 25 if (!attributes.is_a?(Hash))
  137. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::VerificationUpdateRequest` initialize method'
  138. end
  139. # check to see if the attribute exists and convert string to symbol for hash key
  140. 24 acceptable_attribute_map = self.class.acceptable_attribute_map
  141. 24 attributes = attributes.each_with_object({}) { |(k, v), h|
  142. 399 if (!acceptable_attribute_map.key?(k.to_sym))
  143. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::VerificationUpdateRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  144. end
  145. 398 h[k.to_sym] = v
  146. }
  147. 23 if attributes.key?(:'business_address')
  148. 23 self.business_address = attributes[:'business_address']
  149. else
  150. self.business_address = nil
  151. end
  152. 23 if attributes.key?(:'business_contact')
  153. 23 self.business_contact = attributes[:'business_contact']
  154. else
  155. self.business_contact = nil
  156. end
  157. 23 if attributes.key?(:'message_volume')
  158. 23 self.message_volume = attributes[:'message_volume']
  159. else
  160. self.message_volume = nil
  161. end
  162. 23 if attributes.key?(:'use_case')
  163. 23 self.use_case = attributes[:'use_case']
  164. else
  165. self.use_case = nil
  166. end
  167. 23 if attributes.key?(:'use_case_summary')
  168. 23 self.use_case_summary = attributes[:'use_case_summary']
  169. else
  170. self.use_case_summary = nil
  171. end
  172. 23 if attributes.key?(:'production_message_content')
  173. 23 self.production_message_content = attributes[:'production_message_content']
  174. else
  175. self.production_message_content = nil
  176. end
  177. 23 if attributes.key?(:'opt_in_workflow')
  178. 23 self.opt_in_workflow = attributes[:'opt_in_workflow']
  179. else
  180. self.opt_in_workflow = nil
  181. end
  182. 23 if attributes.key?(:'additional_information')
  183. 20 self.additional_information = attributes[:'additional_information']
  184. end
  185. 23 if attributes.key?(:'isv_reseller')
  186. 20 self.isv_reseller = attributes[:'isv_reseller']
  187. end
  188. 23 if attributes.key?(:'privacy_policy_url')
  189. 20 self.privacy_policy_url = attributes[:'privacy_policy_url']
  190. end
  191. 23 if attributes.key?(:'terms_and_conditions_url')
  192. 20 self.terms_and_conditions_url = attributes[:'terms_and_conditions_url']
  193. end
  194. 23 if attributes.key?(:'business_dba')
  195. 20 self.business_dba = attributes[:'business_dba']
  196. end
  197. 23 if attributes.key?(:'business_registration_number')
  198. 20 self.business_registration_number = attributes[:'business_registration_number']
  199. end
  200. 23 if attributes.key?(:'business_registration_type')
  201. 20 self.business_registration_type = attributes[:'business_registration_type']
  202. end
  203. 23 if attributes.key?(:'business_entity_type')
  204. 20 self.business_entity_type = attributes[:'business_entity_type']
  205. end
  206. 23 if attributes.key?(:'business_registration_issuing_country')
  207. 20 self.business_registration_issuing_country = attributes[:'business_registration_issuing_country']
  208. end
  209. 23 if attributes.key?(:'help_message_response')
  210. 19 self.help_message_response = attributes[:'help_message_response']
  211. end
  212. 23 if attributes.key?(:'age_gated_content')
  213. 19 self.age_gated_content = attributes[:'age_gated_content']
  214. end
  215. 23 if attributes.key?(:'cv_token')
  216. 19 self.cv_token = attributes[:'cv_token']
  217. end
  218. end
  219. # Show invalid properties with the reasons. Usually used together with valid?
  220. # @return Array for valid properties with the reasons
  221. 1 def list_invalid_properties
  222. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  223. invalid_properties = Array.new
  224. if @business_address.nil?
  225. invalid_properties.push('invalid value for "business_address", business_address cannot be nil.')
  226. end
  227. if @business_contact.nil?
  228. invalid_properties.push('invalid value for "business_contact", business_contact cannot be nil.')
  229. end
  230. if @message_volume.nil?
  231. invalid_properties.push('invalid value for "message_volume", message_volume cannot be nil.')
  232. end
  233. if @message_volume > 10000000
  234. invalid_properties.push('invalid value for "message_volume", must be smaller than or equal to 10000000.')
  235. end
  236. if @message_volume < 10
  237. invalid_properties.push('invalid value for "message_volume", must be greater than or equal to 10.')
  238. end
  239. if @use_case.nil?
  240. invalid_properties.push('invalid value for "use_case", use_case cannot be nil.')
  241. end
  242. if @use_case.to_s.length > 500
  243. invalid_properties.push('invalid value for "use_case", the character length must be smaller than or equal to 500.')
  244. end
  245. if @use_case.to_s.length < 0
  246. invalid_properties.push('invalid value for "use_case", the character length must be greater than or equal to 0.')
  247. end
  248. if @use_case_summary.nil?
  249. invalid_properties.push('invalid value for "use_case_summary", use_case_summary cannot be nil.')
  250. end
  251. if @use_case_summary.to_s.length > 500
  252. invalid_properties.push('invalid value for "use_case_summary", the character length must be smaller than or equal to 500.')
  253. end
  254. if @use_case_summary.to_s.length < 0
  255. invalid_properties.push('invalid value for "use_case_summary", the character length must be greater than or equal to 0.')
  256. end
  257. if @production_message_content.nil?
  258. invalid_properties.push('invalid value for "production_message_content", production_message_content cannot be nil.')
  259. end
  260. if @production_message_content.to_s.length > 500
  261. invalid_properties.push('invalid value for "production_message_content", the character length must be smaller than or equal to 500.')
  262. end
  263. if @production_message_content.to_s.length < 0
  264. invalid_properties.push('invalid value for "production_message_content", the character length must be greater than or equal to 0.')
  265. end
  266. if @opt_in_workflow.nil?
  267. invalid_properties.push('invalid value for "opt_in_workflow", opt_in_workflow cannot be nil.')
  268. end
  269. if !@additional_information.nil? && @additional_information.to_s.length > 500
  270. invalid_properties.push('invalid value for "additional_information", the character length must be smaller than or equal to 500.')
  271. end
  272. if !@additional_information.nil? && @additional_information.to_s.length < 0
  273. invalid_properties.push('invalid value for "additional_information", the character length must be greater than or equal to 0.')
  274. end
  275. if !@isv_reseller.nil? && @isv_reseller.to_s.length > 500
  276. invalid_properties.push('invalid value for "isv_reseller", the character length must be smaller than or equal to 500.')
  277. end
  278. if !@isv_reseller.nil? && @isv_reseller.to_s.length < 0
  279. invalid_properties.push('invalid value for "isv_reseller", the character length must be greater than or equal to 0.')
  280. end
  281. if !@privacy_policy_url.nil? && @privacy_policy_url.to_s.length > 500
  282. invalid_properties.push('invalid value for "privacy_policy_url", the character length must be smaller than or equal to 500.')
  283. end
  284. if !@terms_and_conditions_url.nil? && @terms_and_conditions_url.to_s.length > 500
  285. invalid_properties.push('invalid value for "terms_and_conditions_url", the character length must be smaller than or equal to 500.')
  286. end
  287. if !@business_dba.nil? && @business_dba.to_s.length > 500
  288. invalid_properties.push('invalid value for "business_dba", the character length must be smaller than or equal to 500.')
  289. end
  290. if !@business_registration_number.nil? && @business_registration_number.to_s.length > 500
  291. invalid_properties.push('invalid value for "business_registration_number", the character length must be smaller than or equal to 500.')
  292. end
  293. if !@help_message_response.nil? && @help_message_response.to_s.length > 500
  294. invalid_properties.push('invalid value for "help_message_response", the character length must be smaller than or equal to 500.')
  295. end
  296. if !@cv_token.nil? && @cv_token.to_s.length > 500
  297. invalid_properties.push('invalid value for "cv_token", the character length must be smaller than or equal to 500.')
  298. end
  299. if !@cv_token.nil? && @cv_token.to_s.length < 0
  300. invalid_properties.push('invalid value for "cv_token", the character length must be greater than or equal to 0.')
  301. end
  302. invalid_properties
  303. end
  304. # Check to see if the all the properties in the model are valid
  305. # @return true if the model is valid
  306. 1 def valid?
  307. warn '[DEPRECATED] the `valid?` method is obsolete'
  308. return false if @business_address.nil?
  309. return false if @business_contact.nil?
  310. return false if @message_volume.nil?
  311. return false if @message_volume > 10000000
  312. return false if @message_volume < 10
  313. return false if @use_case.nil?
  314. return false if @use_case.to_s.length > 500
  315. return false if @use_case.to_s.length < 0
  316. return false if @use_case_summary.nil?
  317. return false if @use_case_summary.to_s.length > 500
  318. return false if @use_case_summary.to_s.length < 0
  319. return false if @production_message_content.nil?
  320. return false if @production_message_content.to_s.length > 500
  321. return false if @production_message_content.to_s.length < 0
  322. return false if @opt_in_workflow.nil?
  323. return false if !@additional_information.nil? && @additional_information.to_s.length > 500
  324. return false if !@additional_information.nil? && @additional_information.to_s.length < 0
  325. return false if !@isv_reseller.nil? && @isv_reseller.to_s.length > 500
  326. return false if !@isv_reseller.nil? && @isv_reseller.to_s.length < 0
  327. return false if !@privacy_policy_url.nil? && @privacy_policy_url.to_s.length > 500
  328. return false if !@terms_and_conditions_url.nil? && @terms_and_conditions_url.to_s.length > 500
  329. return false if !@business_dba.nil? && @business_dba.to_s.length > 500
  330. return false if !@business_registration_number.nil? && @business_registration_number.to_s.length > 500
  331. return false if !@help_message_response.nil? && @help_message_response.to_s.length > 500
  332. return false if !@cv_token.nil? && @cv_token.to_s.length > 500
  333. return false if !@cv_token.nil? && @cv_token.to_s.length < 0
  334. true
  335. end
  336. # Custom attribute writer method with validation
  337. # @param [Object] business_address Value to be assigned
  338. 1 def business_address=(business_address)
  339. 24 if business_address.nil?
  340. 1 fail ArgumentError, 'business_address cannot be nil'
  341. end
  342. 23 @business_address = business_address
  343. end
  344. # Custom attribute writer method with validation
  345. # @param [Object] business_contact Value to be assigned
  346. 1 def business_contact=(business_contact)
  347. 24 if business_contact.nil?
  348. 1 fail ArgumentError, 'business_contact cannot be nil'
  349. end
  350. 23 @business_contact = business_contact
  351. end
  352. # Custom attribute writer method with validation
  353. # @param [Object] message_volume Value to be assigned
  354. 1 def message_volume=(message_volume)
  355. 26 if message_volume.nil?
  356. 1 fail ArgumentError, 'message_volume cannot be nil'
  357. end
  358. 25 if message_volume > 10000000
  359. 1 fail ArgumentError, 'invalid value for "message_volume", must be smaller than or equal to 10000000.'
  360. end
  361. 24 if message_volume < 10
  362. 1 fail ArgumentError, 'invalid value for "message_volume", must be greater than or equal to 10.'
  363. end
  364. 23 @message_volume = message_volume
  365. end
  366. # Custom attribute writer method with validation
  367. # @param [Object] use_case Value to be assigned
  368. 1 def use_case=(use_case)
  369. 25 if use_case.nil?
  370. 1 fail ArgumentError, 'use_case cannot be nil'
  371. end
  372. 24 if use_case.to_s.length > 500
  373. 1 fail ArgumentError, 'invalid value for "use_case", the character length must be smaller than or equal to 500.'
  374. end
  375. 23 if use_case.to_s.length < 0
  376. fail ArgumentError, 'invalid value for "use_case", the character length must be greater than or equal to 0.'
  377. end
  378. 23 @use_case = use_case
  379. end
  380. # Custom attribute writer method with validation
  381. # @param [Object] use_case_summary Value to be assigned
  382. 1 def use_case_summary=(use_case_summary)
  383. 25 if use_case_summary.nil?
  384. 1 fail ArgumentError, 'use_case_summary cannot be nil'
  385. end
  386. 24 if use_case_summary.to_s.length > 500
  387. 1 fail ArgumentError, 'invalid value for "use_case_summary", the character length must be smaller than or equal to 500.'
  388. end
  389. 23 if use_case_summary.to_s.length < 0
  390. fail ArgumentError, 'invalid value for "use_case_summary", the character length must be greater than or equal to 0.'
  391. end
  392. 23 @use_case_summary = use_case_summary
  393. end
  394. # Custom attribute writer method with validation
  395. # @param [Object] production_message_content Value to be assigned
  396. 1 def production_message_content=(production_message_content)
  397. 25 if production_message_content.nil?
  398. 1 fail ArgumentError, 'production_message_content cannot be nil'
  399. end
  400. 24 if production_message_content.to_s.length > 500
  401. 1 fail ArgumentError, 'invalid value for "production_message_content", the character length must be smaller than or equal to 500.'
  402. end
  403. 23 if production_message_content.to_s.length < 0
  404. fail ArgumentError, 'invalid value for "production_message_content", the character length must be greater than or equal to 0.'
  405. end
  406. 23 @production_message_content = production_message_content
  407. end
  408. # Custom attribute writer method with validation
  409. # @param [Object] opt_in_workflow Value to be assigned
  410. 1 def opt_in_workflow=(opt_in_workflow)
  411. 24 if opt_in_workflow.nil?
  412. 1 fail ArgumentError, 'opt_in_workflow cannot be nil'
  413. end
  414. 23 @opt_in_workflow = opt_in_workflow
  415. end
  416. # Custom attribute writer method with validation
  417. # @param [Object] additional_information Value to be assigned
  418. 1 def additional_information=(additional_information)
  419. 21 if !additional_information.nil? && additional_information.to_s.length > 500
  420. 1 fail ArgumentError, 'invalid value for "additional_information", the character length must be smaller than or equal to 500.'
  421. end
  422. 20 if !additional_information.nil? && additional_information.to_s.length < 0
  423. fail ArgumentError, 'invalid value for "additional_information", the character length must be greater than or equal to 0.'
  424. end
  425. 20 @additional_information = additional_information
  426. end
  427. # Custom attribute writer method with validation
  428. # @param [Object] isv_reseller Value to be assigned
  429. 1 def isv_reseller=(isv_reseller)
  430. 21 if !isv_reseller.nil? && isv_reseller.to_s.length > 500
  431. 1 fail ArgumentError, 'invalid value for "isv_reseller", the character length must be smaller than or equal to 500.'
  432. end
  433. 20 if !isv_reseller.nil? && isv_reseller.to_s.length < 0
  434. fail ArgumentError, 'invalid value for "isv_reseller", the character length must be greater than or equal to 0.'
  435. end
  436. 20 @isv_reseller = isv_reseller
  437. end
  438. # Custom attribute writer method with validation
  439. # @param [Object] privacy_policy_url Value to be assigned
  440. 1 def privacy_policy_url=(privacy_policy_url)
  441. 22 if privacy_policy_url.nil?
  442. 1 fail ArgumentError, 'privacy_policy_url cannot be nil'
  443. end
  444. 21 if privacy_policy_url.to_s.length > 500
  445. 1 fail ArgumentError, 'invalid value for "privacy_policy_url", the character length must be smaller than or equal to 500.'
  446. end
  447. 20 @privacy_policy_url = privacy_policy_url
  448. end
  449. # Custom attribute writer method with validation
  450. # @param [Object] terms_and_conditions_url Value to be assigned
  451. 1 def terms_and_conditions_url=(terms_and_conditions_url)
  452. 22 if terms_and_conditions_url.nil?
  453. 1 fail ArgumentError, 'terms_and_conditions_url cannot be nil'
  454. end
  455. 21 if terms_and_conditions_url.to_s.length > 500
  456. 1 fail ArgumentError, 'invalid value for "terms_and_conditions_url", the character length must be smaller than or equal to 500.'
  457. end
  458. 20 @terms_and_conditions_url = terms_and_conditions_url
  459. end
  460. # Custom attribute writer method with validation
  461. # @param [Object] business_dba Value to be assigned
  462. 1 def business_dba=(business_dba)
  463. 22 if business_dba.nil?
  464. 1 fail ArgumentError, 'business_dba cannot be nil'
  465. end
  466. 21 if business_dba.to_s.length > 500
  467. 1 fail ArgumentError, 'invalid value for "business_dba", the character length must be smaller than or equal to 500.'
  468. end
  469. 20 @business_dba = business_dba
  470. end
  471. # Custom attribute writer method with validation
  472. # @param [Object] business_registration_number Value to be assigned
  473. 1 def business_registration_number=(business_registration_number)
  474. 21 if !business_registration_number.nil? && business_registration_number.to_s.length > 500
  475. 1 fail ArgumentError, 'invalid value for "business_registration_number", the character length must be smaller than or equal to 500.'
  476. end
  477. 20 @business_registration_number = business_registration_number
  478. end
  479. # Custom attribute writer method with validation
  480. # @param [Object] help_message_response Value to be assigned
  481. 1 def help_message_response=(help_message_response)
  482. 20 if !help_message_response.nil? && help_message_response.to_s.length > 500
  483. 1 fail ArgumentError, 'invalid value for "help_message_response", the character length must be smaller than or equal to 500.'
  484. end
  485. 19 @help_message_response = help_message_response
  486. end
  487. # Custom attribute writer method with validation
  488. # @param [Object] cv_token Value to be assigned
  489. 1 def cv_token=(cv_token)
  490. 20 if !cv_token.nil? && cv_token.to_s.length > 500
  491. 1 fail ArgumentError, 'invalid value for "cv_token", the character length must be smaller than or equal to 500.'
  492. end
  493. 19 if !cv_token.nil? && cv_token.to_s.length < 0
  494. fail ArgumentError, 'invalid value for "cv_token", the character length must be greater than or equal to 0.'
  495. end
  496. 19 @cv_token = cv_token
  497. end
  498. # Checks equality by comparing each attribute.
  499. # @param [Object] Object to be compared
  500. 1 def ==(o)
  501. 2 return true if self.equal?(o)
  502. 2 self.class == o.class &&
  503. business_address == o.business_address &&
  504. business_contact == o.business_contact &&
  505. message_volume == o.message_volume &&
  506. use_case == o.use_case &&
  507. use_case_summary == o.use_case_summary &&
  508. production_message_content == o.production_message_content &&
  509. opt_in_workflow == o.opt_in_workflow &&
  510. additional_information == o.additional_information &&
  511. isv_reseller == o.isv_reseller &&
  512. privacy_policy_url == o.privacy_policy_url &&
  513. terms_and_conditions_url == o.terms_and_conditions_url &&
  514. business_dba == o.business_dba &&
  515. business_registration_number == o.business_registration_number &&
  516. business_registration_type == o.business_registration_type &&
  517. business_entity_type == o.business_entity_type &&
  518. business_registration_issuing_country == o.business_registration_issuing_country &&
  519. help_message_response == o.help_message_response &&
  520. age_gated_content == o.age_gated_content &&
  521. cv_token == o.cv_token
  522. end
  523. # @see the `==` method
  524. # @param [Object] Object to be compared
  525. 1 def eql?(o)
  526. 2 self == o
  527. end
  528. # Calculates hash code according to all attributes.
  529. # @return [Integer] Hash code
  530. 1 def hash
  531. [business_address, business_contact, message_volume, use_case, use_case_summary, production_message_content, opt_in_workflow, additional_information, isv_reseller, privacy_policy_url, terms_and_conditions_url, business_dba, business_registration_number, business_registration_type, business_entity_type, business_registration_issuing_country, help_message_response, age_gated_content, cv_token].hash
  532. end
  533. # Builds the object from hash
  534. # @param [Hash] attributes Model attributes in the form of hash
  535. # @return [Object] Returns the model itself
  536. 1 def self.build_from_hash(attributes)
  537. 2 return nil unless attributes.is_a?(Hash)
  538. 2 attributes = attributes.transform_keys(&:to_sym)
  539. 2 transformed_hash = {}
  540. 2 openapi_types.each_pair do |key, type|
  541. 38 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  542. transformed_hash["#{key}"] = nil
  543. 38 elsif type =~ /\AArray<(.*)>/i
  544. # check to ensure the input is an array given that the attribute
  545. # is documented as an array but the input is not
  546. if attributes[attribute_map[key]].is_a?(Array)
  547. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  548. end
  549. 38 elsif !attributes[attribute_map[key]].nil?
  550. 29 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  551. end
  552. end
  553. 2 new(transformed_hash)
  554. end
  555. # Returns the object in the form of hash
  556. # @return [Hash] Returns the object in the form of hash
  557. 1 def to_hash
  558. 3 hash = {}
  559. 3 self.class.attribute_map.each_pair do |attr, param|
  560. 57 value = self.send(attr)
  561. 57 if value.nil?
  562. 6 is_nullable = self.class.openapi_nullable.include?(attr)
  563. 6 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  564. end
  565. 51 hash[param] = _to_hash(value)
  566. end
  567. 3 hash
  568. end
  569. end
  570. end

lib/bandwidth-sdk/models/verification_webhook.rb

73.53% lines covered

102 relevant lines. 75 lines covered and 27 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class VerificationWebhook < ApiModelBase
  13. # User's account ID.
  14. 1 attr_accessor :account_id
  15. # Toll-free telephone number in E.164 format.
  16. 1 attr_accessor :phone_number
  17. 1 attr_accessor :status
  18. # Unique identifier (UUID) generated by Bandwidth to assist in tracking the verification status of a toll-free number.
  19. 1 attr_accessor :internal_ticket_number
  20. 1 class EnumAttributeValidator
  21. 1 attr_reader :datatype
  22. 1 attr_reader :allowable_values
  23. 1 def initialize(datatype, allowable_values)
  24. @allowable_values = allowable_values.map do |value|
  25. case datatype.to_s
  26. when /Integer/i
  27. value.to_i
  28. when /Float/i
  29. value.to_f
  30. else
  31. value
  32. end
  33. end
  34. end
  35. 1 def valid?(value)
  36. !value || allowable_values.include?(value)
  37. end
  38. end
  39. # Attribute mapping from ruby-style variable name to JSON key.
  40. 1 def self.attribute_map
  41. 31 {
  42. :'account_id' => :'accountId',
  43. :'phone_number' => :'phoneNumber',
  44. :'status' => :'status',
  45. :'internal_ticket_number' => :'internalTicketNumber'
  46. }
  47. end
  48. # Returns attribute mapping this model knows about
  49. 1 def self.acceptable_attribute_map
  50. 12 attribute_map
  51. end
  52. # Returns all the JSON keys this model knows about
  53. 1 def self.acceptable_attributes
  54. 1 acceptable_attribute_map.values
  55. end
  56. # Attribute type mapping.
  57. 1 def self.openapi_types
  58. 1 {
  59. :'account_id' => :'String',
  60. :'phone_number' => :'String',
  61. :'status' => :'TfvCallbackStatusEnum',
  62. :'internal_ticket_number' => :'String'
  63. }
  64. end
  65. # List of attributes with nullable: true
  66. 1 def self.openapi_nullable
  67. 1 Set.new([
  68. ])
  69. end
  70. # Initializes the object
  71. # @param [Hash] attributes Model attributes in the form of hash
  72. 1 def initialize(attributes = {})
  73. 12 if (!attributes.is_a?(Hash))
  74. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::VerificationWebhook` initialize method'
  75. end
  76. # check to see if the attribute exists and convert string to symbol for hash key
  77. 11 acceptable_attribute_map = self.class.acceptable_attribute_map
  78. 11 attributes = attributes.each_with_object({}) { |(k, v), h|
  79. 21 if (!acceptable_attribute_map.key?(k.to_sym))
  80. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::VerificationWebhook`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  81. end
  82. 20 h[k.to_sym] = v
  83. }
  84. 10 if attributes.key?(:'account_id')
  85. 4 self.account_id = attributes[:'account_id']
  86. end
  87. 10 if attributes.key?(:'phone_number')
  88. 8 self.phone_number = attributes[:'phone_number']
  89. end
  90. 6 if attributes.key?(:'status')
  91. 4 self.status = attributes[:'status']
  92. end
  93. 6 if attributes.key?(:'internal_ticket_number')
  94. 4 self.internal_ticket_number = attributes[:'internal_ticket_number']
  95. end
  96. end
  97. # Show invalid properties with the reasons. Usually used together with valid?
  98. # @return Array for valid properties with the reasons
  99. 1 def list_invalid_properties
  100. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  101. invalid_properties = Array.new
  102. if !@phone_number.nil? && @phone_number.to_s.length > 12
  103. invalid_properties.push('invalid value for "phone_number", the character length must be smaller than or equal to 12.')
  104. end
  105. if !@phone_number.nil? && @phone_number.to_s.length < 12
  106. invalid_properties.push('invalid value for "phone_number", the character length must be greater than or equal to 12.')
  107. end
  108. pattern = Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
  109. if !@phone_number.nil? && @phone_number !~ pattern
  110. invalid_properties.push("invalid value for \"phone_number\", must conform to the pattern #{pattern}.")
  111. end
  112. invalid_properties
  113. end
  114. # Check to see if the all the properties in the model are valid
  115. # @return true if the model is valid
  116. 1 def valid?
  117. warn '[DEPRECATED] the `valid?` method is obsolete'
  118. return false if !@phone_number.nil? && @phone_number.to_s.length > 12
  119. return false if !@phone_number.nil? && @phone_number.to_s.length < 12
  120. return false if !@phone_number.nil? && @phone_number !~ Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
  121. true
  122. end
  123. # Custom attribute writer method with validation
  124. # @param [Object] phone_number Value to be assigned
  125. 1 def phone_number=(phone_number)
  126. 8 if phone_number.nil?
  127. 1 fail ArgumentError, 'phone_number cannot be nil'
  128. end
  129. 7 if phone_number.to_s.length > 12
  130. 1 fail ArgumentError, 'invalid value for "phone_number", the character length must be smaller than or equal to 12.'
  131. end
  132. 6 if phone_number.to_s.length < 12
  133. 1 fail ArgumentError, 'invalid value for "phone_number", the character length must be greater than or equal to 12.'
  134. end
  135. 5 pattern = Regexp.new(/^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$/)
  136. 5 if phone_number !~ pattern
  137. 1 fail ArgumentError, "invalid value for \"phone_number\", must conform to the pattern #{pattern}."
  138. end
  139. 4 @phone_number = phone_number
  140. end
  141. # Checks equality by comparing each attribute.
  142. # @param [Object] Object to be compared
  143. 1 def ==(o)
  144. 2 return true if self.equal?(o)
  145. 2 self.class == o.class &&
  146. account_id == o.account_id &&
  147. phone_number == o.phone_number &&
  148. status == o.status &&
  149. internal_ticket_number == o.internal_ticket_number
  150. end
  151. # @see the `==` method
  152. # @param [Object] Object to be compared
  153. 1 def eql?(o)
  154. 2 self == o
  155. end
  156. # Calculates hash code according to all attributes.
  157. # @return [Integer] Hash code
  158. 1 def hash
  159. [account_id, phone_number, status, internal_ticket_number].hash
  160. end
  161. # Builds the object from hash
  162. # @param [Hash] attributes Model attributes in the form of hash
  163. # @return [Object] Returns the model itself
  164. 1 def self.build_from_hash(attributes)
  165. 1 return nil unless attributes.is_a?(Hash)
  166. 1 attributes = attributes.transform_keys(&:to_sym)
  167. 1 transformed_hash = {}
  168. 1 openapi_types.each_pair do |key, type|
  169. 4 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  170. transformed_hash["#{key}"] = nil
  171. 4 elsif type =~ /\AArray<(.*)>/i
  172. # check to ensure the input is an array given that the attribute
  173. # is documented as an array but the input is not
  174. if attributes[attribute_map[key]].is_a?(Array)
  175. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  176. end
  177. 4 elsif !attributes[attribute_map[key]].nil?
  178. 4 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  179. end
  180. end
  181. 1 new(transformed_hash)
  182. end
  183. # Returns the object in the form of hash
  184. # @return [Hash] Returns the object in the form of hash
  185. 1 def to_hash
  186. 2 hash = {}
  187. 2 self.class.attribute_map.each_pair do |attr, param|
  188. 8 value = self.send(attr)
  189. 8 if value.nil?
  190. is_nullable = self.class.openapi_nullable.include?(attr)
  191. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  192. end
  193. 8 hash[param] = _to_hash(value)
  194. end
  195. 2 hash
  196. end
  197. end
  198. end

lib/bandwidth-sdk/models/verify_code_request.rb

67.77% lines covered

121 relevant lines. 82 lines covered and 39 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class VerifyCodeRequest < ApiModelBase
  13. # The phone number to send the mfa code to.
  14. 1 attr_accessor :to
  15. # An optional field to denote what scope or action the mfa code is addressing. If not supplied, defaults to \"2FA\".
  16. 1 attr_accessor :scope
  17. # The time period, in minutes, to validate the mfa code. By setting this to 3 minutes, it will mean any code generated within the last 3 minutes are still valid. The valid range for expiration time is between 0 and 15 minutes, exclusively and inclusively, respectively.
  18. 1 attr_accessor :expiration_time_in_minutes
  19. # The generated mfa code to check if valid.
  20. 1 attr_accessor :code
  21. # Attribute mapping from ruby-style variable name to JSON key.
  22. 1 def self.attribute_map
  23. 37 {
  24. :'to' => :'to',
  25. :'scope' => :'scope',
  26. :'expiration_time_in_minutes' => :'expirationTimeInMinutes',
  27. :'code' => :'code'
  28. }
  29. end
  30. # Returns attribute mapping this model knows about
  31. 1 def self.acceptable_attribute_map
  32. 17 attribute_map
  33. end
  34. # Returns all the JSON keys this model knows about
  35. 1 def self.acceptable_attributes
  36. 1 acceptable_attribute_map.values
  37. end
  38. # Attribute type mapping.
  39. 1 def self.openapi_types
  40. 1 {
  41. :'to' => :'String',
  42. :'scope' => :'String',
  43. :'expiration_time_in_minutes' => :'Float',
  44. :'code' => :'String'
  45. }
  46. end
  47. # List of attributes with nullable: true
  48. 1 def self.openapi_nullable
  49. 1 Set.new([
  50. ])
  51. end
  52. # Initializes the object
  53. # @param [Hash] attributes Model attributes in the form of hash
  54. 1 def initialize(attributes = {})
  55. 17 if (!attributes.is_a?(Hash))
  56. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::VerifyCodeRequest` initialize method'
  57. end
  58. # check to see if the attribute exists and convert string to symbol for hash key
  59. 16 acceptable_attribute_map = self.class.acceptable_attribute_map
  60. 16 attributes = attributes.each_with_object({}) { |(k, v), h|
  61. 44 if (!acceptable_attribute_map.key?(k.to_sym))
  62. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::VerifyCodeRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  63. end
  64. 43 h[k.to_sym] = v
  65. }
  66. 15 if attributes.key?(:'to')
  67. 15 self.to = attributes[:'to']
  68. else
  69. self.to = nil
  70. end
  71. 13 if attributes.key?(:'scope')
  72. 5 self.scope = attributes[:'scope']
  73. end
  74. 13 if attributes.key?(:'expiration_time_in_minutes')
  75. 13 self.expiration_time_in_minutes = attributes[:'expiration_time_in_minutes']
  76. else
  77. self.expiration_time_in_minutes = nil
  78. end
  79. 10 if attributes.key?(:'code')
  80. 10 self.code = attributes[:'code']
  81. else
  82. self.code = nil
  83. end
  84. end
  85. # Show invalid properties with the reasons. Usually used together with valid?
  86. # @return Array for valid properties with the reasons
  87. 1 def list_invalid_properties
  88. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  89. invalid_properties = Array.new
  90. if @to.nil?
  91. invalid_properties.push('invalid value for "to", to cannot be nil.')
  92. end
  93. pattern = Regexp.new(/^\+[1-9]\d{1,14}$/)
  94. if @to !~ pattern
  95. invalid_properties.push("invalid value for \"to\", must conform to the pattern #{pattern}.")
  96. end
  97. if @expiration_time_in_minutes.nil?
  98. invalid_properties.push('invalid value for "expiration_time_in_minutes", expiration_time_in_minutes cannot be nil.')
  99. end
  100. if @expiration_time_in_minutes > 15
  101. invalid_properties.push('invalid value for "expiration_time_in_minutes", must be smaller than or equal to 15.')
  102. end
  103. if @expiration_time_in_minutes < 1
  104. invalid_properties.push('invalid value for "expiration_time_in_minutes", must be greater than or equal to 1.')
  105. end
  106. if @code.nil?
  107. invalid_properties.push('invalid value for "code", code cannot be nil.')
  108. end
  109. if @code.to_s.length > 8
  110. invalid_properties.push('invalid value for "code", the character length must be smaller than or equal to 8.')
  111. end
  112. if @code.to_s.length < 4
  113. invalid_properties.push('invalid value for "code", the character length must be greater than or equal to 4.')
  114. end
  115. invalid_properties
  116. end
  117. # Check to see if the all the properties in the model are valid
  118. # @return true if the model is valid
  119. 1 def valid?
  120. warn '[DEPRECATED] the `valid?` method is obsolete'
  121. return false if @to.nil?
  122. return false if @to !~ Regexp.new(/^\+[1-9]\d{1,14}$/)
  123. return false if @expiration_time_in_minutes.nil?
  124. return false if @expiration_time_in_minutes > 15
  125. return false if @expiration_time_in_minutes < 1
  126. return false if @code.nil?
  127. return false if @code.to_s.length > 8
  128. return false if @code.to_s.length < 4
  129. true
  130. end
  131. # Custom attribute writer method with validation
  132. # @param [Object] to Value to be assigned
  133. 1 def to=(to)
  134. 15 if to.nil?
  135. 1 fail ArgumentError, 'to cannot be nil'
  136. end
  137. 14 pattern = Regexp.new(/^\+[1-9]\d{1,14}$/)
  138. 14 if to !~ pattern
  139. 1 fail ArgumentError, "invalid value for \"to\", must conform to the pattern #{pattern}."
  140. end
  141. 13 @to = to
  142. end
  143. # Custom attribute writer method with validation
  144. # @param [Object] expiration_time_in_minutes Value to be assigned
  145. 1 def expiration_time_in_minutes=(expiration_time_in_minutes)
  146. 13 if expiration_time_in_minutes.nil?
  147. 1 fail ArgumentError, 'expiration_time_in_minutes cannot be nil'
  148. end
  149. 12 if expiration_time_in_minutes > 15
  150. 1 fail ArgumentError, 'invalid value for "expiration_time_in_minutes", must be smaller than or equal to 15.'
  151. end
  152. 11 if expiration_time_in_minutes < 1
  153. 1 fail ArgumentError, 'invalid value for "expiration_time_in_minutes", must be greater than or equal to 1.'
  154. end
  155. 10 @expiration_time_in_minutes = expiration_time_in_minutes
  156. end
  157. # Custom attribute writer method with validation
  158. # @param [Object] code Value to be assigned
  159. 1 def code=(code)
  160. 10 if code.nil?
  161. 1 fail ArgumentError, 'code cannot be nil'
  162. end
  163. 9 if code.to_s.length > 8
  164. 1 fail ArgumentError, 'invalid value for "code", the character length must be smaller than or equal to 8.'
  165. end
  166. 8 if code.to_s.length < 4
  167. 1 fail ArgumentError, 'invalid value for "code", the character length must be greater than or equal to 4.'
  168. end
  169. 7 @code = code
  170. end
  171. # Checks equality by comparing each attribute.
  172. # @param [Object] Object to be compared
  173. 1 def ==(o)
  174. 2 return true if self.equal?(o)
  175. 2 self.class == o.class &&
  176. to == o.to &&
  177. scope == o.scope &&
  178. expiration_time_in_minutes == o.expiration_time_in_minutes &&
  179. code == o.code
  180. end
  181. # @see the `==` method
  182. # @param [Object] Object to be compared
  183. 1 def eql?(o)
  184. 2 self == o
  185. end
  186. # Calculates hash code according to all attributes.
  187. # @return [Integer] Hash code
  188. 1 def hash
  189. [to, scope, expiration_time_in_minutes, code].hash
  190. end
  191. # Builds the object from hash
  192. # @param [Hash] attributes Model attributes in the form of hash
  193. # @return [Object] Returns the model itself
  194. 1 def self.build_from_hash(attributes)
  195. 1 return nil unless attributes.is_a?(Hash)
  196. 1 attributes = attributes.transform_keys(&:to_sym)
  197. 1 transformed_hash = {}
  198. 1 openapi_types.each_pair do |key, type|
  199. 4 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  200. transformed_hash["#{key}"] = nil
  201. 4 elsif type =~ /\AArray<(.*)>/i
  202. # check to ensure the input is an array given that the attribute
  203. # is documented as an array but the input is not
  204. if attributes[attribute_map[key]].is_a?(Array)
  205. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  206. end
  207. 4 elsif !attributes[attribute_map[key]].nil?
  208. 4 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  209. end
  210. end
  211. 1 new(transformed_hash)
  212. end
  213. # Returns the object in the form of hash
  214. # @return [Hash] Returns the object in the form of hash
  215. 1 def to_hash
  216. 3 hash = {}
  217. 3 self.class.attribute_map.each_pair do |attr, param|
  218. 12 value = self.send(attr)
  219. 12 if value.nil?
  220. is_nullable = self.class.openapi_nullable.include?(attr)
  221. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  222. end
  223. 12 hash[param] = _to_hash(value)
  224. end
  225. 3 hash
  226. end
  227. end
  228. end

lib/bandwidth-sdk/models/verify_code_response.rb

81.97% lines covered

61 relevant lines. 50 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class VerifyCodeResponse < ApiModelBase
  13. # Whether or not the supplied code is valid.
  14. 1 attr_accessor :valid
  15. # Attribute mapping from ruby-style variable name to JSON key.
  16. 1 def self.attribute_map
  17. 27 {
  18. :'valid' => :'valid'
  19. }
  20. end
  21. # Returns attribute mapping this model knows about
  22. 1 def self.acceptable_attribute_map
  23. 11 attribute_map
  24. end
  25. # Returns all the JSON keys this model knows about
  26. 1 def self.acceptable_attributes
  27. 1 acceptable_attribute_map.values
  28. end
  29. # Attribute type mapping.
  30. 1 def self.openapi_types
  31. 3 {
  32. :'valid' => :'Boolean'
  33. }
  34. end
  35. # List of attributes with nullable: true
  36. 1 def self.openapi_nullable
  37. 1 Set.new([
  38. ])
  39. end
  40. # Initializes the object
  41. # @param [Hash] attributes Model attributes in the form of hash
  42. 1 def initialize(attributes = {})
  43. 11 if (!attributes.is_a?(Hash))
  44. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::VerifyCodeResponse` initialize method'
  45. end
  46. # check to see if the attribute exists and convert string to symbol for hash key
  47. 10 acceptable_attribute_map = self.class.acceptable_attribute_map
  48. 10 attributes = attributes.each_with_object({}) { |(k, v), h|
  49. 8 if (!acceptable_attribute_map.key?(k.to_sym))
  50. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::VerifyCodeResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  51. end
  52. 7 h[k.to_sym] = v
  53. }
  54. 9 if attributes.key?(:'valid')
  55. 7 self.valid = attributes[:'valid']
  56. end
  57. end
  58. # Show invalid properties with the reasons. Usually used together with valid?
  59. # @return Array for valid properties with the reasons
  60. 1 def list_invalid_properties
  61. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  62. invalid_properties = Array.new
  63. invalid_properties
  64. end
  65. # Check to see if the all the properties in the model are valid
  66. # @return true if the model is valid
  67. 1 def valid?
  68. warn '[DEPRECATED] the `valid?` method is obsolete'
  69. true
  70. end
  71. # Checks equality by comparing each attribute.
  72. # @param [Object] Object to be compared
  73. 1 def ==(o)
  74. 2 return true if self.equal?(o)
  75. 2 self.class == o.class &&
  76. valid == o.valid
  77. end
  78. # @see the `==` method
  79. # @param [Object] Object to be compared
  80. 1 def eql?(o)
  81. 2 self == o
  82. end
  83. # Calculates hash code according to all attributes.
  84. # @return [Integer] Hash code
  85. 1 def hash
  86. [valid].hash
  87. end
  88. # Builds the object from hash
  89. # @param [Hash] attributes Model attributes in the form of hash
  90. # @return [Object] Returns the model itself
  91. 1 def self.build_from_hash(attributes)
  92. 3 return nil unless attributes.is_a?(Hash)
  93. 3 attributes = attributes.transform_keys(&:to_sym)
  94. 3 transformed_hash = {}
  95. 3 openapi_types.each_pair do |key, type|
  96. 3 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  97. transformed_hash["#{key}"] = nil
  98. 3 elsif type =~ /\AArray<(.*)>/i
  99. # check to ensure the input is an array given that the attribute
  100. # is documented as an array but the input is not
  101. if attributes[attribute_map[key]].is_a?(Array)
  102. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  103. end
  104. 3 elsif !attributes[attribute_map[key]].nil?
  105. 3 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  106. end
  107. end
  108. 3 new(transformed_hash)
  109. end
  110. # Returns the object in the form of hash
  111. # @return [Hash] Returns the object in the form of hash
  112. 1 def to_hash
  113. 3 hash = {}
  114. 3 self.class.attribute_map.each_pair do |attr, param|
  115. 3 value = self.send(attr)
  116. 3 if value.nil?
  117. is_nullable = self.class.openapi_nullable.include?(attr)
  118. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  119. end
  120. 3 hash[param] = _to_hash(value)
  121. end
  122. 3 hash
  123. end
  124. end
  125. end

lib/bandwidth-sdk/models/voice_api_error.rb

83.58% lines covered

67 relevant lines. 56 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class VoiceApiError < ApiModelBase
  13. 1 attr_accessor :type
  14. 1 attr_accessor :description
  15. 1 attr_accessor :id
  16. # Attribute mapping from ruby-style variable name to JSON key.
  17. 1 def self.attribute_map
  18. 23 {
  19. :'type' => :'type',
  20. :'description' => :'description',
  21. :'id' => :'id'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 8 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 1 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 1 {
  35. :'type' => :'String',
  36. :'description' => :'String',
  37. :'id' => :'String'
  38. }
  39. end
  40. # List of attributes with nullable: true
  41. 1 def self.openapi_nullable
  42. 1 Set.new([
  43. :'id'
  44. ])
  45. end
  46. # Initializes the object
  47. # @param [Hash] attributes Model attributes in the form of hash
  48. 1 def initialize(attributes = {})
  49. 8 if (!attributes.is_a?(Hash))
  50. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::VoiceApiError` initialize method'
  51. end
  52. # check to see if the attribute exists and convert string to symbol for hash key
  53. 7 acceptable_attribute_map = self.class.acceptable_attribute_map
  54. 7 attributes = attributes.each_with_object({}) { |(k, v), h|
  55. 13 if (!acceptable_attribute_map.key?(k.to_sym))
  56. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::VoiceApiError`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  57. end
  58. 12 h[k.to_sym] = v
  59. }
  60. 6 if attributes.key?(:'type')
  61. 4 self.type = attributes[:'type']
  62. end
  63. 6 if attributes.key?(:'description')
  64. 4 self.description = attributes[:'description']
  65. end
  66. 6 if attributes.key?(:'id')
  67. 4 self.id = attributes[:'id']
  68. end
  69. end
  70. # Show invalid properties with the reasons. Usually used together with valid?
  71. # @return Array for valid properties with the reasons
  72. 1 def list_invalid_properties
  73. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  74. invalid_properties = Array.new
  75. invalid_properties
  76. end
  77. # Check to see if the all the properties in the model are valid
  78. # @return true if the model is valid
  79. 1 def valid?
  80. warn '[DEPRECATED] the `valid?` method is obsolete'
  81. true
  82. end
  83. # Checks equality by comparing each attribute.
  84. # @param [Object] Object to be compared
  85. 1 def ==(o)
  86. 2 return true if self.equal?(o)
  87. 2 self.class == o.class &&
  88. type == o.type &&
  89. description == o.description &&
  90. id == o.id
  91. end
  92. # @see the `==` method
  93. # @param [Object] Object to be compared
  94. 1 def eql?(o)
  95. 2 self == o
  96. end
  97. # Calculates hash code according to all attributes.
  98. # @return [Integer] Hash code
  99. 1 def hash
  100. [type, description, id].hash
  101. end
  102. # Builds the object from hash
  103. # @param [Hash] attributes Model attributes in the form of hash
  104. # @return [Object] Returns the model itself
  105. 1 def self.build_from_hash(attributes)
  106. 1 return nil unless attributes.is_a?(Hash)
  107. 1 attributes = attributes.transform_keys(&:to_sym)
  108. 1 transformed_hash = {}
  109. 1 openapi_types.each_pair do |key, type|
  110. 3 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  111. transformed_hash["#{key}"] = nil
  112. 3 elsif type =~ /\AArray<(.*)>/i
  113. # check to ensure the input is an array given that the attribute
  114. # is documented as an array but the input is not
  115. if attributes[attribute_map[key]].is_a?(Array)
  116. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  117. end
  118. 3 elsif !attributes[attribute_map[key]].nil?
  119. 3 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  120. end
  121. end
  122. 1 new(transformed_hash)
  123. end
  124. # Returns the object in the form of hash
  125. # @return [Hash] Returns the object in the form of hash
  126. 1 def to_hash
  127. 2 hash = {}
  128. 2 self.class.attribute_map.each_pair do |attr, param|
  129. 6 value = self.send(attr)
  130. 6 if value.nil?
  131. is_nullable = self.class.openapi_nullable.include?(attr)
  132. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  133. end
  134. 6 hash[param] = _to_hash(value)
  135. end
  136. 2 hash
  137. end
  138. end
  139. end

lib/bandwidth-sdk/models/voice_code_response.rb

81.97% lines covered

61 relevant lines. 50 lines covered and 11 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class VoiceCodeResponse < ApiModelBase
  13. # Programmable Voice API Call ID.
  14. 1 attr_accessor :call_id
  15. # Attribute mapping from ruby-style variable name to JSON key.
  16. 1 def self.attribute_map
  17. 20 {
  18. :'call_id' => :'callId'
  19. }
  20. end
  21. # Returns attribute mapping this model knows about
  22. 1 def self.acceptable_attribute_map
  23. 9 attribute_map
  24. end
  25. # Returns all the JSON keys this model knows about
  26. 1 def self.acceptable_attributes
  27. 1 acceptable_attribute_map.values
  28. end
  29. # Attribute type mapping.
  30. 1 def self.openapi_types
  31. 2 {
  32. :'call_id' => :'String'
  33. }
  34. end
  35. # List of attributes with nullable: true
  36. 1 def self.openapi_nullable
  37. 1 Set.new([
  38. ])
  39. end
  40. # Initializes the object
  41. # @param [Hash] attributes Model attributes in the form of hash
  42. 1 def initialize(attributes = {})
  43. 9 if (!attributes.is_a?(Hash))
  44. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::VoiceCodeResponse` initialize method'
  45. end
  46. # check to see if the attribute exists and convert string to symbol for hash key
  47. 8 acceptable_attribute_map = self.class.acceptable_attribute_map
  48. 8 attributes = attributes.each_with_object({}) { |(k, v), h|
  49. 6 if (!acceptable_attribute_map.key?(k.to_sym))
  50. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::VoiceCodeResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  51. end
  52. 5 h[k.to_sym] = v
  53. }
  54. 7 if attributes.key?(:'call_id')
  55. 5 self.call_id = attributes[:'call_id']
  56. end
  57. end
  58. # Show invalid properties with the reasons. Usually used together with valid?
  59. # @return Array for valid properties with the reasons
  60. 1 def list_invalid_properties
  61. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  62. invalid_properties = Array.new
  63. invalid_properties
  64. end
  65. # Check to see if the all the properties in the model are valid
  66. # @return true if the model is valid
  67. 1 def valid?
  68. warn '[DEPRECATED] the `valid?` method is obsolete'
  69. true
  70. end
  71. # Checks equality by comparing each attribute.
  72. # @param [Object] Object to be compared
  73. 1 def ==(o)
  74. 2 return true if self.equal?(o)
  75. 2 self.class == o.class &&
  76. call_id == o.call_id
  77. end
  78. # @see the `==` method
  79. # @param [Object] Object to be compared
  80. 1 def eql?(o)
  81. 2 self == o
  82. end
  83. # Calculates hash code according to all attributes.
  84. # @return [Integer] Hash code
  85. 1 def hash
  86. [call_id].hash
  87. end
  88. # Builds the object from hash
  89. # @param [Hash] attributes Model attributes in the form of hash
  90. # @return [Object] Returns the model itself
  91. 1 def self.build_from_hash(attributes)
  92. 2 return nil unless attributes.is_a?(Hash)
  93. 2 attributes = attributes.transform_keys(&:to_sym)
  94. 2 transformed_hash = {}
  95. 2 openapi_types.each_pair do |key, type|
  96. 2 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  97. transformed_hash["#{key}"] = nil
  98. 2 elsif type =~ /\AArray<(.*)>/i
  99. # check to ensure the input is an array given that the attribute
  100. # is documented as an array but the input is not
  101. if attributes[attribute_map[key]].is_a?(Array)
  102. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  103. end
  104. 2 elsif !attributes[attribute_map[key]].nil?
  105. 2 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  106. end
  107. end
  108. 2 new(transformed_hash)
  109. end
  110. # Returns the object in the form of hash
  111. # @return [Hash] Returns the object in the form of hash
  112. 1 def to_hash
  113. 2 hash = {}
  114. 2 self.class.attribute_map.each_pair do |attr, param|
  115. 2 value = self.send(attr)
  116. 2 if value.nil?
  117. is_nullable = self.class.openapi_nullable.include?(attr)
  118. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  119. end
  120. 2 hash[param] = _to_hash(value)
  121. end
  122. 2 hash
  123. end
  124. end
  125. end

lib/bandwidth-sdk/models/webhook_subscription.rb

76.36% lines covered

110 relevant lines. 84 lines covered and 26 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # Information about a webhook that Bandwidth should send upon the completion of event customer has subscribed to.
  13. 1 class WebhookSubscription < ApiModelBase
  14. 1 attr_accessor :id
  15. 1 attr_accessor :account_id
  16. # Callback URL to receive status updates from Bandwidth. When a webhook subscription is registered with Bandwidth under a given account ID, it will be used to send status updates for all requests submitted under that account ID.
  17. 1 attr_accessor :callback_url
  18. 1 attr_accessor :type
  19. 1 attr_accessor :basic_authentication
  20. 1 attr_accessor :created_date
  21. 1 attr_accessor :modified_date
  22. 1 class EnumAttributeValidator
  23. 1 attr_reader :datatype
  24. 1 attr_reader :allowable_values
  25. 1 def initialize(datatype, allowable_values)
  26. @allowable_values = allowable_values.map do |value|
  27. case datatype.to_s
  28. when /Integer/i
  29. value.to_i
  30. when /Float/i
  31. value.to_f
  32. else
  33. value
  34. end
  35. end
  36. end
  37. 1 def valid?(value)
  38. !value || allowable_values.include?(value)
  39. end
  40. end
  41. # Attribute mapping from ruby-style variable name to JSON key.
  42. 1 def self.attribute_map
  43. 152 {
  44. :'id' => :'id',
  45. :'account_id' => :'accountId',
  46. :'callback_url' => :'callbackUrl',
  47. :'type' => :'type',
  48. :'basic_authentication' => :'basicAuthentication',
  49. :'created_date' => :'createdDate',
  50. :'modified_date' => :'modifiedDate'
  51. }
  52. end
  53. # Returns attribute mapping this model knows about
  54. 1 def self.acceptable_attribute_map
  55. 17 attribute_map
  56. end
  57. # Returns all the JSON keys this model knows about
  58. 1 def self.acceptable_attributes
  59. 1 acceptable_attribute_map.values
  60. end
  61. # Attribute type mapping.
  62. 1 def self.openapi_types
  63. 5 {
  64. :'id' => :'String',
  65. :'account_id' => :'String',
  66. :'callback_url' => :'String',
  67. :'type' => :'WebhookSubscriptionTypeEnum',
  68. :'basic_authentication' => :'WebhookSubscriptionBasicAuthentication',
  69. :'created_date' => :'Time',
  70. :'modified_date' => :'Time'
  71. }
  72. end
  73. # List of attributes with nullable: true
  74. 1 def self.openapi_nullable
  75. 11 Set.new([
  76. :'callback_url',
  77. ])
  78. end
  79. # Initializes the object
  80. # @param [Hash] attributes Model attributes in the form of hash
  81. 1 def initialize(attributes = {})
  82. 17 if (!attributes.is_a?(Hash))
  83. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::WebhookSubscription` initialize method'
  84. end
  85. # check to see if the attribute exists and convert string to symbol for hash key
  86. 16 acceptable_attribute_map = self.class.acceptable_attribute_map
  87. 16 attributes = attributes.each_with_object({}) { |(k, v), h|
  88. 67 if (!acceptable_attribute_map.key?(k.to_sym))
  89. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::WebhookSubscription`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  90. end
  91. 66 h[k.to_sym] = v
  92. }
  93. 15 if attributes.key?(:'id')
  94. 13 self.id = attributes[:'id']
  95. end
  96. 15 if attributes.key?(:'account_id')
  97. 13 self.account_id = attributes[:'account_id']
  98. end
  99. 15 if attributes.key?(:'callback_url')
  100. 8 self.callback_url = attributes[:'callback_url']
  101. else
  102. 7 self.callback_url = nil
  103. end
  104. 15 if attributes.key?(:'type')
  105. 8 self.type = attributes[:'type']
  106. end
  107. 15 if attributes.key?(:'basic_authentication')
  108. 8 self.basic_authentication = attributes[:'basic_authentication']
  109. end
  110. 15 if attributes.key?(:'created_date')
  111. 8 self.created_date = attributes[:'created_date']
  112. end
  113. 15 if attributes.key?(:'modified_date')
  114. 8 self.modified_date = attributes[:'modified_date']
  115. end
  116. end
  117. # Show invalid properties with the reasons. Usually used together with valid?
  118. # @return Array for valid properties with the reasons
  119. 1 def list_invalid_properties
  120. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  121. invalid_properties = Array.new
  122. if @callback_url.to_s.length > 2000
  123. invalid_properties.push('invalid value for "callback_url", the character length must be smaller than or equal to 2000.')
  124. end
  125. if @callback_url.to_s.length < 0
  126. invalid_properties.push('invalid value for "callback_url", the character length must be greater than or equal to 0.')
  127. end
  128. pattern = Regexp.new(/^$|(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,253}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#()?&\/\/=]*)/)
  129. if @callback_url !~ pattern
  130. invalid_properties.push("invalid value for \"callback_url\", must conform to the pattern #{pattern}.")
  131. end
  132. invalid_properties
  133. end
  134. # Check to see if the all the properties in the model are valid
  135. # @return true if the model is valid
  136. 1 def valid?
  137. warn '[DEPRECATED] the `valid?` method is obsolete'
  138. return false if @callback_url.to_s.length > 2000
  139. return false if @callback_url.to_s.length < 0
  140. return false if @callback_url !~ Regexp.new(/^$|(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,253}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#()?&\/\/=]*)/)
  141. true
  142. end
  143. # Custom attribute writer method with validation
  144. # @param [Object] callback_url Value to be assigned
  145. 1 def callback_url=(callback_url)
  146. 17 if !callback_url.nil? && callback_url.to_s.length > 2000
  147. 1 fail ArgumentError, 'invalid value for "callback_url", the character length must be smaller than or equal to 2000.'
  148. end
  149. 16 if !callback_url.nil? && callback_url.to_s.length < 0
  150. fail ArgumentError, 'invalid value for "callback_url", the character length must be greater than or equal to 0.'
  151. end
  152. 16 pattern = Regexp.new(/^$|(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,253}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#()?&\/\/=]*)/)
  153. 16 if !callback_url.nil? && callback_url !~ pattern
  154. 1 fail ArgumentError, "invalid value for \"callback_url\", must conform to the pattern #{pattern}."
  155. end
  156. 15 @callback_url = callback_url
  157. end
  158. # Checks equality by comparing each attribute.
  159. # @param [Object] Object to be compared
  160. 1 def ==(o)
  161. 2 return true if self.equal?(o)
  162. 2 self.class == o.class &&
  163. id == o.id &&
  164. account_id == o.account_id &&
  165. callback_url == o.callback_url &&
  166. type == o.type &&
  167. basic_authentication == o.basic_authentication &&
  168. created_date == o.created_date &&
  169. modified_date == o.modified_date
  170. end
  171. # @see the `==` method
  172. # @param [Object] Object to be compared
  173. 1 def eql?(o)
  174. 2 self == o
  175. end
  176. # Calculates hash code according to all attributes.
  177. # @return [Integer] Hash code
  178. 1 def hash
  179. [id, account_id, callback_url, type, basic_authentication, created_date, modified_date].hash
  180. end
  181. # Builds the object from hash
  182. # @param [Hash] attributes Model attributes in the form of hash
  183. # @return [Object] Returns the model itself
  184. 1 def self.build_from_hash(attributes)
  185. 5 return nil unless attributes.is_a?(Hash)
  186. 5 attributes = attributes.transform_keys(&:to_sym)
  187. 5 transformed_hash = {}
  188. 5 openapi_types.each_pair do |key, type|
  189. 35 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  190. transformed_hash["#{key}"] = nil
  191. 35 elsif type =~ /\AArray<(.*)>/i
  192. # check to ensure the input is an array given that the attribute
  193. # is documented as an array but the input is not
  194. if attributes[attribute_map[key]].is_a?(Array)
  195. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  196. end
  197. 35 elsif !attributes[attribute_map[key]].nil?
  198. 30 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  199. end
  200. end
  201. 5 new(transformed_hash)
  202. end
  203. # Returns the object in the form of hash
  204. # @return [Hash] Returns the object in the form of hash
  205. 1 def to_hash
  206. 4 hash = {}
  207. 4 self.class.attribute_map.each_pair do |attr, param|
  208. 28 value = self.send(attr)
  209. 28 if value.nil?
  210. 10 is_nullable = self.class.openapi_nullable.include?(attr)
  211. 10 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  212. end
  213. 20 hash[param] = _to_hash(value)
  214. end
  215. 4 hash
  216. end
  217. end
  218. end

lib/bandwidth-sdk/models/webhook_subscription_basic_authentication.rb

72.22% lines covered

90 relevant lines. 65 lines covered and 25 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # Basic authentication credentials are not required, but if present, both username and password must be provided.
  13. 1 class WebhookSubscriptionBasicAuthentication < ApiModelBase
  14. 1 attr_accessor :username
  15. 1 attr_accessor :password
  16. # Attribute mapping from ruby-style variable name to JSON key.
  17. 1 def self.attribute_map
  18. 65 {
  19. :'username' => :'username',
  20. :'password' => :'password'
  21. }
  22. end
  23. # Returns attribute mapping this model knows about
  24. 1 def self.acceptable_attribute_map
  25. 20 attribute_map
  26. end
  27. # Returns all the JSON keys this model knows about
  28. 1 def self.acceptable_attributes
  29. 1 acceptable_attribute_map.values
  30. end
  31. # Attribute type mapping.
  32. 1 def self.openapi_types
  33. 5 {
  34. :'username' => :'String',
  35. :'password' => :'String'
  36. }
  37. end
  38. # List of attributes with nullable: true
  39. 1 def self.openapi_nullable
  40. 1 Set.new([
  41. ])
  42. end
  43. # Initializes the object
  44. # @param [Hash] attributes Model attributes in the form of hash
  45. 1 def initialize(attributes = {})
  46. 20 if (!attributes.is_a?(Hash))
  47. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::WebhookSubscriptionBasicAuthentication` initialize method'
  48. end
  49. # check to see if the attribute exists and convert string to symbol for hash key
  50. 19 acceptable_attribute_map = self.class.acceptable_attribute_map
  51. 19 attributes = attributes.each_with_object({}) { |(k, v), h|
  52. 37 if (!acceptable_attribute_map.key?(k.to_sym))
  53. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::WebhookSubscriptionBasicAuthentication`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  54. end
  55. 36 h[k.to_sym] = v
  56. }
  57. 18 if attributes.key?(:'username')
  58. 18 self.username = attributes[:'username']
  59. else
  60. self.username = nil
  61. end
  62. 16 if attributes.key?(:'password')
  63. 16 self.password = attributes[:'password']
  64. else
  65. self.password = nil
  66. end
  67. end
  68. # Show invalid properties with the reasons. Usually used together with valid?
  69. # @return Array for valid properties with the reasons
  70. 1 def list_invalid_properties
  71. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  72. invalid_properties = Array.new
  73. if @username.nil?
  74. invalid_properties.push('invalid value for "username", username cannot be nil.')
  75. end
  76. if @username.to_s.length > 100
  77. invalid_properties.push('invalid value for "username", the character length must be smaller than or equal to 100.')
  78. end
  79. if @password.nil?
  80. invalid_properties.push('invalid value for "password", password cannot be nil.')
  81. end
  82. if @password.to_s.length > 200
  83. invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 200.')
  84. end
  85. invalid_properties
  86. end
  87. # Check to see if the all the properties in the model are valid
  88. # @return true if the model is valid
  89. 1 def valid?
  90. warn '[DEPRECATED] the `valid?` method is obsolete'
  91. return false if @username.nil?
  92. return false if @username.to_s.length > 100
  93. return false if @password.nil?
  94. return false if @password.to_s.length > 200
  95. true
  96. end
  97. # Custom attribute writer method with validation
  98. # @param [Object] username Value to be assigned
  99. 1 def username=(username)
  100. 18 if username.nil?
  101. 1 fail ArgumentError, 'username cannot be nil'
  102. end
  103. 17 if username.to_s.length > 100
  104. 1 fail ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 100.'
  105. end
  106. 16 @username = username
  107. end
  108. # Custom attribute writer method with validation
  109. # @param [Object] password Value to be assigned
  110. 1 def password=(password)
  111. 16 if password.nil?
  112. 1 fail ArgumentError, 'password cannot be nil'
  113. end
  114. 15 if password.to_s.length > 200
  115. 1 fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 200.'
  116. end
  117. 14 @password = password
  118. end
  119. # Checks equality by comparing each attribute.
  120. # @param [Object] Object to be compared
  121. 1 def ==(o)
  122. 2 return true if self.equal?(o)
  123. 2 self.class == o.class &&
  124. username == o.username &&
  125. password == o.password
  126. end
  127. # @see the `==` method
  128. # @param [Object] Object to be compared
  129. 1 def eql?(o)
  130. 2 self == o
  131. end
  132. # Calculates hash code according to all attributes.
  133. # @return [Integer] Hash code
  134. 1 def hash
  135. [username, password].hash
  136. end
  137. # Builds the object from hash
  138. # @param [Hash] attributes Model attributes in the form of hash
  139. # @return [Object] Returns the model itself
  140. 1 def self.build_from_hash(attributes)
  141. 5 return nil unless attributes.is_a?(Hash)
  142. 5 attributes = attributes.transform_keys(&:to_sym)
  143. 5 transformed_hash = {}
  144. 5 openapi_types.each_pair do |key, type|
  145. 10 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  146. transformed_hash["#{key}"] = nil
  147. 10 elsif type =~ /\AArray<(.*)>/i
  148. # check to ensure the input is an array given that the attribute
  149. # is documented as an array but the input is not
  150. if attributes[attribute_map[key]].is_a?(Array)
  151. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  152. end
  153. 10 elsif !attributes[attribute_map[key]].nil?
  154. 10 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  155. end
  156. end
  157. 5 new(transformed_hash)
  158. end
  159. # Returns the object in the form of hash
  160. # @return [Hash] Returns the object in the form of hash
  161. 1 def to_hash
  162. 4 hash = {}
  163. 4 self.class.attribute_map.each_pair do |attr, param|
  164. 8 value = self.send(attr)
  165. 8 if value.nil?
  166. is_nullable = self.class.openapi_nullable.include?(attr)
  167. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  168. end
  169. 8 hash[param] = _to_hash(value)
  170. end
  171. 4 hash
  172. end
  173. end
  174. end

lib/bandwidth-sdk/models/webhook_subscription_error.rb

89.71% lines covered

68 relevant lines. 61 lines covered and 7 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class WebhookSubscriptionError < ApiModelBase
  13. 1 attr_accessor :code
  14. 1 attr_accessor :description
  15. 1 attr_accessor :telephone_numbers
  16. # Attribute mapping from ruby-style variable name to JSON key.
  17. 1 def self.attribute_map
  18. 53 {
  19. :'code' => :'code',
  20. :'description' => :'description',
  21. :'telephone_numbers' => :'telephoneNumbers'
  22. }
  23. end
  24. # Returns attribute mapping this model knows about
  25. 1 def self.acceptable_attribute_map
  26. 14 attribute_map
  27. end
  28. # Returns all the JSON keys this model knows about
  29. 1 def self.acceptable_attributes
  30. 1 acceptable_attribute_map.values
  31. end
  32. # Attribute type mapping.
  33. 1 def self.openapi_types
  34. 3 {
  35. :'code' => :'Integer',
  36. :'description' => :'String',
  37. :'telephone_numbers' => :'Array<TelephoneNumber>'
  38. }
  39. end
  40. # List of attributes with nullable: true
  41. 1 def self.openapi_nullable
  42. 3 Set.new([
  43. ])
  44. end
  45. # Initializes the object
  46. # @param [Hash] attributes Model attributes in the form of hash
  47. 1 def initialize(attributes = {})
  48. 14 if (!attributes.is_a?(Hash))
  49. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::WebhookSubscriptionError` initialize method'
  50. end
  51. # check to see if the attribute exists and convert string to symbol for hash key
  52. 13 acceptable_attribute_map = self.class.acceptable_attribute_map
  53. 13 attributes = attributes.each_with_object({}) { |(k, v), h|
  54. 26 if (!acceptable_attribute_map.key?(k.to_sym))
  55. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::WebhookSubscriptionError`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  56. end
  57. 25 h[k.to_sym] = v
  58. }
  59. 12 if attributes.key?(:'code')
  60. 10 self.code = attributes[:'code']
  61. end
  62. 12 if attributes.key?(:'description')
  63. 10 self.description = attributes[:'description']
  64. end
  65. 12 if attributes.key?(:'telephone_numbers')
  66. 5 if (value = attributes[:'telephone_numbers']).is_a?(Array)
  67. 5 self.telephone_numbers = value
  68. end
  69. end
  70. end
  71. # Show invalid properties with the reasons. Usually used together with valid?
  72. # @return Array for valid properties with the reasons
  73. 1 def list_invalid_properties
  74. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  75. invalid_properties = Array.new
  76. invalid_properties
  77. end
  78. # Check to see if the all the properties in the model are valid
  79. # @return true if the model is valid
  80. 1 def valid?
  81. warn '[DEPRECATED] the `valid?` method is obsolete'
  82. true
  83. end
  84. # Checks equality by comparing each attribute.
  85. # @param [Object] Object to be compared
  86. 1 def ==(o)
  87. 2 return true if self.equal?(o)
  88. 2 self.class == o.class &&
  89. code == o.code &&
  90. description == o.description &&
  91. telephone_numbers == o.telephone_numbers
  92. end
  93. # @see the `==` method
  94. # @param [Object] Object to be compared
  95. 1 def eql?(o)
  96. 2 self == o
  97. end
  98. # Calculates hash code according to all attributes.
  99. # @return [Integer] Hash code
  100. 1 def hash
  101. [code, description, telephone_numbers].hash
  102. end
  103. # Builds the object from hash
  104. # @param [Hash] attributes Model attributes in the form of hash
  105. # @return [Object] Returns the model itself
  106. 1 def self.build_from_hash(attributes)
  107. 3 return nil unless attributes.is_a?(Hash)
  108. 3 attributes = attributes.transform_keys(&:to_sym)
  109. 3 transformed_hash = {}
  110. 3 openapi_types.each_pair do |key, type|
  111. 9 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  112. transformed_hash["#{key}"] = nil
  113. 9 elsif type =~ /\AArray<(.*)>/i
  114. # check to ensure the input is an array given that the attribute
  115. # is documented as an array but the input is not
  116. 3 if attributes[attribute_map[key]].is_a?(Array)
  117. 4 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  118. end
  119. 6 elsif !attributes[attribute_map[key]].nil?
  120. 6 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  121. end
  122. end
  123. 3 new(transformed_hash)
  124. end
  125. # Returns the object in the form of hash
  126. # @return [Hash] Returns the object in the form of hash
  127. 1 def to_hash
  128. 4 hash = {}
  129. 4 self.class.attribute_map.each_pair do |attr, param|
  130. 12 value = self.send(attr)
  131. 12 if value.nil?
  132. 2 is_nullable = self.class.openapi_nullable.include?(attr)
  133. 2 next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  134. end
  135. 10 hash[param] = _to_hash(value)
  136. end
  137. 4 hash
  138. end
  139. end
  140. end

lib/bandwidth-sdk/models/webhook_subscription_request_schema.rb

68.87% lines covered

106 relevant lines. 73 lines covered and 33 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class WebhookSubscriptionRequestSchema < ApiModelBase
  13. 1 attr_accessor :basic_authentication
  14. # Callback URL to receive status updates from Bandwidth. When a webhook subscription is registered with Bandwidth under a given account ID, it will be used to send status updates for all requests submitted under that account ID.
  15. 1 attr_accessor :callback_url
  16. # An ASCII string submitted by the user as a shared secret key for generating an HMAC header for callbacks.
  17. 1 attr_accessor :shared_secret_key
  18. # Attribute mapping from ruby-style variable name to JSON key.
  19. 1 def self.attribute_map
  20. 29 {
  21. :'basic_authentication' => :'basicAuthentication',
  22. :'callback_url' => :'callbackUrl',
  23. :'shared_secret_key' => :'sharedSecretKey'
  24. }
  25. end
  26. # Returns attribute mapping this model knows about
  27. 1 def self.acceptable_attribute_map
  28. 12 attribute_map
  29. end
  30. # Returns all the JSON keys this model knows about
  31. 1 def self.acceptable_attributes
  32. 1 acceptable_attribute_map.values
  33. end
  34. # Attribute type mapping.
  35. 1 def self.openapi_types
  36. 1 {
  37. :'basic_authentication' => :'TfvBasicAuthentication',
  38. :'callback_url' => :'String',
  39. :'shared_secret_key' => :'String'
  40. }
  41. end
  42. # List of attributes with nullable: true
  43. 1 def self.openapi_nullable
  44. 1 Set.new([
  45. :'callback_url',
  46. :'shared_secret_key'
  47. ])
  48. end
  49. # Initializes the object
  50. # @param [Hash] attributes Model attributes in the form of hash
  51. 1 def initialize(attributes = {})
  52. 12 if (!attributes.is_a?(Hash))
  53. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::WebhookSubscriptionRequestSchema` initialize method'
  54. end
  55. # check to see if the attribute exists and convert string to symbol for hash key
  56. 11 acceptable_attribute_map = self.class.acceptable_attribute_map
  57. 11 attributes = attributes.each_with_object({}) { |(k, v), h|
  58. 25 if (!acceptable_attribute_map.key?(k.to_sym))
  59. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::WebhookSubscriptionRequestSchema`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  60. end
  61. 24 h[k.to_sym] = v
  62. }
  63. 10 if attributes.key?(:'basic_authentication')
  64. 8 self.basic_authentication = attributes[:'basic_authentication']
  65. end
  66. 10 if attributes.key?(:'callback_url')
  67. 8 self.callback_url = attributes[:'callback_url']
  68. else
  69. 2 self.callback_url = nil
  70. end
  71. 10 if attributes.key?(:'shared_secret_key')
  72. 8 self.shared_secret_key = attributes[:'shared_secret_key']
  73. end
  74. end
  75. # Show invalid properties with the reasons. Usually used together with valid?
  76. # @return Array for valid properties with the reasons
  77. 1 def list_invalid_properties
  78. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  79. invalid_properties = Array.new
  80. if @callback_url.to_s.length > 2000
  81. invalid_properties.push('invalid value for "callback_url", the character length must be smaller than or equal to 2000.')
  82. end
  83. if @callback_url.to_s.length < 0
  84. invalid_properties.push('invalid value for "callback_url", the character length must be greater than or equal to 0.')
  85. end
  86. pattern = Regexp.new(/^$|(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,253}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#()?&\/\/=]*)/)
  87. if @callback_url !~ pattern
  88. invalid_properties.push("invalid value for \"callback_url\", must conform to the pattern #{pattern}.")
  89. end
  90. if !@shared_secret_key.nil? && @shared_secret_key.to_s.length > 64
  91. invalid_properties.push('invalid value for "shared_secret_key", the character length must be smaller than or equal to 64.')
  92. end
  93. if !@shared_secret_key.nil? && @shared_secret_key.to_s.length < 16
  94. invalid_properties.push('invalid value for "shared_secret_key", the character length must be greater than or equal to 16.')
  95. end
  96. pattern = Regexp.new(/^[ -~]{16,64}$/)
  97. if !@shared_secret_key.nil? && @shared_secret_key !~ pattern
  98. invalid_properties.push("invalid value for \"shared_secret_key\", must conform to the pattern #{pattern}.")
  99. end
  100. invalid_properties
  101. end
  102. # Check to see if the all the properties in the model are valid
  103. # @return true if the model is valid
  104. 1 def valid?
  105. warn '[DEPRECATED] the `valid?` method is obsolete'
  106. return false if @callback_url.to_s.length > 2000
  107. return false if @callback_url.to_s.length < 0
  108. return false if @callback_url !~ Regexp.new(/^$|(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,253}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#()?&\/\/=]*)/)
  109. return false if !@shared_secret_key.nil? && @shared_secret_key.to_s.length > 64
  110. return false if !@shared_secret_key.nil? && @shared_secret_key.to_s.length < 16
  111. return false if !@shared_secret_key.nil? && @shared_secret_key !~ Regexp.new(/^[ -~]{16,64}$/)
  112. true
  113. end
  114. # Custom attribute writer method with validation
  115. # @param [Object] callback_url Value to be assigned
  116. 1 def callback_url=(callback_url)
  117. 12 if !callback_url.nil? && callback_url.to_s.length > 2000
  118. 1 fail ArgumentError, 'invalid value for "callback_url", the character length must be smaller than or equal to 2000.'
  119. end
  120. 11 if !callback_url.nil? && callback_url.to_s.length < 0
  121. fail ArgumentError, 'invalid value for "callback_url", the character length must be greater than or equal to 0.'
  122. end
  123. 11 pattern = Regexp.new(/^$|(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,253}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#()?&\/\/=]*)/)
  124. 11 if !callback_url.nil? && callback_url !~ pattern
  125. 1 fail ArgumentError, "invalid value for \"callback_url\", must conform to the pattern #{pattern}."
  126. end
  127. 10 @callback_url = callback_url
  128. end
  129. # Custom attribute writer method with validation
  130. # @param [Object] shared_secret_key Value to be assigned
  131. 1 def shared_secret_key=(shared_secret_key)
  132. 10 if !shared_secret_key.nil? && shared_secret_key.to_s.length > 64
  133. 1 fail ArgumentError, 'invalid value for "shared_secret_key", the character length must be smaller than or equal to 64.'
  134. end
  135. 9 if !shared_secret_key.nil? && shared_secret_key.to_s.length < 16
  136. 1 fail ArgumentError, 'invalid value for "shared_secret_key", the character length must be greater than or equal to 16.'
  137. end
  138. 8 pattern = Regexp.new(/^[ -~]{16,64}$/)
  139. 8 if !shared_secret_key.nil? && shared_secret_key !~ pattern
  140. fail ArgumentError, "invalid value for \"shared_secret_key\", must conform to the pattern #{pattern}."
  141. end
  142. 8 @shared_secret_key = shared_secret_key
  143. end
  144. # Checks equality by comparing each attribute.
  145. # @param [Object] Object to be compared
  146. 1 def ==(o)
  147. 2 return true if self.equal?(o)
  148. 2 self.class == o.class &&
  149. basic_authentication == o.basic_authentication &&
  150. callback_url == o.callback_url &&
  151. shared_secret_key == o.shared_secret_key
  152. end
  153. # @see the `==` method
  154. # @param [Object] Object to be compared
  155. 1 def eql?(o)
  156. 2 self == o
  157. end
  158. # Calculates hash code according to all attributes.
  159. # @return [Integer] Hash code
  160. 1 def hash
  161. [basic_authentication, callback_url, shared_secret_key].hash
  162. end
  163. # Builds the object from hash
  164. # @param [Hash] attributes Model attributes in the form of hash
  165. # @return [Object] Returns the model itself
  166. 1 def self.build_from_hash(attributes)
  167. 1 return nil unless attributes.is_a?(Hash)
  168. 1 attributes = attributes.transform_keys(&:to_sym)
  169. 1 transformed_hash = {}
  170. 1 openapi_types.each_pair do |key, type|
  171. 3 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  172. transformed_hash["#{key}"] = nil
  173. 3 elsif type =~ /\AArray<(.*)>/i
  174. # check to ensure the input is an array given that the attribute
  175. # is documented as an array but the input is not
  176. if attributes[attribute_map[key]].is_a?(Array)
  177. transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  178. end
  179. 3 elsif !attributes[attribute_map[key]].nil?
  180. 3 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  181. end
  182. end
  183. 1 new(transformed_hash)
  184. end
  185. # Returns the object in the form of hash
  186. # @return [Hash] Returns the object in the form of hash
  187. 1 def to_hash
  188. 4 hash = {}
  189. 4 self.class.attribute_map.each_pair do |attr, param|
  190. 12 value = self.send(attr)
  191. 12 if value.nil?
  192. is_nullable = self.class.openapi_nullable.include?(attr)
  193. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  194. end
  195. 12 hash[param] = _to_hash(value)
  196. end
  197. 4 hash
  198. end
  199. end
  200. end

lib/bandwidth-sdk/models/webhook_subscription_type_enum.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. 1 class WebhookSubscriptionTypeEnum
  13. 1 TOLLFREE_VERIFICATION_STATUS = 'TOLLFREE_VERIFICATION_STATUS'.freeze
  14. 1 MESSAGING_PORTOUT_APPROVAL_STATUS = 'MESSAGING_PORTOUT_APPROVAL_STATUS'.freeze
  15. 1 def self.all_vars
  16. 11 @all_vars ||= [TOLLFREE_VERIFICATION_STATUS, MESSAGING_PORTOUT_APPROVAL_STATUS].freeze
  17. end
  18. # Builds the enum from string
  19. # @param [String] The enum value in the form of the string
  20. # @return [String] The enum value
  21. 1 def self.build_from_hash(value)
  22. 7 new.build_from_hash(value)
  23. end
  24. # Builds the enum from string
  25. # @param [String] The enum value in the form of the string
  26. # @return [String] The enum value
  27. 1 def build_from_hash(value)
  28. 7 return value if WebhookSubscriptionTypeEnum.all_vars.include?(value)
  29. 1 raise "Invalid ENUM value #{value} for class #WebhookSubscriptionTypeEnum"
  30. end
  31. end
  32. end

lib/bandwidth-sdk/models/webhook_subscriptions_list_body.rb

83.12% lines covered

77 relevant lines. 64 lines covered and 13 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 require 'date'
  10. 1 require 'time'
  11. 1 module Bandwidth
  12. # A list of all webhook subscriptions registered for this account ID for this particular feature (unpaginated).
  13. 1 class WebhookSubscriptionsListBody < ApiModelBase
  14. 1 attr_accessor :links
  15. 1 attr_accessor :errors
  16. 1 attr_accessor :data
  17. # Attribute mapping from ruby-style variable name to JSON key.
  18. 1 def self.attribute_map
  19. 37 {
  20. :'links' => :'links',
  21. :'errors' => :'errors',
  22. :'data' => :'data'
  23. }
  24. end
  25. # Returns attribute mapping this model knows about
  26. 1 def self.acceptable_attribute_map
  27. 10 attribute_map
  28. end
  29. # Returns all the JSON keys this model knows about
  30. 1 def self.acceptable_attributes
  31. 1 acceptable_attribute_map.values
  32. end
  33. # Attribute type mapping.
  34. 1 def self.openapi_types
  35. 2 {
  36. :'links' => :'LinksObject',
  37. :'errors' => :'Array<WebhookSubscriptionError>',
  38. :'data' => :'Array<WebhookSubscription>'
  39. }
  40. end
  41. # List of attributes with nullable: true
  42. 1 def self.openapi_nullable
  43. 1 Set.new([
  44. ])
  45. end
  46. # Initializes the object
  47. # @param [Hash] attributes Model attributes in the form of hash
  48. 1 def initialize(attributes = {})
  49. 10 if (!attributes.is_a?(Hash))
  50. 1 fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::WebhookSubscriptionsListBody` initialize method'
  51. end
  52. # check to see if the attribute exists and convert string to symbol for hash key
  53. 9 acceptable_attribute_map = self.class.acceptable_attribute_map
  54. 9 attributes = attributes.each_with_object({}) { |(k, v), h|
  55. 21 if (!acceptable_attribute_map.key?(k.to_sym))
  56. 1 fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::WebhookSubscriptionsListBody`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
  57. end
  58. 20 h[k.to_sym] = v
  59. }
  60. 8 if attributes.key?(:'links')
  61. 6 self.links = attributes[:'links']
  62. end
  63. 8 if attributes.key?(:'errors')
  64. 6 if (value = attributes[:'errors']).is_a?(Array)
  65. 6 self.errors = value
  66. end
  67. end
  68. 8 if attributes.key?(:'data')
  69. 8 if (value = attributes[:'data']).is_a?(Array)
  70. 8 self.data = value
  71. end
  72. else
  73. self.data = nil
  74. end
  75. end
  76. # Show invalid properties with the reasons. Usually used together with valid?
  77. # @return Array for valid properties with the reasons
  78. 1 def list_invalid_properties
  79. warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  80. invalid_properties = Array.new
  81. if @data.nil?
  82. invalid_properties.push('invalid value for "data", data cannot be nil.')
  83. end
  84. invalid_properties
  85. end
  86. # Check to see if the all the properties in the model are valid
  87. # @return true if the model is valid
  88. 1 def valid?
  89. warn '[DEPRECATED] the `valid?` method is obsolete'
  90. return false if @data.nil?
  91. true
  92. end
  93. # Custom attribute writer method with validation
  94. # @param [Object] data Value to be assigned
  95. 1 def data=(data)
  96. 9 if data.nil?
  97. 1 fail ArgumentError, 'data cannot be nil'
  98. end
  99. 8 @data = data
  100. end
  101. # Checks equality by comparing each attribute.
  102. # @param [Object] Object to be compared
  103. 1 def ==(o)
  104. 2 return true if self.equal?(o)
  105. 2 self.class == o.class &&
  106. links == o.links &&
  107. errors == o.errors &&
  108. data == o.data
  109. end
  110. # @see the `==` method
  111. # @param [Object] Object to be compared
  112. 1 def eql?(o)
  113. 2 self == o
  114. end
  115. # Calculates hash code according to all attributes.
  116. # @return [Integer] Hash code
  117. 1 def hash
  118. [links, errors, data].hash
  119. end
  120. # Builds the object from hash
  121. # @param [Hash] attributes Model attributes in the form of hash
  122. # @return [Object] Returns the model itself
  123. 1 def self.build_from_hash(attributes)
  124. 2 return nil unless attributes.is_a?(Hash)
  125. 2 attributes = attributes.transform_keys(&:to_sym)
  126. 2 transformed_hash = {}
  127. 2 openapi_types.each_pair do |key, type|
  128. 6 if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
  129. transformed_hash["#{key}"] = nil
  130. 6 elsif type =~ /\AArray<(.*)>/i
  131. # check to ensure the input is an array given that the attribute
  132. # is documented as an array but the input is not
  133. 4 if attributes[attribute_map[key]].is_a?(Array)
  134. 8 transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
  135. end
  136. 2 elsif !attributes[attribute_map[key]].nil?
  137. 2 transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
  138. end
  139. end
  140. 2 new(transformed_hash)
  141. end
  142. # Returns the object in the form of hash
  143. # @return [Hash] Returns the object in the form of hash
  144. 1 def to_hash
  145. 2 hash = {}
  146. 2 self.class.attribute_map.each_pair do |attr, param|
  147. 6 value = self.send(attr)
  148. 6 if value.nil?
  149. is_nullable = self.class.openapi_nullable.include?(attr)
  150. next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
  151. end
  152. 6 hash[param] = _to_hash(value)
  153. end
  154. 2 hash
  155. end
  156. end
  157. end

lib/bandwidth-sdk/version.rb

100.0% lines covered

2 relevant lines. 2 lines covered and 0 lines missed.
    
  1. =begin
  2. #Bandwidth
  3. #Bandwidth's Communication APIs
  4. The version of the OpenAPI document: 1.0.0
  5. Contact: letstalk@bandwidth.com
  6. Generated by: https://openapi-generator.tech
  7. Generator version: 7.17.0
  8. =end
  9. 1 module Bandwidth
  10. 1 VERSION = '18.1.1'
  11. end

spec/unit/api/calls_api_spec.rb

100.0% lines covered

128 relevant lines. 128 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CallsApi
  2. 1 describe 'CallsApi' do
  3. 4 let(:call_id) { 'c-1234' }
  4. 1 before(:all) do
  5. 1 Bandwidth.configure do |config|
  6. 1 config.debugging = true
  7. 1 config.username = BW_USERNAME
  8. 1 config.password = BW_PASSWORD
  9. 1 config.ignore_operation_servers = true
  10. 1 config.host = '127.0.0.1:4010'
  11. end
  12. 1 @calls_api_instance = Bandwidth::CallsApi.new
  13. end
  14. 1 describe 'test an instance of CallsApi' do
  15. 1 it 'should create an instance of CallsApi' do
  16. 1 expect(@calls_api_instance).to be_instance_of(Bandwidth::CallsApi)
  17. end
  18. end
  19. # Create Call
  20. 1 describe '#create_call' do
  21. 1 it 'creates a call with amd' do
  22. 1 amd_config = Bandwidth::MachineDetectionConfiguration.new(
  23. mode: Bandwidth::MachineDetectionModeEnum::ASYNC,
  24. detection_timeout: 15.0,
  25. silence_timeout: 10.0,
  26. speech_threshold: 10.0,
  27. speech_end_threshold: 5.0,
  28. machine_speech_end_threshold: 5.0,
  29. delay_result: false,
  30. callback_url: 'https://myServer.com/bandwidth/webhooks/machineDetectionComplete',
  31. callback_method: Bandwidth::CallbackMethodEnum::POST,
  32. username: 'mySecretUsername',
  33. password: 'mySecretPassword1!',
  34. fallback_url: 'https://myFallbackServer.com/bandwidth/webhooks/machineDetectionComplete',
  35. fallback_method: Bandwidth::CallbackMethodEnum::POST,
  36. fallback_username: 'mySecretUsername',
  37. fallback_password: 'mySecretPassword1!',
  38. )
  39. 1 call_body = Bandwidth::CreateCall.new(
  40. to: USER_NUMBER,
  41. from: BW_NUMBER,
  42. application_id: BW_VOICE_APPLICATION_ID,
  43. answer_url: BASE_CALLBACK_URL,
  44. answer_method: Bandwidth::CallbackMethodEnum::POST,
  45. username: 'mySecretUsername',
  46. password: 'mySecretPassword1!',
  47. answer_fallback_url: 'https://www.myFallbackServer.com/webhooks/answer',
  48. answer_fallback_method: Bandwidth::CallbackMethodEnum::POST,
  49. fallback_username: 'mySecretUsername',
  50. fallback_password: 'mySecretPassword1!',
  51. disconnect_url: 'https://myServer.com/bandwidth/webhooks/disconnectUrl',
  52. disconnect_method: Bandwidth::CallbackMethodEnum::POST,
  53. call_timeout: 30.0,
  54. callback_timeout: 15.0,
  55. machine_detection: amd_config,
  56. priority: 5,
  57. tag: 'tag_example',
  58. )
  59. 1 data, status_code = @calls_api_instance.create_call_with_http_info(BW_ACCOUNT_ID, call_body)
  60. 1 expect(status_code).to eq(201)
  61. 1 expect(data).to be_instance_of(Bandwidth::CreateCallResponse)
  62. 1 expect(data.application_id.length).to eq(36)
  63. 1 expect(data.account_id.length).to eq(7)
  64. 1 expect(data.call_id.length).to eq(47)
  65. 1 expect(data.to.length).to eq(12)
  66. 1 expect(data.from.length).to eq(12)
  67. 1 expect(data.enqueued_time).to be_instance_of(Time)
  68. 1 expect(data.call_url).to start_with('http')
  69. 1 expect(data.call_timeout).to be_instance_of(Float)
  70. 1 expect(data.callback_timeout).to be_instance_of(Float)
  71. 1 expect(data.tag).to be_instance_of(String)
  72. 1 expect(data.answer_method).to be_one_of(Bandwidth::CallbackMethodEnum.all_vars)
  73. 1 expect(data.answer_url).to start_with('http')
  74. 1 expect(data.answer_fallback_method).to be_one_of(Bandwidth::CallbackMethodEnum.all_vars)
  75. 1 expect(data.answer_fallback_url).to start_with('http')
  76. 1 expect(data.disconnect_method).to be_one_of(Bandwidth::CallbackMethodEnum.all_vars)
  77. 1 expect(data.disconnect_url).to start_with('http')
  78. 1 expect(data.username).to be_instance_of(String)
  79. 1 expect(data.password).to be_instance_of(String)
  80. 1 expect(data.fallback_username).to be_instance_of(String)
  81. 1 expect(data.fallback_password).to be_instance_of(String)
  82. 1 expect(data.priority).to be_instance_of(Integer)
  83. end
  84. 1 it 'causes an ArgumentError for a missing account_id' do
  85. 1 expect {
  86. 1 @calls_api_instance.create_call(nil, {})
  87. }.to raise_error(ArgumentError)
  88. end
  89. 1 it 'causes an ArgumentError for a missing create_call' do
  90. 1 expect {
  91. 1 @calls_api_instance.create_call(BW_ACCOUNT_ID, nil)
  92. }.to raise_error(ArgumentError)
  93. end
  94. end
  95. # Get Calls
  96. 1 describe '#list_calls' do
  97. 1 it 'gets a list of calls' do
  98. 1 data, status_code = @calls_api_instance.list_calls_with_http_info(BW_ACCOUNT_ID)
  99. 1 expect(status_code).to eq(200)
  100. 1 expect(data).to be_instance_of(Array)
  101. 1 expect(data[0]).to be_instance_of(Bandwidth::CallState)
  102. 1 expect(data[0].application_id.length).to eq(36)
  103. 1 expect(data[0].account_id.length).to eq(7)
  104. 1 expect(data[0].call_id.length).to eq(47)
  105. 1 expect(data[0].parent_call_id.length).to eq(47)
  106. 1 expect(data[0].to.length).to eq(12)
  107. 1 expect(data[0].from.length).to eq(12)
  108. 1 expect(data[0].direction).to be_one_of(Bandwidth::CallDirectionEnum.all_vars)
  109. 1 expect(data[0].state).to be_instance_of(String)
  110. 1 expect(data[0].stir_shaken).to be_instance_of(Hash)
  111. 1 expect(data[0].identity).to be_instance_of(String)
  112. 1 expect(data[0].enqueued_time).to be_instance_of(Time)
  113. 1 expect(data[0].start_time).to be_instance_of(Time)
  114. 1 expect(data[0].answer_time).to be_instance_of(Time)
  115. 1 expect(data[0].end_time).to be_instance_of(Time)
  116. 1 expect(data[0].disconnect_cause).to be_instance_of(String)
  117. 1 expect(data[0]).to respond_to(:error_message)
  118. 1 expect(data[0]).to respond_to(:error_id)
  119. 1 expect(data[0].last_update).to be_instance_of(Time)
  120. end
  121. end
  122. # # Get Call State Information
  123. 1 describe '#get_call_state' do
  124. 1 it 'gets the call state' do
  125. 1 data, status_code = @calls_api_instance.get_call_state_with_http_info(BW_ACCOUNT_ID, call_id)
  126. 1 expect(status_code).to eq(200)
  127. 1 expect(data).to be_instance_of(Bandwidth::CallState)
  128. 1 expect(data.application_id.length).to eq(36)
  129. 1 expect(data.account_id.length).to eq(7)
  130. 1 expect(data.call_id.length).to eq(47)
  131. 1 expect(data.parent_call_id.length).to eq(47)
  132. 1 expect(data.to.length).to eq(12)
  133. 1 expect(data.from.length).to eq(12)
  134. 1 expect(data.direction).to be_one_of(Bandwidth::CallDirectionEnum.all_vars)
  135. 1 expect(data.state).to be_instance_of(String)
  136. 1 expect(data.stir_shaken).to be_instance_of(Hash)
  137. 1 expect(data.identity).to be_instance_of(String)
  138. 1 expect(data.enqueued_time).to be_instance_of(Time)
  139. 1 expect(data.start_time).to be_instance_of(Time)
  140. 1 expect(data.answer_time).to be_instance_of(Time)
  141. 1 expect(data.end_time).to be_instance_of(Time)
  142. 1 expect(data.disconnect_cause).to be_instance_of(String)
  143. 1 expect(data).to respond_to(:error_message)
  144. 1 expect(data).to respond_to(:error_id)
  145. 1 expect(data.last_update).to be_instance_of(Time)
  146. end
  147. 1 it 'causes an ArgumentError for a missing account_id' do
  148. 1 expect {
  149. 1 @calls_api_instance.get_call_state(nil, '')
  150. }.to raise_error(ArgumentError)
  151. end
  152. 1 it 'causes an ArgumentError for a missing call_id' do
  153. 1 expect {
  154. 1 @calls_api_instance.get_call_state(BW_ACCOUNT_ID, nil)
  155. }.to raise_error(ArgumentError)
  156. end
  157. end
  158. # # Update Call
  159. 1 describe '#update_call' do
  160. 1 it 'creates and updates a call' do
  161. 1 update_call_body = Bandwidth::UpdateCall.new(
  162. state: Bandwidth::CallStateEnum::ACTIVE,
  163. redirect_url: MANTECA_BASE_URL + '/bxml/pause'
  164. )
  165. 1 _data, status_code = @calls_api_instance.update_call_with_http_info(BW_ACCOUNT_ID, call_id, update_call_body)
  166. 1 expect(status_code).to eq(200)
  167. end
  168. 1 it 'causes an ArgumentError for a missing account_id' do
  169. 1 expect {
  170. 1 @calls_api_instance.update_call(nil, '', {})
  171. }.to raise_error(ArgumentError)
  172. end
  173. 1 it 'causes an ArgumentError for a missing call_id' do
  174. 1 expect {
  175. 1 @calls_api_instance.update_call(BW_ACCOUNT_ID, nil, {})
  176. }.to raise_error(ArgumentError)
  177. end
  178. 1 it 'causes an ArgumentError for a missing update_call' do
  179. 1 expect {
  180. 1 @calls_api_instance.update_call(BW_ACCOUNT_ID, '', nil)
  181. }.to raise_error(ArgumentError)
  182. end
  183. end
  184. # Update Call BXML
  185. 1 describe '#update_call_bxml' do
  186. 1 it 'updates a call using bxml' do
  187. 1 update_bxml = "<?xml version='1.0' encoding='UTF-8'?><Bxml><SpeakSentence locale='en_US' gender='female' voice='susan'>This is a test bxml response</SpeakSentence><Pause duration='3'/></Bxml>"
  188. 1 _data, status_code = @calls_api_instance.update_call_bxml_with_http_info(BW_ACCOUNT_ID, call_id, update_bxml)
  189. 1 expect(status_code).to eq(204)
  190. end
  191. 1 it 'causes an ArgumentError for a missing account_id' do
  192. 1 expect {
  193. 1 @calls_api_instance.update_call_bxml(nil, '', {})
  194. }.to raise_error(ArgumentError)
  195. end
  196. 1 it 'causes an ArgumentError for a missing call_id' do
  197. 1 expect {
  198. 1 @calls_api_instance.update_call_bxml(BW_ACCOUNT_ID, nil, {})
  199. }.to raise_error(ArgumentError)
  200. end
  201. 1 it 'causes an ArgumentError for a missing body' do
  202. 1 expect {
  203. 1 @calls_api_instance.update_call_bxml(BW_ACCOUNT_ID, '', nil)
  204. }.to raise_error(ArgumentError)
  205. end
  206. end
  207. end

spec/unit/api/conferences_api_spec.rb

100.0% lines covered

184 relevant lines. 184 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::ConferencesApi
  2. 1 describe 'ConferencesApi' do
  3. 4 let(:call_id) { 'c-1234' }
  4. 9 let(:conference_id) { 'c-4321' }
  5. 3 let(:recording_id) { 'r-1234' }
  6. 1 before(:all) do
  7. 1 Bandwidth.configure do |config|
  8. 1 config.debugging = true
  9. 1 config.username = BW_USERNAME
  10. 1 config.password = BW_PASSWORD
  11. 1 config.ignore_operation_servers = true
  12. 1 config.return_binary_data = true
  13. 1 config.host = '127.0.0.1:4010'
  14. end
  15. 1 @conferences_api_instance = Bandwidth::ConferencesApi.new
  16. end
  17. 1 describe 'test an instance of ConferencesApi' do
  18. 1 it 'should create an instance of ConferencesApi' do
  19. 1 expect(@conferences_api_instance).to be_instance_of(Bandwidth::ConferencesApi)
  20. end
  21. end
  22. # Download Conference Recording
  23. 1 describe 'download_conference_recording test' do
  24. 1 it 'download a conference recording' do
  25. 1 data, status_code = @conferences_api_instance.download_conference_recording_with_http_info(
  26. BW_ACCOUNT_ID, conference_id, recording_id, { header_params: { 'Accept' => 'audio/vnd.wave' } })
  27. 1 expect(status_code).to eq(200)
  28. 1 expect(data).to be_instance_of(String)
  29. end
  30. 1 it 'causes an ArgumentError for a missing account_id' do
  31. 1 expect {
  32. 1 @conferences_api_instance.download_conference_recording(nil, '', '')
  33. }.to raise_error(ArgumentError)
  34. end
  35. 1 it 'causes an ArgumentError for a missing conference_id' do
  36. 1 expect {
  37. 1 @conferences_api_instance.download_conference_recording(BW_ACCOUNT_ID, nil, '')
  38. }.to raise_error(ArgumentError)
  39. end
  40. 1 it 'causes an ArgumentError for a missing recording_id' do
  41. 1 expect {
  42. 1 @conferences_api_instance.download_conference_recording(BW_ACCOUNT_ID, '', nil)
  43. }.to raise_error(ArgumentError)
  44. end
  45. end
  46. # Get Conference Information
  47. 1 describe 'get_conference' do
  48. 1 it 'get a conference by id' do
  49. 1 data, status_code = @conferences_api_instance.get_conference_with_http_info(BW_ACCOUNT_ID, conference_id)
  50. 1 expect(status_code).to eq(200)
  51. 1 expect(data).to be_instance_of(Bandwidth::Conference)
  52. 1 expect(data.id.length).to eq(50)
  53. 1 expect(data.name).to be_instance_of(String)
  54. 1 expect(data.created_time).to be_instance_of(Time)
  55. 1 expect(data.completed_time).to be_instance_of(Time)
  56. 1 expect(data.conference_event_url).to start_with('http')
  57. 1 expect(data.conference_event_method).to be_one_of(Bandwidth::CallbackMethodEnum.all_vars)
  58. 1 expect(data.tag).to be_instance_of(String)
  59. end
  60. 1 it 'causes an ArgumentError for a missing account_id' do
  61. 1 expect {
  62. 1 @conferences_api_instance.get_conference(nil, '')
  63. }.to raise_error(ArgumentError)
  64. end
  65. 1 it 'causes an ArgumentError for a missing conference_id' do
  66. 1 expect {
  67. 1 @conferences_api_instance.get_conference(BW_ACCOUNT_ID, nil)
  68. }.to raise_error(ArgumentError)
  69. end
  70. end
  71. # Get Conference Member
  72. 1 describe 'get_conference_member' do
  73. 1 it 'gets a conference member by call id' do
  74. 1 data, status_code = @conferences_api_instance.get_conference_member_with_http_info(BW_ACCOUNT_ID, conference_id, call_id)
  75. 1 expect(status_code).to eq(200)
  76. 1 expect(data).to be_instance_of(Bandwidth::ConferenceMember)
  77. 1 expect(data.call_id.length).to eq(47)
  78. 1 expect(data.conference_id.length).to eq(50)
  79. 1 expect(data.member_url).to start_with('http')
  80. 1 expect(data.mute).to be_one_of([true, false])
  81. 1 expect(data.hold).to be_one_of([true, false])
  82. 1 expect(data.call_ids_to_coach).to be_instance_of(Array)
  83. end
  84. 1 it 'causes an ArgumentError for a missing account_id' do
  85. 1 expect {
  86. 1 @conferences_api_instance.get_conference_member(nil, '', '')
  87. }.to raise_error(ArgumentError)
  88. end
  89. 1 it 'causes an ArgumentError for a missing conference_id' do
  90. 1 expect {
  91. 1 @conferences_api_instance.get_conference_member(BW_ACCOUNT_ID, nil, '')
  92. }.to raise_error(ArgumentError)
  93. end
  94. 1 it 'causes an ArgumentError for a missing member_id' do
  95. 1 expect {
  96. 1 @conferences_api_instance.get_conference_member(BW_ACCOUNT_ID, '', nil)
  97. }.to raise_error(ArgumentError)
  98. end
  99. end
  100. # Get Conference Recording Information
  101. 1 describe 'get_conference_recording' do
  102. 1 it 'gets a conference recording by id' do
  103. 1 data, status_code = @conferences_api_instance.get_conference_recording_with_http_info(BW_ACCOUNT_ID, conference_id, recording_id)
  104. 1 expect(status_code).to eq(200)
  105. 1 expect(data).to be_instance_of(Bandwidth::ConferenceRecordingMetadata)
  106. 1 expect(data.account_id.length).to eq(7)
  107. 1 expect(data.conference_id.length).to eq(50)
  108. 1 expect(data.name).to be_instance_of(String)
  109. 1 expect(data.recording_id.length).to eq(47)
  110. 1 expect(data.duration).to start_with('PT')
  111. 1 expect(data.channels).to be_instance_of(Integer)
  112. 1 expect(data.start_time).to be_instance_of(Time)
  113. 1 expect(data.end_time).to be_instance_of(Time)
  114. 1 expect(data.file_format).to be_one_of(Bandwidth::FileFormatEnum.all_vars)
  115. 1 expect(data.status).to be_instance_of(String)
  116. 1 expect(data.media_url).to start_with('http')
  117. end
  118. 1 it 'causes an ArgumentError for a missing account_id' do
  119. 1 expect {
  120. 1 @conferences_api_instance.get_conference_recording(nil, '', '')
  121. }.to raise_error(ArgumentError)
  122. end
  123. 1 it 'causes an ArgumentError for a missing conference_id' do
  124. 1 expect {
  125. 1 @conferences_api_instance.get_conference_recording(BW_ACCOUNT_ID, nil, '')
  126. }.to raise_error(ArgumentError)
  127. end
  128. 1 it 'causes an ArgumentError for a missing recording_id' do
  129. 1 expect {
  130. 1 @conferences_api_instance.get_conference_recording(BW_ACCOUNT_ID, '', nil)
  131. }.to raise_error(ArgumentError)
  132. end
  133. end
  134. # List Conference Recordings
  135. 1 describe 'list_conference_recordings' do
  136. 1 it 'lists recordings for a conference' do
  137. 1 data, status_code = @conferences_api_instance.list_conference_recordings_with_http_info(BW_ACCOUNT_ID, conference_id)
  138. 1 expect(status_code).to eq(200)
  139. 1 expect(data).to be_instance_of(Array)
  140. 1 expect(data[0]).to be_instance_of(Bandwidth::ConferenceRecordingMetadata)
  141. 1 expect(data[0].account_id.length).to eq(7)
  142. 1 expect(data[0].conference_id.length).to eq(50)
  143. 1 expect(data[0].name).to be_instance_of(String)
  144. 1 expect(data[0].recording_id.length).to eq(47)
  145. 1 expect(data[0].duration).to start_with('PT')
  146. 1 expect(data[0].channels).to be_instance_of(Integer)
  147. 1 expect(data[0].start_time).to be_instance_of(Time)
  148. 1 expect(data[0].end_time).to be_instance_of(Time)
  149. 1 expect(data[0].file_format).to be_one_of(Bandwidth::FileFormatEnum.all_vars)
  150. 1 expect(data[0].status).to be_instance_of(String)
  151. 1 expect(data[0].media_url).to start_with('http')
  152. end
  153. 1 it 'causes an ArgumentError for a missing account_id' do
  154. 1 expect {
  155. 1 @conferences_api_instance.list_conference_recordings(nil, '')
  156. }.to raise_error(ArgumentError)
  157. end
  158. 1 it 'causes an ArgumentError for a missing conference_id' do
  159. 1 expect {
  160. 1 @conferences_api_instance.list_conference_recordings(BW_ACCOUNT_ID, nil)
  161. }.to raise_error(ArgumentError)
  162. end
  163. end
  164. # List Conferences
  165. 1 describe 'list_conferences' do
  166. 1 it 'list all conferences' do
  167. conference_opts = {
  168. 1 name: call_id
  169. }
  170. 1 data, status_code = @conferences_api_instance.list_conferences_with_http_info(BW_ACCOUNT_ID, conference_opts)
  171. 1 expect(status_code).to eq(200)
  172. 1 expect(data).to be_instance_of(Array)
  173. 1 expect(data[0]).to be_instance_of(Bandwidth::Conference)
  174. 1 expect(data[0].id.length).to eq(50)
  175. 1 expect(data[0].name).to be_instance_of(String)
  176. 1 expect(data[0].created_time).to be_instance_of(Time)
  177. 1 expect(data[0].completed_time).to be_instance_of(Time)
  178. 1 expect(data[0].conference_event_url).to start_with('http')
  179. 1 expect(data[0].conference_event_method).to be_one_of(Bandwidth::CallbackMethodEnum.all_vars)
  180. 1 expect(data[0].tag).to be_instance_of(String)
  181. end
  182. 1 it 'causes an ArgumentError for a missing account_id' do
  183. 1 expect {
  184. 1 @conferences_api_instance.list_conferences(nil, {})
  185. }.to raise_error(ArgumentError)
  186. end
  187. 1 it 'causes an ArgumentError for an invalid page_size' do
  188. 1 expect {
  189. 1 @conferences_api_instance.list_conferences(BW_ACCOUNT_ID, { page_size: 1001 })
  190. }.to raise_error(ArgumentError)
  191. end
  192. 1 it 'causes an ArgumentError for an invalid page_size' do
  193. 1 expect {
  194. 1 @conferences_api_instance.list_conferences(BW_ACCOUNT_ID, { page_size: 0 })
  195. }.to raise_error(ArgumentError)
  196. end
  197. end
  198. # Update Conference
  199. 1 describe 'update_conference' do
  200. 1 it 'updates a conference' do
  201. 1 update_conference_body = Bandwidth::UpdateConference.new(
  202. status: Bandwidth::ConferenceStateEnum::ACTIVE,
  203. redirect_url: BASE_CALLBACK_URL + '/bxml/pause',
  204. redirect_method: Bandwidth::RedirectMethodEnum::POST,
  205. username: 'username',
  206. password: 'password',
  207. redirect_fallback_url: BASE_CALLBACK_URL + '/bxml/pause',
  208. redirect_fallback_method: Bandwidth::RedirectMethodEnum::POST,
  209. fallback_username: 'username',
  210. fallback_password: 'password'
  211. )
  212. 1 _data, status_code = @conferences_api_instance.update_conference_with_http_info(BW_ACCOUNT_ID, conference_id, update_conference_body)
  213. 1 expect(status_code).to eq(204)
  214. end
  215. 1 it 'causes an ArgumentError for a missing account_id' do
  216. 1 expect {
  217. 1 @conferences_api_instance.update_conference(nil, '', '')
  218. }.to raise_error(ArgumentError)
  219. end
  220. 1 it 'causes an ArgumentError for a missing conference_id' do
  221. 1 expect {
  222. 1 @conferences_api_instance.update_conference(BW_ACCOUNT_ID, nil, '')
  223. }.to raise_error(ArgumentError)
  224. end
  225. 1 it 'causes an ArgumentError for a missing update_conference' do
  226. 1 expect {
  227. 1 @conferences_api_instance.update_conference(BW_ACCOUNT_ID, '', nil)
  228. }.to raise_error(ArgumentError)
  229. end
  230. end
  231. # Update Conference BXML
  232. 1 describe 'update_conference_bxml' do
  233. 1 it 'updates a conference using bxml' do
  234. 1 update_bxml = '<?xml version="1.0" encoding="UTF-8"?><Bxml><StartRecording/><SpeakSentence locale="en_US" gender="female" voice="susan">This should be a conference recording.</SpeakSentence><StopRecording/></Bxml>'
  235. 1 _data, status_code = @conferences_api_instance.update_conference_bxml_with_http_info(BW_ACCOUNT_ID, conference_id, update_bxml)
  236. 1 expect(status_code).to eq(204)
  237. end
  238. 1 it 'causes an ArgumentError for a missing account_id' do
  239. 1 expect {
  240. 1 @conferences_api_instance.update_conference_bxml(nil, '', '')
  241. }.to raise_error(ArgumentError)
  242. end
  243. 1 it 'causes an ArgumentError for a missing conference_id' do
  244. 1 expect {
  245. 1 @conferences_api_instance.update_conference_bxml(BW_ACCOUNT_ID, nil, '')
  246. }.to raise_error(ArgumentError)
  247. end
  248. 1 it 'causes an ArgumentError for a missing body' do
  249. 1 expect {
  250. 1 @conferences_api_instance.update_conference_bxml(BW_ACCOUNT_ID, '', nil)
  251. }.to raise_error(ArgumentError)
  252. end
  253. end
  254. # Update Conference Member
  255. 1 describe 'update_conference_member' do
  256. 1 it 'updates a conference member by call id' do
  257. 1 update_conference_member = Bandwidth::UpdateConferenceMember.new(
  258. mute: false
  259. )
  260. 1 _data, status_code = @conferences_api_instance.update_conference_member_with_http_info(BW_ACCOUNT_ID, conference_id, call_id, update_conference_member)
  261. 1 expect(status_code).to eq(204)
  262. end
  263. 1 it 'causes an ArgumentError for a missing account_id' do
  264. 1 expect {
  265. 1 @conferences_api_instance.update_conference_member(nil, '', '', {})
  266. }.to raise_error(ArgumentError)
  267. end
  268. 1 it 'causes an ArgumentError for a missing conference_id' do
  269. 1 expect {
  270. 1 @conferences_api_instance.update_conference_member(BW_ACCOUNT_ID, nil, '', {})
  271. }.to raise_error(ArgumentError)
  272. end
  273. 1 it 'causes an ArgumentError for a missing member_id' do
  274. 1 expect {
  275. 1 @conferences_api_instance.update_conference_member(BW_ACCOUNT_ID, '', nil, {})
  276. }.to raise_error(ArgumentError)
  277. end
  278. 1 it 'causes an ArgumentError for a missing update_conference_member' do
  279. 1 expect {
  280. 1 @conferences_api_instance.update_conference_member(BW_ACCOUNT_ID, '', '', nil)
  281. }.to raise_error(ArgumentError)
  282. end
  283. end
  284. end

spec/unit/api/endpoints_api_spec.rb

100.0% lines covered

100 relevant lines. 100 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::EndpointsApi
  2. 1 describe 'EndpointsApi' do
  3. 4 let(:endpoint_id) { 'ep-abc123' }
  4. 1 before(:all) do
  5. 1 Bandwidth.configure do |config|
  6. 1 config.debugging = true
  7. 1 config.username = BW_USERNAME
  8. 1 config.password = BW_PASSWORD
  9. 1 config.ignore_operation_servers = true
  10. 1 config.host = '127.0.0.1:4010'
  11. end
  12. 1 @endpoints_api_instance = Bandwidth::EndpointsApi.new
  13. end
  14. 1 describe 'test an instance of EndpointsApi' do
  15. 1 it 'should create an instance of EndpointsApi' do
  16. 1 expect(@endpoints_api_instance).to be_instance_of(Bandwidth::EndpointsApi)
  17. end
  18. end
  19. # Create Endpoint
  20. 1 describe '#create_endpoint' do
  21. 1 it 'creates a WebRTC endpoint' do
  22. 1 create_endpoint_body = Bandwidth::CreateWebRtcConnectionRequest.new(
  23. type: Bandwidth::EndpointTypeEnum::WEBRTC,
  24. direction: Bandwidth::EndpointDirectionEnum::BIDIRECTIONAL,
  25. event_callback_url: 'https://myServer.com/bandwidth/webhooks/endpoint',
  26. event_fallback_url: 'https://myFallbackServer.com/bandwidth/webhooks/endpoint',
  27. tag: 'test-endpoint',
  28. connection_metadata: { 'key1' => 'value1', 'key2' => 'value2' }
  29. )
  30. 1 data, status_code = @endpoints_api_instance.create_endpoint_with_http_info(BW_ACCOUNT_ID, create_endpoint_body)
  31. 1 expect(status_code).to eq(201)
  32. 1 expect(data).to be_instance_of(Bandwidth::CreateEndpointResponse)
  33. 1 expect(data.links).to be_instance_of(Array)
  34. 1 expect(data.data).to be_instance_of(Bandwidth::CreateEndpointResponseData)
  35. 1 expect(data.data.endpoint_id).to be_instance_of(String)
  36. 1 expect(data.data.type).to be_one_of(Bandwidth::EndpointTypeEnum.all_vars)
  37. 1 expect(data.data.status).to be_one_of(Bandwidth::EndpointStatusEnum.all_vars)
  38. 1 expect(data.data.creation_timestamp).to be_instance_of(Time)
  39. 1 expect(data.data.expiration_timestamp).to be_instance_of(Time)
  40. 1 expect(data.data.token).to be_instance_of(String)
  41. 1 expect(data.data.tag).to be_instance_of(String)
  42. 1 expect(data.data.devices).to be_instance_of(Array)
  43. 1 expect(data.errors).to be_instance_of(Array)
  44. end
  45. 1 it 'causes an ArgumentError for a missing account_id' do
  46. 1 expect {
  47. 1 @endpoints_api_instance.create_endpoint(nil, {})
  48. }.to raise_error(ArgumentError)
  49. end
  50. 1 it 'causes an ArgumentError for a missing body' do
  51. 1 expect {
  52. 1 @endpoints_api_instance.create_endpoint(BW_ACCOUNT_ID, nil)
  53. }.to raise_error(ArgumentError)
  54. end
  55. end
  56. # List Endpoints
  57. 1 describe '#list_endpoints' do
  58. 1 it 'gets a list of endpoints' do
  59. 1 data, status_code = @endpoints_api_instance.list_endpoints_with_http_info(BW_ACCOUNT_ID)
  60. 1 expect(status_code).to eq(200)
  61. 1 expect(data).to be_instance_of(Bandwidth::ListEndpointsResponse)
  62. 1 expect(data.links).to be_instance_of(Array)
  63. 1 expect(data.page).to be_instance_of(Bandwidth::Page)
  64. 1 expect(data.data).to be_instance_of(Array)
  65. 1 expect(data.data[0]).to be_instance_of(Bandwidth::Endpoints)
  66. 1 expect(data.data[0].endpoint_id).to be_instance_of(String)
  67. 1 expect(data.data[0].type).to be_one_of(Bandwidth::EndpointTypeEnum.all_vars)
  68. 1 expect(data.data[0].status).to be_one_of(Bandwidth::EndpointStatusEnum.all_vars)
  69. 1 expect(data.data[0].creation_timestamp).to be_instance_of(Time)
  70. 1 expect(data.data[0].expiration_timestamp).to be_instance_of(Time)
  71. 1 expect(data.data[0].tag).to be_instance_of(String)
  72. 1 expect(data.errors).to be_instance_of(Array)
  73. end
  74. 1 it 'causes an ArgumentError for a missing account_id' do
  75. 1 expect {
  76. 1 @endpoints_api_instance.list_endpoints(nil)
  77. }.to raise_error(ArgumentError)
  78. end
  79. end
  80. # Get Endpoint
  81. 1 describe '#get_endpoint' do
  82. 1 it 'gets an endpoint' do
  83. 1 data, status_code = @endpoints_api_instance.get_endpoint_with_http_info(BW_ACCOUNT_ID, endpoint_id)
  84. 1 expect(status_code).to eq(200)
  85. 1 expect(data).to be_instance_of(Bandwidth::EndpointResponse)
  86. 1 expect(data.links).to be_instance_of(Array)
  87. 1 expect(data.data).to be_instance_of(Bandwidth::Endpoint)
  88. 1 expect(data.data.endpoint_id).to be_instance_of(String)
  89. 1 expect(data.data.type).to be_one_of(Bandwidth::EndpointTypeEnum.all_vars)
  90. 1 expect(data.data.status).to be_one_of(Bandwidth::EndpointStatusEnum.all_vars)
  91. 1 expect(data.data.creation_timestamp).to be_instance_of(Time)
  92. 1 expect(data.data.expiration_timestamp).to be_instance_of(Time)
  93. 1 expect(data.data.tag).to be_instance_of(String)
  94. 1 expect(data.data.devices).to be_instance_of(Array)
  95. 1 expect(data.errors).to be_instance_of(Array)
  96. end
  97. 1 it 'causes an ArgumentError for a missing account_id' do
  98. 1 expect {
  99. 1 @endpoints_api_instance.get_endpoint(nil, '')
  100. }.to raise_error(ArgumentError)
  101. end
  102. 1 it 'causes an ArgumentError for a missing endpoint_id' do
  103. 1 expect {
  104. 1 @endpoints_api_instance.get_endpoint(BW_ACCOUNT_ID, nil)
  105. }.to raise_error(ArgumentError)
  106. end
  107. end
  108. # Update Endpoint BXML
  109. 1 describe '#update_endpoint_bxml' do
  110. 1 it 'updates an endpoint using bxml' do
  111. 1 update_bxml = "<?xml version='1.0' encoding='UTF-8'?><Bxml><SpeakSentence>Hello</SpeakSentence></Bxml>"
  112. 1 _data, status_code = @endpoints_api_instance.update_endpoint_bxml_with_http_info(BW_ACCOUNT_ID, endpoint_id, update_bxml)
  113. 1 expect(status_code).to eq(204)
  114. end
  115. 1 it 'causes an ArgumentError for a missing account_id' do
  116. 1 expect {
  117. 1 @endpoints_api_instance.update_endpoint_bxml(nil, '', {})
  118. }.to raise_error(ArgumentError)
  119. end
  120. 1 it 'causes an ArgumentError for a missing endpoint_id' do
  121. 1 expect {
  122. 1 @endpoints_api_instance.update_endpoint_bxml(BW_ACCOUNT_ID, nil, {})
  123. }.to raise_error(ArgumentError)
  124. end
  125. 1 it 'causes an ArgumentError for a missing body' do
  126. 1 expect {
  127. 1 @endpoints_api_instance.update_endpoint_bxml(BW_ACCOUNT_ID, '', nil)
  128. }.to raise_error(ArgumentError)
  129. end
  130. end
  131. # Delete Endpoint
  132. 1 describe '#delete_endpoint' do
  133. 1 it 'deletes an endpoint' do
  134. 1 _data, status_code = @endpoints_api_instance.delete_endpoint_with_http_info(BW_ACCOUNT_ID, endpoint_id)
  135. 1 expect(status_code).to eq(204)
  136. end
  137. 1 it 'causes an ArgumentError for a missing account_id' do
  138. 1 expect {
  139. 1 @endpoints_api_instance.delete_endpoint(nil, '')
  140. }.to raise_error(ArgumentError)
  141. end
  142. 1 it 'causes an ArgumentError for a missing endpoint_id' do
  143. 1 expect {
  144. 1 @endpoints_api_instance.delete_endpoint(BW_ACCOUNT_ID, nil)
  145. }.to raise_error(ArgumentError)
  146. end
  147. end
  148. end

spec/unit/api/media_api_spec.rb

100.0% lines covered

61 relevant lines. 61 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MediaApi
  2. 1 describe 'MediaApi' do
  3. # media info
  4. 4 let(:media_name) { 'ruby_media.jpeg' }
  5. 2 let(:media_file_data) { File.open('spec/fixtures/ruby_cat.jpeg').read }
  6. 1 before(:all) do
  7. 1 Bandwidth.configure do |config|
  8. 1 config.debugging = true
  9. 1 config.username = BW_USERNAME
  10. 1 config.password = BW_PASSWORD
  11. 1 config.ignore_operation_servers = true
  12. 1 config.return_binary_data = true
  13. 1 config.host = '127.0.0.1:4010'
  14. end
  15. 1 @media_api_instance = Bandwidth::MediaApi.new
  16. end
  17. 1 describe 'test an instance of MediaApi' do
  18. 1 it 'should create an instance of MediaApi' do
  19. 1 expect(@media_api_instance).to be_instance_of(Bandwidth::MediaApi)
  20. end
  21. end
  22. # Delete Media
  23. 1 describe 'delete_media' do
  24. 1 it 'deletes the binary media' do
  25. 1 _data, status_code = @media_api_instance.delete_media_with_http_info(BW_ACCOUNT_ID, media_name)
  26. 1 expect(status_code).to eq(204)
  27. end
  28. 1 it 'causes an ArgumentError for a missing account_id' do
  29. 1 expect {
  30. 1 @media_api_instance.delete_media(nil, '')
  31. }.to raise_error(ArgumentError)
  32. end
  33. 1 it 'causes an ArgumentError for a missing media_id' do
  34. 1 expect {
  35. 1 @media_api_instance.delete_media(BW_ACCOUNT_ID, nil)
  36. }.to raise_error(ArgumentError)
  37. end
  38. end
  39. # Get Media
  40. 1 describe 'get_media' do
  41. 1 it 'gets uploaded binary media' do
  42. 1 data, status_code = @media_api_instance.get_media_with_http_info(
  43. BW_ACCOUNT_ID, media_name, { header_params: { 'Accept' => 'application/octet-stream' } })
  44. 1 expect(status_code).to eq(200)
  45. 1 expect(data).to be_instance_of(String)
  46. end
  47. 1 it 'causes an ArgumentError for a missing account_id' do
  48. 1 expect {
  49. 1 @media_api_instance.get_media(nil, '')
  50. }.to raise_error(ArgumentError)
  51. end
  52. 1 it 'causes an ArgumentError for a missing media_id' do
  53. 1 expect {
  54. 1 @media_api_instance.get_media(BW_ACCOUNT_ID, nil)
  55. }.to raise_error(ArgumentError)
  56. end
  57. end
  58. # List Media
  59. 1 describe 'list_media' do
  60. 1 it 'lists media' do
  61. 1 data, status_code = @media_api_instance.list_media_with_http_info(BW_ACCOUNT_ID)
  62. 1 expect(status_code).to eq(200)
  63. 1 expect(data).to be_instance_of(Array)
  64. 1 expect(data[0]).to be_instance_of(Bandwidth::Media)
  65. 1 expect(data[0].content).to be_instance_of(String)
  66. 1 expect(data[0].content_length).to be_instance_of(Integer)
  67. 1 expect(data[0].media_name).to be_instance_of(String)
  68. end
  69. 1 it 'causes an ArgumentError for a missing account_id' do
  70. 1 expect {
  71. 1 @media_api_instance.list_media(nil)
  72. }.to raise_error(ArgumentError)
  73. end
  74. end
  75. # Upload Media
  76. 1 describe 'upload_media' do
  77. 1 it 'uploads media' do
  78. 1 _data, status_code = @media_api_instance.upload_media_with_http_info(
  79. BW_ACCOUNT_ID, media_name, media_file_data, { content_type: 'image/jpeg' })
  80. 1 expect(status_code).to eq(204)
  81. end
  82. 1 it 'causes an ArgumentError for a missing account_id' do
  83. 1 expect {
  84. 1 @media_api_instance.upload_media(nil, '', '')
  85. }.to raise_error(ArgumentError)
  86. end
  87. 1 it 'causes an ArgumentError for a missing media_id' do
  88. 1 expect {
  89. 1 @media_api_instance.upload_media(BW_ACCOUNT_ID, nil, '')
  90. }.to raise_error(ArgumentError)
  91. end
  92. 1 it 'causes an ArgumentError for a missing body' do
  93. 1 expect {
  94. 1 @media_api_instance.upload_media(BW_ACCOUNT_ID, '', nil)
  95. }.to raise_error(ArgumentError)
  96. end
  97. end
  98. end

spec/unit/api/messages_api_spec.rb

100.0% lines covered

77 relevant lines. 77 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MessagesApi
  2. 1 describe 'MessagesApi' do
  3. 1 before(:all) do
  4. 1 Bandwidth.configure do |config|
  5. 1 config.debugging = true
  6. 1 config.username = BW_USERNAME
  7. 1 config.password = BW_PASSWORD
  8. 1 config.ignore_operation_servers = true
  9. 1 config.host = '127.0.0.1:4010'
  10. end
  11. 1 @messaging_api_instance = Bandwidth::MessagesApi.new
  12. end
  13. 1 describe 'test an instance of MessagesApi' do
  14. 1 it 'should create an instance of MessagesApi' do
  15. 1 expect(@messaging_api_instance).to be_instance_of(Bandwidth::MessagesApi)
  16. end
  17. end
  18. # Create Message
  19. 1 describe 'create_message' do
  20. 1 it 'creates a message' do
  21. 1 message_request = Bandwidth::MessageRequest.new(
  22. application_id: BW_MESSAGING_APPLICATION_ID,
  23. to: [USER_NUMBER],
  24. from: BW_NUMBER,
  25. text: 'Hello',
  26. )
  27. 1 data, status_code = @messaging_api_instance.create_message_with_http_info(BW_ACCOUNT_ID, message_request)
  28. 1 expect(status_code).to eq(202)
  29. 1 expect(data).to be_instance_of(Bandwidth::Message)
  30. 1 expect(data.id.length).to eq(29)
  31. 1 expect(data.owner.length).to eq(12)
  32. 1 expect(data.application_id.length).to eq(36)
  33. 1 expect(data.time).to be_instance_of(Time)
  34. 1 expect(data.segment_count).to be_instance_of(Integer)
  35. 1 expect(data.direction).to be_one_of(Bandwidth::MessageDirectionEnum.all_vars)
  36. 1 expect(data.to).to be_instance_of(Array)
  37. 1 expect(data.to[0].length).to eq(12)
  38. 1 expect(data.from.length).to eq(12)
  39. 1 expect(data.media).to be_instance_of(Array)
  40. 1 expect(data.media[0]).to start_with('http')
  41. 1 expect(data.text).to be_instance_of(String)
  42. 1 expect(data.tag).to be_instance_of(String)
  43. 1 expect(data.priority).to be_one_of(Bandwidth::PriorityEnum.all_vars)
  44. 1 expect(data.expiration).to be_instance_of(Time)
  45. end
  46. 1 it 'causes an ArgumentError for a missing account_id' do
  47. 1 expect {
  48. 1 @messaging_api_instance.create_message(nil, {})
  49. }.to raise_error(ArgumentError)
  50. end
  51. 1 it 'causes an ArgumentError for a missing message_request' do
  52. 1 expect {
  53. 1 @messaging_api_instance.create_message(BW_ACCOUNT_ID, nil)
  54. }.to raise_error(ArgumentError)
  55. end
  56. end
  57. # List Messages
  58. 1 describe 'list_messages' do
  59. 1 it 'lists messages' do
  60. 1 data, status_code = @messaging_api_instance.list_messages_with_http_info(BW_ACCOUNT_ID)
  61. 1 expect(status_code).to eq(200)
  62. 1 expect(data).to be_instance_of(Bandwidth::MessagesList)
  63. 1 expect(data.total_count).to be_instance_of(Integer)
  64. 1 expect(data.page_info).to be_instance_of(Bandwidth::PageInfo)
  65. 1 expect(data.page_info.prev_page).to start_with('http')
  66. 1 expect(data.page_info.next_page).to start_with('http')
  67. 1 expect(data.page_info.prev_page_token).to be_instance_of(String)
  68. 1 expect(data.page_info.next_page_token).to be_instance_of(String)
  69. 1 expect(data.messages).to be_instance_of(Array)
  70. 1 expect(data.messages[0]).to be_instance_of(Bandwidth::ListMessageItem)
  71. 1 expect(data.messages[0].message_id.length).to eq(29)
  72. 1 expect(data.messages[0].account_id.length).to eq(7)
  73. 1 expect(data.messages[0].source_tn.length).to eq(12)
  74. 1 expect(data.messages[0].destination_tn.length).to eq(12)
  75. 1 expect(data.messages[0].message_status).to be_one_of(Bandwidth::MessageStatusEnum.all_vars)
  76. 1 expect(data.messages[0].message_direction).to be_one_of(Bandwidth::ListMessageDirectionEnum.all_vars)
  77. 1 expect(data.messages[0].message_type).to be_one_of(Bandwidth::MessageTypeEnum.all_vars)
  78. 1 expect(data.messages[0].segment_count).to be_instance_of(Integer)
  79. 1 expect(data.messages[0].error_code).to be_instance_of(Integer)
  80. 1 expect(data.messages[0].receive_time).to be_instance_of(Time)
  81. 1 expect(data.messages[0].carrier_name).to be_instance_of(String)
  82. 1 expect(data.messages[0].message_size).to be_instance_of(Integer)
  83. 1 expect(data.messages[0].message_length).to be_instance_of(Integer)
  84. 1 expect(data.messages[0].attachment_count).to be_instance_of(Integer)
  85. 1 expect(data.messages[0].recipient_count).to be_instance_of(Integer)
  86. 1 expect(data.messages[0].campaign_class).to be_instance_of(String)
  87. 1 expect(data.messages[0].campaign_id).to be_instance_of(String)
  88. 1 expect(data.messages[0].bw_latency).to be_instance_of(Integer)
  89. 1 expect(data.messages[0].calling_number_country_a3).to be_instance_of(String)
  90. 1 expect(data.messages[0].called_number_country_a3).to be_instance_of(String)
  91. 1 expect(data.messages[0].product).to be_one_of(Bandwidth::ProductTypeEnum.all_vars)
  92. 1 expect(data.messages[0].location).to be_instance_of(String)
  93. end
  94. 1 it 'causes an ArgumentError for a missing account_id' do
  95. 1 expect {
  96. 1 @messaging_api_instance.list_messages(nil)
  97. }.to raise_error(ArgumentError)
  98. end
  99. end
  100. end

spec/unit/api/mfa_api_spec.rb

100.0% lines covered

53 relevant lines. 53 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MFAApi
  2. 1 describe 'MFAApi' do
  3. 3 let(:message) { 'Your temporary {NAME} {SCOPE} code is: {CODE}' }
  4. 3 let(:digits) { 6 }
  5. 1 before(:all) do
  6. 1 Bandwidth.configure do |config|
  7. 1 config.debugging = true
  8. 1 config.username = BW_USERNAME
  9. 1 config.password = BW_PASSWORD
  10. 1 config.ignore_operation_servers = true
  11. 1 config.host = '127.0.0.1:4010'
  12. end
  13. 1 @mfa_api_instance = Bandwidth::MFAApi.new
  14. end
  15. 1 describe 'test an instance of MFAApi' do
  16. 1 it 'should create an instance of MFAApi' do
  17. 1 expect(@mfa_api_instance).to be_instance_of(Bandwidth::MFAApi)
  18. end
  19. end
  20. # Messaging Authentication Code
  21. 1 describe 'generate_messaging_code' do
  22. 1 it 'generates messaging mfa code' do
  23. 1 req_schema = Bandwidth::CodeRequest.new(
  24. to: USER_NUMBER,
  25. from: BW_NUMBER,
  26. application_id: BW_MESSAGING_APPLICATION_ID,
  27. message: message,
  28. digits: digits
  29. )
  30. 1 data, status_code = @mfa_api_instance.generate_messaging_code_with_http_info(BW_ACCOUNT_ID, req_schema)
  31. 1 expect(status_code).to eq(200)
  32. 1 expect(data).to be_instance_of(Bandwidth::MessagingCodeResponse)
  33. 1 expect(data.message_id.length).to eq(29)
  34. end
  35. 1 it 'causes an ArgumentError for a missing account_id' do
  36. 1 expect {
  37. 1 @mfa_api_instance.generate_messaging_code(nil, {})
  38. }.to raise_error(ArgumentError)
  39. end
  40. 1 it 'causes an ArgumentError for a missing code_request' do
  41. 1 expect {
  42. 1 @mfa_api_instance.generate_messaging_code(BW_ACCOUNT_ID, nil)
  43. }.to raise_error(ArgumentError)
  44. end
  45. end
  46. # Voice Authentication Code
  47. 1 describe 'generate_voice_code' do
  48. 1 it 'generates voice mfa code' do
  49. 1 req_schema = Bandwidth::CodeRequest.new(
  50. to: USER_NUMBER,
  51. from: BW_NUMBER,
  52. application_id: BW_VOICE_APPLICATION_ID,
  53. message: message,
  54. digits: digits
  55. )
  56. 1 data, status_code = @mfa_api_instance.generate_voice_code_with_http_info(BW_ACCOUNT_ID, req_schema)
  57. 1 expect(status_code).to eq(200)
  58. 1 expect(data).to be_instance_of(Bandwidth::VoiceCodeResponse)
  59. 1 expect(data.call_id.length).to eq(47)
  60. end
  61. 1 it 'causes an ArgumentError for a missing account_id' do
  62. 1 expect {
  63. 1 @mfa_api_instance.generate_voice_code(nil, {})
  64. }.to raise_error(ArgumentError)
  65. end
  66. 1 it 'causes an ArgumentError for a missing code_request' do
  67. 1 expect {
  68. 1 @mfa_api_instance.generate_voice_code(BW_ACCOUNT_ID, nil)
  69. }.to raise_error(ArgumentError)
  70. end
  71. end
  72. # Verify Authentication Code
  73. 1 describe 'verify_code' do
  74. 1 it 'verifies mfa code' do
  75. 1 req_schema = Bandwidth::VerifyCodeRequest.new(
  76. to: USER_NUMBER,
  77. scope: '2FA',
  78. expiration_time_in_minutes: 3,
  79. code: '12345'
  80. )
  81. 1 data, status_code = @mfa_api_instance.verify_code_with_http_info(BW_ACCOUNT_ID, req_schema)
  82. 1 expect(status_code).to eq(200)
  83. 1 expect(data).to be_instance_of(Bandwidth::VerifyCodeResponse)
  84. 1 expect(data.valid).to be_one_of([true, false])
  85. end
  86. 1 it 'causes an ArgumentError for a missing account_id' do
  87. 1 expect {
  88. 1 @mfa_api_instance.verify_code(nil, {})
  89. }.to raise_error(ArgumentError)
  90. end
  91. 1 it 'causes an ArgumentError for a missing verify_code_request' do
  92. 1 expect {
  93. 1 @mfa_api_instance.verify_code(BW_ACCOUNT_ID, nil)
  94. }.to raise_error(ArgumentError)
  95. end
  96. end
  97. end

spec/unit/api/multi_channel_api_spec.rb

100.0% lines covered

36 relevant lines. 36 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MultiChannelApi
  2. 1 describe 'MultiChannelApi' do
  3. 1 before(:all) do
  4. 1 Bandwidth.configure do |config|
  5. 1 config.debugging = true
  6. 1 config.username = BW_USERNAME
  7. 1 config.password = BW_PASSWORD
  8. 1 config.ignore_operation_servers = true
  9. 1 config.host = '127.0.0.1:4010'
  10. end
  11. 1 @multi_channel_api_instance = Bandwidth::MultiChannelApi.new
  12. 1 @expiration_time = (Time.now + 60).round.to_datetime.rfc3339
  13. end
  14. 1 describe 'test an instance of MultiChannelApi' do
  15. 1 it 'should create an instance of MultiChannelApi' do
  16. 1 expect(@multi_channel_api_instance).to be_instance_of(Bandwidth::MultiChannelApi)
  17. end
  18. end
  19. # Create Multi-Channel Message
  20. 1 describe 'create_multi_channel_message' do
  21. 1 it 'creates a multi channel message' do
  22. 1 message_body = Bandwidth::MultiChannelChannelListSMSObject.new(
  23. from: BW_NUMBER,
  24. application_id: BW_MESSAGING_APPLICATION_ID,
  25. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS,
  26. content: Bandwidth::SmsMessageContent.new(
  27. text: 'Hello, this is a test message.',
  28. )
  29. )
  30. 1 multi_channel_message_request = Bandwidth::MultiChannelMessageRequest.new(
  31. to: USER_NUMBER,
  32. channel_list: [message_body],
  33. tag: 'tag',
  34. priority: 'high',
  35. expiration: @expiration_time,
  36. )
  37. 1 data, status_code = @multi_channel_api_instance.create_multi_channel_message_with_http_info(BW_ACCOUNT_ID, multi_channel_message_request)
  38. 1 expect(status_code).to eq(202)
  39. 1 expect(data).to be_instance_of(Bandwidth::CreateMultiChannelMessageResponse)
  40. 1 expect(data.links).to be_instance_of(Array)
  41. 1 expect(data.data).to be_instance_of(Bandwidth::MultiChannelMessageResponseData)
  42. 1 expect(data.data.id).to be_instance_of(String)
  43. 1 expect(data.data.time).to be_instance_of(Time)
  44. 1 expect(data.data.direction).to be_one_of(Bandwidth::MessageDirectionEnum.all_vars)
  45. 1 expect(data.data.to).to be_instance_of(Array)
  46. 1 expect(data.data.tag).to be_instance_of(String)
  47. 1 expect(data.data.priority).to be_one_of(Bandwidth::PriorityEnum.all_vars)
  48. 1 expect(data.data.expiration).to be_instance_of(Time)
  49. 1 expect(data.data.channel_list).to be_instance_of(Array)
  50. end
  51. 1 it 'causes an ArgumentError for a missing account_id' do
  52. 1 expect {
  53. 1 @multi_channel_api_instance.create_multi_channel_message(nil, {})
  54. }.to raise_error(ArgumentError)
  55. end
  56. 1 it 'causes an ArgumentError for a missing message_request' do
  57. 1 expect {
  58. 1 @multi_channel_api_instance.create_multi_channel_message(BW_ACCOUNT_ID, nil)
  59. }.to raise_error(ArgumentError)
  60. end
  61. end
  62. end

spec/unit/api/phone_number_lookup_api_spec.rb

100.0% lines covered

84 relevant lines. 84 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::PhoneNumberLookupApi
  2. 1 describe 'PhoneNumberLookupApi' do
  3. 5 let(:phone_numbers) { [BW_NUMBER, USER_NUMBER] }
  4. 3 let(:request_id) { '123e4567-e89b-12d3-a456-426614174000' }
  5. 3 let(:rcs_agent) { 'TestAgent' }
  6. 1 before(:all) do
  7. 1 Bandwidth.configure do |config|
  8. 1 config.debugging = true
  9. 1 config.username = BW_USERNAME
  10. 1 config.password = BW_PASSWORD
  11. 1 config.ignore_operation_servers = true
  12. 1 config.host = '127.0.0.1:4010'
  13. end
  14. 1 @api_instance = Bandwidth::PhoneNumberLookupApi.new
  15. end
  16. 1 describe 'test an instance of PhoneNumberLookupApi' do
  17. 1 it 'should create an instance of PhoneNumberLookupApi' do
  18. 1 expect(@api_instance).to be_instance_of(Bandwidth::PhoneNumberLookupApi)
  19. end
  20. end
  21. # Create Asynchronous Bulk Number Lookup
  22. 1 describe 'create_async_bulk_lookup test' do
  23. 1 it 'should work' do
  24. 1 request = Bandwidth::AsyncLookupRequest.new(
  25. phone_numbers: phone_numbers,
  26. )
  27. 1 data, status_code = @api_instance.create_async_bulk_lookup_with_http_info(BW_ACCOUNT_ID, request)
  28. 1 expect(status_code).to eq(202)
  29. 1 expect(data).to be_instance_of(Bandwidth::CreateAsyncBulkLookupResponse)
  30. 1 expect(data.links[0]).to be_instance_of(Bandwidth::LinkSchema)
  31. 1 expect(data.links[0].rel).to be_instance_of(String)
  32. 1 expect(data.links[0].href).to be_instance_of(String)
  33. 1 expect(data.links[0].method).to be_instance_of(String)
  34. 1 expect(data.data).to be_instance_of(Bandwidth::CreateAsyncBulkLookupResponseData)
  35. 1 expect(data.data.request_id).to be_instance_of(String)
  36. 1 expect(data.data.status).to eq(Bandwidth::InProgressLookupStatusEnum::IN_PROGRESS)
  37. 1 expect(data.errors).to be_instance_of(Array)
  38. end
  39. 1 it 'causes an ArgumentError for a missing account_id' do
  40. 1 expect {
  41. 1 @api_instance.create_async_bulk_lookup(nil, Bandwidth::AsyncLookupRequest.new(phone_numbers: phone_numbers))
  42. }.to raise_error(ArgumentError)
  43. end
  44. 1 it 'causes an ArgumentError for a missing async_lookup_request' do
  45. 1 expect {
  46. 1 @api_instance.create_async_bulk_lookup(BW_ACCOUNT_ID, nil)
  47. }.to raise_error(ArgumentError)
  48. end
  49. end
  50. # Create Synchronous Number Lookup
  51. 1 describe 'create_sync_lookup test' do
  52. 1 it 'should work' do
  53. 1 request = Bandwidth::SyncLookupRequest.new(
  54. phone_numbers: phone_numbers,
  55. rcs_agent: rcs_agent,
  56. )
  57. 1 data, status_code = @api_instance.create_sync_lookup_with_http_info(BW_ACCOUNT_ID, request)
  58. 1 expect(status_code).to eq(200)
  59. 1 expect(data).to be_instance_of(Bandwidth::CreateSyncLookupResponse)
  60. 1 expect(data.data.request_id).to be_instance_of(String)
  61. 1 expect(data.data.status).to eq(Bandwidth::CompletedLookupStatusEnum::COMPLETE)
  62. 1 expect(data.data.results).to be_instance_of(Array)
  63. 1 expect(data.data.results[0]).to be_instance_of(Bandwidth::LookupResult)
  64. 1 expect(data.data.results[0].phone_number).to be_instance_of(String)
  65. 1 expect(data.data.results[0].line_type).to eq(Bandwidth::LineTypeEnum::MOBILE)
  66. 1 expect(data.data.results[0].messaging_provider).to be_instance_of(String)
  67. 1 expect(data.data.results[0].voice_provider).to be_instance_of(String)
  68. 1 expect(data.data.results[0].country_code_a3).to be_instance_of(String)
  69. 1 expect(data.data.results[0].latest_message_delivery_status).to eq(Bandwidth::LatestMessageDeliveryStatusEnum::ACTIVE)
  70. 1 expect(data.data.results[0].initial_message_delivery_status_date).to be_instance_of(Date)
  71. 1 expect(data.data.results[0].latest_message_delivery_status_date).to be_instance_of(Date)
  72. 1 expect(data.errors).to be_instance_of(Array)
  73. end
  74. 1 it 'causes an ArgumentError for a missing account_id' do
  75. 1 expect {
  76. 1 @api_instance.create_sync_lookup(nil, Bandwidth::SyncLookupRequest.new(phone_numbers: phone_numbers, rcs_agent: rcs_agent))
  77. }.to raise_error(ArgumentError)
  78. end
  79. 1 it 'causes an ArgumentError for a missing sync_lookup_request' do
  80. 1 expect {
  81. 1 @api_instance.create_sync_lookup(BW_ACCOUNT_ID, nil)
  82. }.to raise_error(ArgumentError)
  83. end
  84. end
  85. # Get Asynchronous Bulk Number Lookup
  86. 1 describe 'get_async_bulk_lookup test' do
  87. 1 it 'should work' do
  88. 1 data, status_code = @api_instance.get_async_bulk_lookup_with_http_info(BW_ACCOUNT_ID, request_id)
  89. 1 expect(status_code).to eq(200)
  90. 1 expect(data).to be_instance_of(Bandwidth::GetAsyncBulkLookupResponse)
  91. 1 expect(data.data.request_id).to be_instance_of(String)
  92. 1 expect(data.data.status).to eq(Bandwidth::InProgressLookupStatusEnum::COMPLETE)
  93. 1 expect(data.data.results).to be_instance_of(Array)
  94. 1 expect(data.data.results[0]).to be_instance_of(Bandwidth::LookupResult)
  95. 1 expect(data.data.results[0].phone_number).to be_instance_of(String)
  96. 1 expect(data.data.results[0].line_type).to eq(Bandwidth::LineTypeEnum::MOBILE)
  97. 1 expect(data.data.results[0].messaging_provider).to be_instance_of(String)
  98. 1 expect(data.data.results[0].voice_provider).to be_instance_of(String)
  99. 1 expect(data.data.results[0].country_code_a3).to be_instance_of(String)
  100. 1 expect(data.data.results[0].latest_message_delivery_status).to eq(Bandwidth::LatestMessageDeliveryStatusEnum::ACTIVE)
  101. 1 expect(data.data.results[0].initial_message_delivery_status_date).to be_instance_of(Date)
  102. 1 expect(data.data.results[0].latest_message_delivery_status_date).to be_instance_of(Date)
  103. 1 expect(data.errors).to be_instance_of(Array)
  104. end
  105. 1 it 'causes an ArgumentError for a missing account_id' do
  106. 1 expect {
  107. 1 @api_instance.get_async_bulk_lookup(nil, request_id)
  108. }.to raise_error(ArgumentError)
  109. end
  110. 1 it 'causes an ArgumentError for a missing request_id' do
  111. 1 expect {
  112. 1 @api_instance.get_async_bulk_lookup(BW_ACCOUNT_ID, nil)
  113. }.to raise_error(ArgumentError)
  114. end
  115. end
  116. end

spec/unit/api/recordings_api_spec.rb

100.0% lines covered

194 relevant lines. 194 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RecordingsApi
  2. 1 describe 'RecordingsApi' do
  3. 9 let(:call_id) { 'c-1234' }
  4. 7 let(:recording_id) { 'r-1234' }
  5. 1 before(:all) do
  6. 1 Bandwidth.configure do |config|
  7. 1 config.debugging = true
  8. 1 config.username = BW_USERNAME
  9. 1 config.password = BW_PASSWORD
  10. 1 config.return_binary_data = true
  11. 1 config.ignore_operation_servers = true
  12. 1 config.host = '127.0.0.1:4010'
  13. end
  14. 1 @recordings_api_instance = Bandwidth::RecordingsApi.new
  15. end
  16. 1 describe 'test an instance of RecordingsApi' do
  17. 1 it 'should create an instance of RecordingsApi' do
  18. 1 expect(@recordings_api_instance).to be_instance_of(Bandwidth::RecordingsApi)
  19. end
  20. end
  21. # Delete Recording Transcription
  22. 1 describe 'delete_recording_transcription' do
  23. 1 it 'deletes the completed call recording transcription' do
  24. 1 _data, status_code = @recordings_api_instance.delete_recording_transcription_with_http_info(BW_ACCOUNT_ID, call_id, recording_id)
  25. 1 expect(status_code).to eq(204)
  26. end
  27. 1 it 'causes an ArgumentError for a missing account_id' do
  28. 1 expect {
  29. 1 @recordings_api_instance.delete_recording_transcription(nil, '', '')
  30. }.to raise_error(ArgumentError)
  31. end
  32. 1 it 'causes an ArgumentError for a missing call_id' do
  33. 1 expect {
  34. 1 @recordings_api_instance.delete_recording_transcription(BW_ACCOUNT_ID, nil, '')
  35. }.to raise_error(ArgumentError)
  36. end
  37. 1 it 'causes an ArgumentError for a missing recording_id' do
  38. 1 expect {
  39. 1 @recordings_api_instance.delete_recording_transcription(BW_ACCOUNT_ID, '', nil)
  40. }.to raise_error(ArgumentError)
  41. end
  42. end
  43. # Delete Recording
  44. 1 describe 'delete_recording' do
  45. 1 it 'deletes the completed call recording data' do
  46. 1 _data, status_code = @recordings_api_instance.delete_recording_with_http_info(BW_ACCOUNT_ID, call_id, recording_id)
  47. 1 expect(status_code).to eq(204)
  48. end
  49. 1 it 'causes an ArgumentError for a missing account_id' do
  50. 1 expect {
  51. 1 @recordings_api_instance.delete_recording(nil, '', '')
  52. }.to raise_error(ArgumentError)
  53. end
  54. 1 it 'causes an ArgumentError for a missing call_id' do
  55. 1 expect {
  56. 1 @recordings_api_instance.delete_recording(BW_ACCOUNT_ID, nil, '')
  57. }.to raise_error(ArgumentError)
  58. end
  59. 1 it 'causes an ArgumentError for a missing recording_id' do
  60. 1 expect {
  61. 1 @recordings_api_instance.delete_recording(BW_ACCOUNT_ID, '', nil)
  62. }.to raise_error(ArgumentError)
  63. end
  64. end
  65. # Delete Recording Media
  66. 1 describe 'delete_recording_media' do
  67. 1 it 'deletes the completed call recording media' do
  68. 1 _data, status_code = @recordings_api_instance.delete_recording_media_with_http_info(BW_ACCOUNT_ID, call_id, recording_id)
  69. 1 expect(status_code).to eq(204)
  70. end
  71. 1 it 'causes an ArgumentError for a missing account_id' do
  72. 1 expect {
  73. 1 @recordings_api_instance.delete_recording_media(nil, '', '')
  74. }.to raise_error(ArgumentError)
  75. end
  76. 1 it 'causes an ArgumentError for a missing call_id' do
  77. 1 expect {
  78. 1 @recordings_api_instance.delete_recording_media(BW_ACCOUNT_ID, nil, '')
  79. }.to raise_error(ArgumentError)
  80. end
  81. 1 it 'causes an ArgumentError for a missing recording_id' do
  82. 1 expect {
  83. 1 @recordings_api_instance.delete_recording_media(BW_ACCOUNT_ID, '', nil)
  84. }.to raise_error(ArgumentError)
  85. end
  86. end
  87. # Download Recording
  88. 1 describe 'download_call_recording' do
  89. 1 it 'downloads a call recording by id' do
  90. 1 data, status_code = @recordings_api_instance.download_call_recording_with_http_info(
  91. BW_ACCOUNT_ID, call_id, recording_id, { header_params: { 'Accept' => 'audio/vnd.wave' } })
  92. 1 expect(status_code).to eq(200)
  93. 1 expect(data).to be_instance_of(String)
  94. end
  95. 1 it 'causes an ArgumentError for a missing account_id' do
  96. 1 expect {
  97. 1 @recordings_api_instance.download_call_recording(nil, '', '')
  98. }.to raise_error(ArgumentError)
  99. end
  100. 1 it 'causes an ArgumentError for a missing call_id' do
  101. 1 expect {
  102. 1 @recordings_api_instance.download_call_recording(BW_ACCOUNT_ID, nil, '')
  103. }.to raise_error(ArgumentError)
  104. end
  105. 1 it 'causes an ArgumentError for a missing recording_id' do
  106. 1 expect {
  107. 1 @recordings_api_instance.download_call_recording(BW_ACCOUNT_ID, '', nil)
  108. }.to raise_error(ArgumentError)
  109. end
  110. end
  111. # Get Call Recording
  112. 1 describe 'get_call_recording' do
  113. it 'gets a call recording by id' do
  114. data, status_code = @recordings_api_instance.get_call_recording_with_http_info(BW_ACCOUNT_ID, call_id, recording_id)
  115. expect(status_code).to eq(200)
  116. expect(data).to be_instance_of(Bandwidth::CallRecordingMetadata)
  117. expect(data.application_id.length).to eq(36)
  118. expect(data.account_id.length).to eq(7)
  119. expect(data.call_id.length).to eq(47)
  120. expect(data.parent_call_id.length).to eq(47)
  121. expect(data.recording_id.length).to eq(47)
  122. expect(data.to.length).to eq(12)
  123. expect(data.from.length).to eq(12)
  124. expect(data.transfer_caller_id.length).to eq(12)
  125. expect(data.transfer_to.length).to eq(12)
  126. expect(data.duration).to start_with('PT')
  127. expect(data.direction).to be_one_of(Bandwidth::CallDirectionEnum.all_vars)
  128. expect(data.channels).to be_instance_of(Integer)
  129. expect(data.start_time).to be_instance_of(Time)
  130. expect(data.end_time).to be_instance_of(Time)
  131. expect(data.file_format).to be_one_of(Bandwidth::FileFormatEnum.all_vars)
  132. expect(data.status).to be_instance_of(String)
  133. expect(data.media_url).to start_with('http')
  134. expect(data.transcription).to be_instance_of(Bandwidth::RecordingTranscriptionMetadata)
  135. expect(data.transcription.id.length).to eq(38)
  136. expect(data.transcription.status).to be_instance_of(String)
  137. expect(data.transcription.completed_time).to be_instance_of(Time)
  138. expect(data.transcription.url).to start_with('http')
  139. expect(data.recording_name).to be_instance_of(String)
  140. end if false # skip due to prism error
  141. 1 it 'causes an ArgumentError for a missing account_id' do
  142. 1 expect {
  143. 1 @recordings_api_instance.get_call_recording(nil, '', '')
  144. }.to raise_error(ArgumentError)
  145. end
  146. 1 it 'causes an ArgumentError for a missing call_id' do
  147. 1 expect {
  148. 1 @recordings_api_instance.get_call_recording(BW_ACCOUNT_ID, nil, '')
  149. }.to raise_error(ArgumentError)
  150. end
  151. 1 it 'causes an ArgumentError for a missing recording_id' do
  152. 1 expect {
  153. 1 @recordings_api_instance.get_call_recording(BW_ACCOUNT_ID, '', nil)
  154. }.to raise_error(ArgumentError)
  155. end
  156. end
  157. # Get Recording Transcription
  158. 1 describe 'get_recording_transcription' do
  159. 1 it 'gets the completed call recording transcription' do
  160. 1 data, status_code = @recordings_api_instance.get_recording_transcription_with_http_info(BW_ACCOUNT_ID, call_id, recording_id)
  161. 1 expect(status_code).to eq(200)
  162. 1 expect(data).to be_instance_of(Bandwidth::RecordingTranscriptions)
  163. 1 expect(data.transcripts).to be_instance_of(Array)
  164. 1 expect(data.transcripts[0]).to be_instance_of(Bandwidth::Transcription)
  165. 1 expect(data.transcripts[0].text).to be_instance_of(String)
  166. 1 expect(data.transcripts[0].confidence).to be_instance_of(Float)
  167. end
  168. 1 it 'causes an ArgumentError for a missing account_id' do
  169. 1 expect {
  170. 1 @recordings_api_instance.get_recording_transcription(nil, '', '')
  171. }.to raise_error(ArgumentError)
  172. end
  173. 1 it 'causes an ArgumentError for a missing call_id' do
  174. 1 expect {
  175. 1 @recordings_api_instance.get_recording_transcription(BW_ACCOUNT_ID, nil, '')
  176. }.to raise_error(ArgumentError)
  177. end
  178. 1 it 'causes an ArgumentError for a missing recording_id' do
  179. 1 expect {
  180. 1 @recordings_api_instance.get_recording_transcription(BW_ACCOUNT_ID, '', nil)
  181. }.to raise_error(ArgumentError)
  182. end
  183. end
  184. # Get Call Recordings
  185. 1 describe 'list_account_call_recordings' do
  186. 1 it 'lists account call recordings' do
  187. 1 data, status_code = @recordings_api_instance.list_account_call_recordings_with_http_info(BW_ACCOUNT_ID)
  188. 1 expect(status_code).to eq(200)
  189. 1 expect(data).to be_instance_of(Array)
  190. 1 expect(data[0]).to be_instance_of(Bandwidth::CallRecordingMetadata)
  191. 1 expect(data[0].application_id.length).to eq(36)
  192. 1 expect(data[0].account_id.length).to eq(7)
  193. 1 expect(data[0].call_id.length).to eq(47)
  194. 1 expect(data[0].parent_call_id.length).to eq(47)
  195. 1 expect(data[0].recording_id.length).to eq(47)
  196. 1 expect(data[0].to.length).to eq(12)
  197. 1 expect(data[0].from.length).to eq(12)
  198. 1 expect(data[0].transfer_caller_id.length).to eq(12)
  199. 1 expect(data[0].transfer_to.length).to eq(12)
  200. 1 expect(data[0].duration).to start_with('PT')
  201. 1 expect(data[0].direction).to be_one_of(Bandwidth::CallDirectionEnum.all_vars)
  202. 1 expect(data[0].channels).to be_instance_of(Integer)
  203. 1 expect(data[0].start_time).to be_instance_of(Time)
  204. 1 expect(data[0].end_time).to be_instance_of(Time)
  205. 1 expect(data[0].file_format).to be_one_of(Bandwidth::FileFormatEnum.all_vars)
  206. 1 expect(data[0].status).to be_instance_of(String)
  207. 1 expect(data[0].media_url).to start_with('http')
  208. 1 expect(data[0].transcription).to be_instance_of(Bandwidth::RecordingTranscriptionMetadata)
  209. 1 expect(data[0].transcription.id.length).to eq(38)
  210. 1 expect(data[0].transcription.status).to be_instance_of(String)
  211. 1 expect(data[0].transcription.completed_time).to be_instance_of(Time)
  212. 1 expect(data[0].transcription.url).to start_with('http')
  213. 1 expect(data[0].recording_name).to be_instance_of(String)
  214. end
  215. 1 it 'causes an ArgumentError for a missing account_id' do
  216. 1 expect {
  217. 1 @recordings_api_instance.list_account_call_recordings(nil)
  218. }.to raise_error(ArgumentError)
  219. end
  220. end
  221. # List Call Recordings
  222. 1 describe 'list_call_recordings' do
  223. 1 it 'lists all recordings for a single call' do
  224. 1 data, status_code = @recordings_api_instance.list_call_recordings_with_http_info(BW_ACCOUNT_ID, call_id)
  225. 1 expect(status_code).to eq(200)
  226. 1 expect(data).to be_instance_of(Array)
  227. 1 expect(data[0]).to be_instance_of(Bandwidth::CallRecordingMetadata)
  228. 1 expect(data[0].application_id.length).to eq(36)
  229. 1 expect(data[0].account_id.length).to eq(7)
  230. 1 expect(data[0].call_id.length).to eq(47)
  231. 1 expect(data[0].parent_call_id.length).to eq(47)
  232. 1 expect(data[0].recording_id.length).to eq(47)
  233. 1 expect(data[0].to.length).to eq(12)
  234. 1 expect(data[0].from.length).to eq(12)
  235. 1 expect(data[0].transfer_caller_id.length).to eq(12)
  236. 1 expect(data[0].transfer_to.length).to eq(12)
  237. 1 expect(data[0].duration).to start_with('PT')
  238. 1 expect(data[0].direction).to be_one_of(Bandwidth::CallDirectionEnum.all_vars)
  239. 1 expect(data[0].channels).to be_instance_of(Integer)
  240. 1 expect(data[0].start_time).to be_instance_of(Time)
  241. 1 expect(data[0].end_time).to be_instance_of(Time)
  242. 1 expect(data[0].file_format).to be_one_of(Bandwidth::FileFormatEnum.all_vars)
  243. 1 expect(data[0].status).to be_instance_of(String)
  244. 1 expect(data[0].media_url).to start_with('http')
  245. 1 expect(data[0].transcription).to be_instance_of(Bandwidth::RecordingTranscriptionMetadata)
  246. 1 expect(data[0].transcription.id.length).to eq(38)
  247. 1 expect(data[0].transcription.status).to be_instance_of(String)
  248. 1 expect(data[0].transcription.completed_time).to be_instance_of(Time)
  249. 1 expect(data[0].transcription.url).to start_with('http')
  250. 1 expect(data[0].recording_name).to be_instance_of(String)
  251. end
  252. 1 it 'causes an ArgumentError for a missing account_id' do
  253. 1 expect {
  254. 1 @recordings_api_instance.list_call_recordings(nil, '')
  255. }.to raise_error(ArgumentError)
  256. end
  257. 1 it 'causes an ArgumentError for a missing call_id' do
  258. 1 expect {
  259. 1 @recordings_api_instance.list_call_recordings(BW_ACCOUNT_ID, nil)
  260. }.to raise_error(ArgumentError)
  261. end
  262. end
  263. # Create Transcription Request
  264. 1 describe 'transcribe_call_recording' do
  265. 1 it 'creates a transcription request' do
  266. 1 transcribe_recording = Bandwidth::TranscribeRecording.new(
  267. callback_url: BASE_CALLBACK_URL + '/transcriptions',
  268. tag: call_id
  269. )
  270. 1 _data, status_code = @recordings_api_instance.transcribe_call_recording_with_http_info(BW_ACCOUNT_ID, call_id, recording_id, transcribe_recording)
  271. 1 expect(status_code).to eq(204)
  272. end
  273. 1 it 'causes an ArgumentError for a missing account_id' do
  274. 1 expect {
  275. 1 @recordings_api_instance.transcribe_call_recording(nil, '', '', '')
  276. }.to raise_error(ArgumentError)
  277. end
  278. 1 it 'causes an ArgumentError for a missing call_id' do
  279. 1 expect {
  280. 1 @recordings_api_instance.transcribe_call_recording(BW_ACCOUNT_ID, nil, '', '')
  281. }.to raise_error(ArgumentError)
  282. end
  283. 1 it 'causes an ArgumentError for a missing recording_id' do
  284. 1 expect {
  285. 1 @recordings_api_instance.transcribe_call_recording(BW_ACCOUNT_ID, '', nil, '')
  286. }.to raise_error(ArgumentError)
  287. end
  288. 1 it 'causes an ArgumentError for a missing transcribe_recording' do
  289. 1 expect {
  290. 1 @recordings_api_instance.transcribe_call_recording(BW_ACCOUNT_ID, '', '', nil)
  291. }.to raise_error(ArgumentError)
  292. end
  293. end
  294. # Update Recording
  295. 1 describe 'update_call_recording_state' do
  296. 1 it 'updates call recording' do
  297. 1 pause_recording = Bandwidth::UpdateCallRecording.new(
  298. state: Bandwidth::RecordingStateEnum::PAUSED
  299. )
  300. 1 _data, status_code = @recordings_api_instance.update_call_recording_state_with_http_info(BW_ACCOUNT_ID, call_id, pause_recording)
  301. 1 expect(status_code).to eq(200)
  302. end
  303. 1 it 'causes an ArgumentError for a missing account_id' do
  304. 1 expect {
  305. 1 @recordings_api_instance.update_call_recording_state(nil, '', {})
  306. }.to raise_error(ArgumentError)
  307. end
  308. 1 it 'causes an ArgumentError for a missing call_id' do
  309. 1 expect {
  310. 1 @recordings_api_instance.update_call_recording_state(BW_ACCOUNT_ID, nil, {})
  311. }.to raise_error(ArgumentError)
  312. end
  313. 1 it 'causes an ArgumentError for a missing update_call_recording' do
  314. 1 expect {
  315. 1 @recordings_api_instance.update_call_recording_state(BW_ACCOUNT_ID, '', nil)
  316. }.to raise_error(ArgumentError)
  317. end
  318. end
  319. end

spec/unit/api/statistics_api_spec.rb

100.0% lines covered

22 relevant lines. 22 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::StatisticsApi
  2. 1 describe 'StatisticsApi' do
  3. 1 before(:all) do
  4. 1 Bandwidth.configure do |config|
  5. 1 config.debugging = true
  6. 1 config.username = BW_USERNAME
  7. 1 config.password = BW_PASSWORD
  8. 1 config.ignore_operation_servers = true
  9. 1 config.host = '127.0.0.1:4010'
  10. end
  11. 1 @statistics_api_instance = Bandwidth::StatisticsApi.new
  12. end
  13. 1 describe 'test an instance of StatisticsApi' do
  14. 1 it 'should create an instance of StatisticsApi' do
  15. 1 expect(@statistics_api_instance).to be_instance_of(Bandwidth::StatisticsApi)
  16. end
  17. end
  18. # Get Account Statistics
  19. 1 describe 'get_statistics' do
  20. 1 it 'gets account statistics' do
  21. 1 data, status_code = @statistics_api_instance.get_statistics_with_http_info(BW_ACCOUNT_ID)
  22. 1 expect(status_code).to eq(200)
  23. 1 expect(data).to be_instance_of(Bandwidth::AccountStatistics)
  24. 1 expect(data.current_call_queue_size).to be_instance_of(Integer)
  25. 1 expect(data.max_call_queue_size).to be_instance_of(Integer)
  26. end
  27. 1 it 'causes an ArgumentError for a missing account_id' do
  28. 1 expect {
  29. 1 @statistics_api_instance.get_statistics(nil)
  30. }.to raise_error(ArgumentError)
  31. end
  32. end
  33. end

spec/unit/api/toll_free_verification_api_spec.rb

100.0% lines covered

164 relevant lines. 164 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::TollFreeVerificationApi
  2. 1 describe 'TollFreeVerificationApi' do
  3. 3 let (:webhook_subscription_request_schema) { Bandwidth::WebhookSubscriptionRequestSchema.new(
  4. basic_authentication: {
  5. username: 'username',
  6. password: 'password'
  7. },
  8. callback_url: 'https://example.com',
  9. shared_secret_key: 'shared-secret-key'
  10. ) }
  11. 1 let (:verification) { {
  12. 2 business_address: Bandwidth::Address.new(
  13. name: 'name',
  14. addr1: 'addr1',
  15. addr2: 'addr2',
  16. city: 'city',
  17. state: 'state',
  18. zip: 'zip',
  19. url: 'https://example.com'
  20. ),
  21. business_contact: Bandwidth::Contact.new(
  22. first_name: 'first-name',
  23. last_name: 'last-name',
  24. email: 'email@email.com',
  25. phone_number: '+19195551234'
  26. ),
  27. message_volume: 12,
  28. use_case: 'useCase',
  29. use_case_summary: 'useCaseSummary',
  30. production_message_content: 'productionMessageContent',
  31. opt_in_workflow: Bandwidth::OptInWorkflow.new(
  32. description: 'description',
  33. image_urls: ['https://example.com']
  34. ),
  35. business_entity_type: Bandwidth::BusinessEntityTypeEnum::PUBLIC_PROFIT,
  36. business_registration_number: '123456789',
  37. business_registration_type: Bandwidth::BusinessRegistrationTypeEnum::EIN,
  38. business_registration_issuing_country: 'USA',
  39. additional_information: 'additionalInformation',
  40. isv_reseller: 'isvReseller'
  41. } }
  42. 6 let (:subscription_id) { 'test-id-1234' }
  43. 9 let (:tf_phone_number) { '+18005551234' }
  44. 1 before(:all) do
  45. 1 Bandwidth.configure do |config|
  46. 1 config.debugging = true
  47. 1 config.username = BW_USERNAME
  48. 1 config.password = BW_PASSWORD
  49. 1 config.ignore_operation_servers = true
  50. 1 config.host = '127.0.0.1:4010'
  51. end
  52. 1 @tfv_api_instance = Bandwidth::TollFreeVerificationApi.new
  53. end
  54. 1 describe 'test an instance of TollFreeVerificationApi' do
  55. 1 it 'should create an instance of TollFreeVerificationApi' do
  56. 1 expect(@tfv_api_instance).to be_instance_of(Bandwidth::TollFreeVerificationApi)
  57. end
  58. end
  59. # Create Webhook Subscription
  60. 1 describe 'create_webhook_subscription test' do
  61. 1 it 'creates webhook subscription' do
  62. 1 data, status_code = @tfv_api_instance.create_webhook_subscription_with_http_info(BW_ACCOUNT_ID, webhook_subscription_request_schema)
  63. 1 expect(status_code).to eq(201)
  64. 1 expect(data).to be_instance_of(Bandwidth::WebhookSubscription)
  65. 1 expect(data.id).to be_instance_of(String)
  66. 1 expect(data.account_id.length).to eq(7)
  67. 1 expect(data.callback_url).to be_instance_of(String)
  68. 1 expect(data.type).to be_one_of(Bandwidth::WebhookSubscriptionTypeEnum.all_vars)
  69. 1 expect(data.basic_authentication).to be_instance_of(Bandwidth::WebhookSubscriptionBasicAuthentication)
  70. 1 expect(data.basic_authentication.username).to be_instance_of(String)
  71. 1 expect(data.basic_authentication.password).to be_instance_of(String)
  72. 1 expect(data.created_date).to be_instance_of(Time)
  73. 1 expect(data.modified_date).to be_instance_of(Time)
  74. end
  75. 1 it 'causes an ArgumentError for a missing account_id' do
  76. 1 expect {
  77. 1 @tfv_api_instance.create_webhook_subscription(nil, {})
  78. }.to raise_error(ArgumentError)
  79. end
  80. 1 it 'causes an ArgumentError for a missing webhook_subscription_request_schema' do
  81. 1 expect {
  82. 1 @tfv_api_instance.create_webhook_subscription(BW_ACCOUNT_ID, nil)
  83. }.to raise_error(ArgumentError)
  84. end
  85. end
  86. # Delete Webhook Subscription
  87. 1 describe 'delete_webhook_subscription test' do
  88. 1 it 'deletes webhook subscription' do
  89. 1 _data, status_code = @tfv_api_instance.delete_webhook_subscription_with_http_info(BW_ACCOUNT_ID, subscription_id)
  90. 1 expect(status_code).to eq(204)
  91. end
  92. 1 it 'causes an ArgumentError for a missing account_id' do
  93. 1 expect {
  94. 1 @tfv_api_instance.delete_webhook_subscription(nil, subscription_id)
  95. }.to raise_error(ArgumentError)
  96. end
  97. 1 it 'causes an ArgumentError for a missing subscription_id' do
  98. 1 expect {
  99. 1 @tfv_api_instance.delete_webhook_subscription(BW_ACCOUNT_ID, nil)
  100. }.to raise_error(ArgumentError)
  101. end
  102. end
  103. # Get Toll-Free Verification Status
  104. 1 describe 'get_toll_free_verification_status test' do
  105. 1 it 'gets toll free verification status' do
  106. 1 data, status_code = @tfv_api_instance.get_toll_free_verification_status_with_http_info(BW_ACCOUNT_ID, tf_phone_number)
  107. 1 expect(status_code).to eq(200)
  108. 1 expect(data).to be_instance_of(Bandwidth::TfvStatus)
  109. 1 expect(data.phone_number).to be_instance_of(String)
  110. 1 expect(data.status).to be_one_of(Bandwidth::TfvStatusEnum.all_vars)
  111. 1 expect(data.internal_ticket_number).to be_instance_of(String)
  112. 1 expect(data.decline_reason_description).to be_instance_of(String)
  113. 1 expect(data.resubmit_allowed).to be_one_of([true, false])
  114. 1 expect(data.created_date_time).to be_instance_of(Time)
  115. 1 expect(data.modified_date_time).to be_instance_of(Time)
  116. 1 expect(data.submission).to be_instance_of(Bandwidth::TfvSubmissionInfo)
  117. 1 expect(data.blocked).to be_one_of([true, false])
  118. 1 expect(data.blocked_reason).to be_instance_of(String)
  119. 1 expect(data.cv_token).to be_instance_of(String)
  120. end
  121. 1 it 'causes an ArgumentError for a missing account_id' do
  122. 1 expect {
  123. 1 @tfv_api_instance.get_toll_free_verification_status(nil, tf_phone_number)
  124. }.to raise_error(ArgumentError)
  125. end
  126. 1 it 'causes an ArgumentError for a missing phone_number' do
  127. 1 expect {
  128. 1 @tfv_api_instance.get_toll_free_verification_status(BW_ACCOUNT_ID, nil)
  129. }.to raise_error(ArgumentError)
  130. end
  131. end
  132. # Delete a Toll-Free Verification Submission
  133. 1 describe 'delete_verification_request' do
  134. 1 it 'deletes a toll free verification submission' do
  135. 1 _data, status_code = @tfv_api_instance.delete_verification_request_with_http_info(BW_ACCOUNT_ID, tf_phone_number)
  136. 1 expect(status_code).to eq(204)
  137. end
  138. 1 it 'causes an ArgumentError for a missing account_id' do
  139. 1 expect {
  140. 1 @tfv_api_instance.delete_verification_request(nil, tf_phone_number)
  141. }.to raise_error(ArgumentError)
  142. end
  143. 1 it 'causes an ArgumentError for a missing phone_number' do
  144. 1 expect {
  145. 1 @tfv_api_instance.delete_verification_request(BW_ACCOUNT_ID, nil)
  146. }.to raise_error(ArgumentError)
  147. end
  148. end
  149. # List Toll-Free Use Cases
  150. 1 describe 'list_toll_free_use_cases test' do
  151. 1 it 'lists toll free use cases' do
  152. 1 data, status_code = @tfv_api_instance.list_toll_free_use_cases_with_http_info
  153. 1 expect(status_code).to eq(200)
  154. 1 expect(data).to be_instance_of(Array)
  155. 1 expect(data.length).to be > 0
  156. 1 expect(data[0]).to be_instance_of(String)
  157. end
  158. end
  159. # List Webhook Subscriptions
  160. 1 describe 'list_webhook_subscriptions test' do
  161. 1 it 'lists webhook subscriptions' do
  162. 1 data, status_code = @tfv_api_instance.list_webhook_subscriptions_with_http_info(BW_ACCOUNT_ID)
  163. 1 expect(status_code).to eq(200)
  164. 1 expect(data).to be_instance_of(Bandwidth::WebhookSubscriptionsListBody)
  165. 1 expect(data.links).to be_instance_of(Bandwidth::LinksObject)
  166. 1 expect(data.links.first).to be_instance_of(String)
  167. 1 expect(data.links._next).to be_instance_of(String)
  168. 1 expect(data.links.previous).to be_instance_of(String)
  169. 1 expect(data.links.last).to be_instance_of(String)
  170. 1 expect(data.errors).to be_instance_of(Array)
  171. 1 expect(data.errors[0].code).to be_instance_of(Integer)
  172. 1 expect(data.errors[0].description).to be_instance_of(String)
  173. 1 expect(data.errors[0].telephone_numbers).to be_instance_of(Array)
  174. 1 expect(data.errors[0].telephone_numbers[0]).to be_instance_of(Bandwidth::TelephoneNumber)
  175. 1 expect(data.errors[0].telephone_numbers[0].telephone_number).to be_instance_of(String)
  176. 1 expect(data.data).to be_instance_of(Array)
  177. 1 expect(data.data[0]).to be_instance_of(Bandwidth::WebhookSubscription)
  178. 1 expect(data.data[0].id).to be_instance_of(String)
  179. 1 expect(data.data[0].account_id).to be_instance_of(String)
  180. 1 expect(data.data[0].callback_url).to be_instance_of(String)
  181. 1 expect(data.data[0].type).to be_one_of(Bandwidth::WebhookSubscriptionTypeEnum.all_vars)
  182. 1 expect(data.data[0].basic_authentication).to be_instance_of(Bandwidth::WebhookSubscriptionBasicAuthentication)
  183. 1 expect(data.data[0].basic_authentication.username).to be_instance_of(String)
  184. 1 expect(data.data[0].basic_authentication.password).to be_instance_of(String)
  185. 1 expect(data.data[0].created_date).to be_instance_of(Time)
  186. 1 expect(data.data[0].modified_date).to be_instance_of(Time)
  187. end
  188. 1 it 'causes an ArgumentError for a missing account_id' do
  189. 1 expect {
  190. 1 @tfv_api_instance.list_webhook_subscriptions(nil)
  191. }.to raise_error(ArgumentError)
  192. end
  193. end
  194. # Request Toll-Free Verification
  195. 1 describe 'request_toll_free_verification test' do
  196. 1 it 'requests toll free verification' do
  197. 1 verification_request = Bandwidth::VerificationRequest.new(verification.merge(phone_numbers: [tf_phone_number]))
  198. 1 _data, status_code = @tfv_api_instance.request_toll_free_verification_with_http_info(BW_ACCOUNT_ID, verification_request)
  199. 1 expect(status_code).to eq(202)
  200. end
  201. 1 it 'causes an ArgumentError for a missing account_id' do
  202. 1 expect {
  203. 1 @tfv_api_instance.request_toll_free_verification(nil, {})
  204. }.to raise_error(ArgumentError)
  205. end
  206. 1 it 'causes an ArgumentError for a missing verification_request' do
  207. 1 expect {
  208. 1 @tfv_api_instance.request_toll_free_verification(BW_ACCOUNT_ID, nil)
  209. }.to raise_error(ArgumentError)
  210. end
  211. end
  212. # Update Toll-Free Verification Request
  213. 1 describe 'update_toll_free_verification_request test' do
  214. 1 it 'updates toll free verification request' do
  215. 1 tfv_submission_wrapper = Bandwidth::TfvSubmissionWrapper.new(
  216. submission: Bandwidth::VerificationUpdateRequest.new(verification)
  217. )
  218. 1 _data, status_code = @tfv_api_instance.update_toll_free_verification_request_with_http_info(BW_ACCOUNT_ID, tf_phone_number, tfv_submission_wrapper)
  219. 1 expect(status_code).to eq(202)
  220. end
  221. 1 it 'causes an ArgumentError for a missing account_id' do
  222. 1 expect {
  223. 1 @tfv_api_instance.update_toll_free_verification_request(nil, tf_phone_number, {})
  224. }.to raise_error(ArgumentError)
  225. end
  226. 1 it 'causes an ArgumentError for a missing phone_number' do
  227. 1 expect {
  228. 1 @tfv_api_instance.update_toll_free_verification_request(BW_ACCOUNT_ID, nil, {})
  229. }.to raise_error(ArgumentError)
  230. end
  231. 1 it 'causes an ArgumentError for a missing tfv_submission_wrapper' do
  232. 1 expect {
  233. 1 @tfv_api_instance.update_toll_free_verification_request(BW_ACCOUNT_ID, tf_phone_number, nil)
  234. }.to raise_error(ArgumentError)
  235. end
  236. end
  237. # Update Webhook Subscription
  238. 1 describe 'update_webhook_subscription test' do
  239. 1 it 'updates webhook subscription' do
  240. 1 data, status_code = @tfv_api_instance.update_webhook_subscription_with_http_info(BW_ACCOUNT_ID, subscription_id, webhook_subscription_request_schema)
  241. 1 expect(status_code).to eq(200)
  242. 1 expect(data).to be_instance_of(Bandwidth::WebhookSubscription)
  243. 1 expect(data.id).to be_instance_of(String)
  244. 1 expect(data.account_id.length).to eq(7)
  245. 1 expect(data.callback_url).to be_instance_of(String)
  246. 1 expect(data.type).to be_one_of(Bandwidth::WebhookSubscriptionTypeEnum.all_vars)
  247. 1 expect(data.basic_authentication).to be_instance_of(Bandwidth::WebhookSubscriptionBasicAuthentication)
  248. 1 expect(data.basic_authentication.username).to be_instance_of(String)
  249. 1 expect(data.basic_authentication.password).to be_instance_of(String)
  250. 1 expect(data.created_date).to be_instance_of(Time)
  251. 1 expect(data.modified_date).to be_instance_of(Time)
  252. end
  253. 1 it 'causes an ArgumentError for a missing account_id' do
  254. 1 expect {
  255. 1 @tfv_api_instance.update_webhook_subscription(nil, subscription_id, {})
  256. }.to raise_error(ArgumentError)
  257. end
  258. 1 it 'causes an ArgumentError for a missing subscription_id' do
  259. 1 expect {
  260. 1 @tfv_api_instance.update_webhook_subscription(BW_ACCOUNT_ID, nil, {})
  261. }.to raise_error(ArgumentError)
  262. end
  263. 1 it 'causes an ArgumentError for a missing webhook_subscription_request_schema' do
  264. 1 expect {
  265. 1 @tfv_api_instance.update_webhook_subscription(BW_ACCOUNT_ID, subscription_id, nil)
  266. }.to raise_error(ArgumentError)
  267. end
  268. end
  269. end

spec/unit/api/transcriptions_api_spec.rb

100.0% lines covered

65 relevant lines. 65 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::TranscriptionsApi
  2. 1 describe 'TranscriptionsApi' do
  3. 4 let(:call_id) { 'c-1234' }
  4. 3 let(:transcription_id) { 't-1234' }
  5. 1 before(:all) do
  6. 1 Bandwidth.configure do |config|
  7. 1 config.debugging = true
  8. 1 config.username = BW_USERNAME
  9. 1 config.password = BW_PASSWORD
  10. 1 config.ignore_operation_servers = true
  11. 1 config.host = '127.0.0.1:4010'
  12. end
  13. 1 @transcriptions_api_instance = Bandwidth::TranscriptionsApi.new
  14. end
  15. 1 describe 'test an instance of TranscriptionsApi' do
  16. 1 it 'should create an instance of TranscriptionsApi' do
  17. 1 expect(@transcriptions_api_instance).to be_instance_of(Bandwidth::TranscriptionsApi)
  18. end
  19. end
  20. # Delete Call Transcription
  21. 1 describe 'delete_real_time_transcription' do
  22. 1 it 'deletes the specified call transcription' do
  23. 1 _data, status_code = @transcriptions_api_instance.delete_real_time_transcription_with_http_info(BW_ACCOUNT_ID, call_id, transcription_id)
  24. 1 expect(status_code).to eq(200)
  25. end
  26. 1 it 'causes an ArgumentError for a missing account_id' do
  27. 1 expect {
  28. 1 @transcriptions_api_instance.delete_real_time_transcription(nil, '', '')
  29. }.to raise_error(ArgumentError)
  30. end
  31. 1 it 'causes an ArgumentError for a missing call_id' do
  32. 1 expect {
  33. 1 @transcriptions_api_instance.delete_real_time_transcription(BW_ACCOUNT_ID, nil, '')
  34. }.to raise_error(ArgumentError)
  35. end
  36. 1 it 'causes an ArgumentError for a missing transcription_id' do
  37. 1 expect {
  38. 1 @transcriptions_api_instance.delete_real_time_transcription(BW_ACCOUNT_ID, '', nil)
  39. }.to raise_error(ArgumentError)
  40. end
  41. end
  42. # List Call Transcriptions
  43. 1 describe 'list_real_time_transcriptions' do
  44. 1 it 'lists call transcriptions' do
  45. 1 data, status_code = @transcriptions_api_instance.list_real_time_transcriptions_with_http_info(BW_ACCOUNT_ID, call_id)
  46. 1 expect(status_code).to eq(200)
  47. 1 expect(data).to be_instance_of(Array)
  48. 1 expect(data[0]).to be_instance_of(Bandwidth::CallTranscriptionMetadata)
  49. 1 expect(data[0].transcription_id).to be_instance_of(String)
  50. 1 expect(data[0].transcription_url).to be_instance_of(String)
  51. 1 expect(data[0].transcription_name).to be_instance_of(String)
  52. end
  53. 1 it 'causes an ArgumentError for a missing account_id' do
  54. 1 expect {
  55. 1 @transcriptions_api_instance.list_real_time_transcriptions(nil, '')
  56. }.to raise_error(ArgumentError)
  57. end
  58. 1 it 'causes an ArgumentError for a missing call_id' do
  59. 1 expect {
  60. 1 @transcriptions_api_instance.list_real_time_transcriptions(BW_ACCOUNT_ID, nil)
  61. }.to raise_error(ArgumentError)
  62. end
  63. end
  64. # Get Call Transcription
  65. 1 describe 'get_real_time_transcription' do
  66. 1 it 'gets the specified call transcription' do
  67. 1 data, status_code = @transcriptions_api_instance.get_real_time_transcription_with_http_info(BW_ACCOUNT_ID, call_id, transcription_id)
  68. 1 expect(status_code).to eq(200)
  69. 1 expect(data).to be_instance_of(Bandwidth::CallTranscriptionResponse)
  70. 1 expect(data.account_id.length).to eq(7)
  71. 1 expect(data.call_id.length).to eq(47)
  72. 1 expect(data.transcription_id).to be_instance_of(String)
  73. 1 expect(data.tracks).to be_instance_of(Array)
  74. 1 expect(data.tracks[0]).to be_instance_of(Bandwidth::CallTranscription)
  75. 1 expect(data.tracks[0].detected_language).to be_one_of(Bandwidth::CallTranscriptionDetectedLanguageEnum.all_vars)
  76. 1 expect(data.tracks[0].track).to be_one_of(Bandwidth::CallTranscriptionTrackEnum.all_vars)
  77. 1 expect(data.tracks[0].transcript).to be_instance_of(String)
  78. 1 expect(data.tracks[0].confidence).to be_instance_of(Float)
  79. end
  80. 1 it 'causes an ArgumentError for a missing account_id' do
  81. 1 expect {
  82. 1 @transcriptions_api_instance.get_real_time_transcription(nil, '', '')
  83. }.to raise_error(ArgumentError)
  84. end
  85. 1 it 'causes an ArgumentError for a missing call_id' do
  86. 1 expect {
  87. 1 @transcriptions_api_instance.get_real_time_transcription(BW_ACCOUNT_ID, nil, '')
  88. }.to raise_error(ArgumentError)
  89. end
  90. 1 it 'causes an ArgumentError for a missing transcription_id' do
  91. 1 expect {
  92. 1 @transcriptions_api_instance.get_real_time_transcription(BW_ACCOUNT_ID, '', nil)
  93. }.to raise_error(ArgumentError)
  94. end
  95. end
  96. end

spec/unit/client/api_client_spec.rb

100.0% lines covered

122 relevant lines. 122 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::ApiClient
  2. 1 describe Bandwidth::ApiClient do
  3. 17 let(:api_client_default) { Bandwidth::ApiClient.new }
  4. 2 let(:config) { Bandwidth::Configuration.new }
  5. 2 let(:faraday_connection) { Faraday::Connection.new }
  6. 2 let(:api_client) { Bandwidth::ApiClient.new(config) }
  7. 1 let(:named_media_headers) { { 'content-disposition' => 'filename=test', 'content-type' => 'text/plain' } }
  8. 1 let(:media_data) { '123456' }
  9. 1 let(:media_headers) { { 'content-type' => 'text/plain' } }
  10. 1 let(:json_headers) { { 'content-type' => 'application/json' } }
  11. 1 let(:multipart_headers) { { 'Content-Type' => 'multipart/form-data' } }
  12. 2 let(:form_encoded_headers) { { 'Content-Type' => 'application/x-www-form-urlencoded' } }
  13. 1 let(:error_data) { '{"error": true}' }
  14. describe '#call_api' do
  15. it 'calls api and returns a tempfile with name from content-disposition header' do
  16. stub_request(:get, 'https://messaging.bandwidth.com/api/v2/path').
  17. to_return(status: 200, headers: media_headers, body: media_data)
  18. opts = {
  19. operation: :"MediaApi.get_media",
  20. header_params: {},
  21. query_params: {},
  22. form_params: {},
  23. body: nil,
  24. auth_names: ['Basic'],
  25. return_type: 'File'
  26. }
  27. data, status_code, headers = api_client.call_api(:GET, 'path', opts)
  28. expect(status_code).to eq(200)
  29. expect(headers).to eq(media_headers)
  30. expect(data).to be_a(Tempfile)
  31. end
  32. it 'calls api and returns a tempfile' do
  33. stub_request(:get, 'https://messaging.bandwidth.com/api/v2/path').
  34. to_return(status: 200, headers: named_media_headers, body: media_data)
  35. opts = {
  36. operation: :"MediaApi.get_media",
  37. header_params: {},
  38. query_params: {},
  39. form_params: {},
  40. body: nil,
  41. auth_names: ['Basic'],
  42. return_type: 'File'
  43. }
  44. data, status_code, headers = api_client.call_api(:GET, 'path', opts)
  45. expect(status_code).to eq(200)
  46. expect(headers).to eq(named_media_headers)
  47. expect(data).to be_a(Tempfile)
  48. end
  49. it 'calls api and returns binary data' do
  50. stub_request(:get, 'https://messaging.bandwidth.com/api/v2/path').
  51. to_return(status: 200, headers: media_headers, body: media_data)
  52. api_client.config.return_binary_data = true
  53. api_client.config.debugging = true
  54. opts = {
  55. operation: :"MediaApi.get_media",
  56. header_params: {},
  57. query_params: {},
  58. form_params: {},
  59. body: nil,
  60. auth_names: ['Basic'],
  61. return_type: 'File'
  62. }
  63. data, status_code, headers = api_client.call_api(:GET, 'path', opts)
  64. expect(status_code).to eq(200)
  65. expect(headers).to eq(media_headers)
  66. expect(data).to eq(media_data)
  67. end
  68. it 'calls api and returns a hash' do
  69. stub_request(:get, 'https://messaging.bandwidth.com/api/v2/path').
  70. to_return(status: 200, headers: json_headers, body: '{"id": 1}')
  71. opts = {
  72. operation: :"MessagesApi.list_messages",
  73. header_params: {},
  74. query_params: {},
  75. form_params: {},
  76. body: nil,
  77. auth_names: ['Basic'],
  78. return_type: 'Hash<String, Integer>'
  79. }
  80. data, status_code, headers = api_client.call_api(:GET, 'path', opts)
  81. expect(status_code).to eq(200)
  82. expect(headers).to eq(json_headers)
  83. expect(data).to eq({ id: 1 })
  84. end
  85. it 'posts data and returns nothing' do
  86. stub_request(:post, 'https://messaging.bandwidth.com/api/v2/path').
  87. to_return(status: 204)
  88. api_client.config.debugging = true
  89. opts = {
  90. operation: :"MediaApi.upload_media",
  91. header_params: {},
  92. query_params: {},
  93. form_params: {},
  94. body: { id: 1 },
  95. auth_names: ['Basic'],
  96. return_type: nil
  97. }
  98. data, status_code = api_client.call_api(:POST, 'path', opts)
  99. expect(status_code).to eq(204)
  100. expect(data).to be nil
  101. end
  102. it 'posts multipart/form-data and returns nothing' do
  103. stub_request(:post, 'https://messaging.bandwidth.com/api/v2/path').
  104. to_return(status: 204)
  105. opts = {
  106. operation: :"MediaApi.upload_media",
  107. header_params: multipart_headers,
  108. query_params: {},
  109. form_params: { file: Tempfile.new('filename'), array: [1, 2, 3], string: '123' },
  110. body: nil,
  111. auth_names: ['Basic'],
  112. return_type: nil
  113. }
  114. data, status_code = api_client.call_api(:POST, 'path', opts)
  115. expect(status_code).to eq(204)
  116. expect(data).to be nil
  117. end
  118. it 'calls api and handles HTTP error' do
  119. stub_request(:post, 'https://messaging.bandwidth.com/api/v2/path').
  120. to_return(status: 400, headers: json_headers, body: error_data)
  121. opts = {
  122. operation: :"MediaApi.upload_media",
  123. header_params: {},
  124. query_params: {},
  125. form_params: {},
  126. body: { id: 1 },
  127. auth_names: ['Basic'],
  128. return_type: nil
  129. }
  130. expect {
  131. api_client.call_api(:POST, 'path', opts)
  132. }.to raise_error { |e|
  133. expect(e).to be_instance_of(Bandwidth::ApiError)
  134. expect(e.code).to eq(400)
  135. expect(e.response_headers).to eq(json_headers)
  136. expect(e.response_body).to eq('{"error": true}')
  137. }
  138. end
  139. it 'calls api and handles timeout error' do
  140. stub_request(:post, 'https://messaging.bandwidth.com/api/v2/path').
  141. to_raise(Faraday::TimeoutError)
  142. opts = {
  143. operation: :"MediaApi.upload_media",
  144. header_params: {},
  145. query_params: {},
  146. form_params: {},
  147. body: { id: 1 },
  148. auth_names: ['Basic'],
  149. return_type: nil
  150. }
  151. expect {
  152. api_client.call_api(:POST, 'path', opts)
  153. }.to raise_error { |e|
  154. expect(e).to be_instance_of(Bandwidth::ApiError)
  155. expect(e.message).to eq('Connection timed out')
  156. }
  157. end
  158. it 'calls api and handles connection error' do
  159. stub_request(:post, 'https://messaging.bandwidth.com/api/v2/path').
  160. to_raise(Faraday::ConnectionFailed)
  161. opts = {
  162. operation: :"MediaApi.upload_media",
  163. header_params: {},
  164. query_params: {},
  165. form_params: {},
  166. body: { id: 1 },
  167. auth_names: ['Basic'],
  168. return_type: nil
  169. }
  170. expect {
  171. api_client.call_api(:POST, 'path', opts)
  172. }.to raise_error { |e|
  173. expect(e).to be_instance_of(Bandwidth::ApiError)
  174. expect(e.message).to eq('Connection failed')
  175. }
  176. end
  177. end if false # not needed since the api unit tests cover this
  178. 1 describe '#build_request_body' do
  179. 1 it 'builds application/x-www-form-urlencoded' do
  180. 1 expect(api_client_default.build_request_body(form_encoded_headers, { id: 1 }, nil)).to eq('id=1')
  181. end
  182. 1 it 'builds empty body' do
  183. 1 expect(api_client_default.build_request_body({}, {}, nil)).to be nil
  184. end
  185. end
  186. 1 describe '#deserialize' do
  187. 1 it 'throws on invalid JSON when expecting JSON' do
  188. 1 headers = { 'Content-Type' => 'application/json' }
  189. 1 response = double('response', headers: headers, body: '{id 1}')
  190. 1 expect {
  191. 1 api_client_default.deserialize(response, 'Hash<String, Integer>')
  192. }.to raise_error(JSON::ParserError)
  193. end
  194. 1 it 'rescues invalid JSON when expecting non-JSON' do
  195. 1 headers = { 'Content-Type' => 'application/json' }
  196. 1 response = double('response', headers: headers, body: '2022-06-16')
  197. 1 data = api_client_default.deserialize(response, 'Date')
  198. 1 expect(data).to eq(Date.parse('2022-06-16'))
  199. end
  200. end
  201. 1 describe '#basic_auth' do
  202. 1 it 'sets basic auth for the connection' do
  203. 1 api_client.config.username = 'username'
  204. 1 api_client.config.password = 'password'
  205. 1 api_client.basic_auth(faraday_connection)
  206. 1 expect(api_client.config.username).to eq('username')
  207. 1 expect(api_client.config.password).to eq('password')
  208. end
  209. end
  210. 1 describe '#json_mime?' do
  211. 1 it 'checks if the given MIME is a JSON MIME' do
  212. 1 expect(api_client_default.json_mime?(nil)).to eq false
  213. 1 expect(api_client_default.json_mime?('')).to eq false
  214. 1 expect(api_client_default.json_mime?('application/json')).to eq true
  215. 1 expect(api_client_default.json_mime?('application/json; charset=UTF8')).to eq true
  216. 1 expect(api_client_default.json_mime?('APPLICATION/JSON')).to eq true
  217. 1 expect(api_client_default.json_mime?('application/xml')).to eq false
  218. 1 expect(api_client_default.json_mime?('text/plain')).to eq false
  219. 1 expect(api_client_default.json_mime?('application/jsonp')).to eq false
  220. end
  221. end
  222. 1 describe '#convert_to_type' do
  223. 1 it 'converts data to the given return type' do
  224. 1 expect(api_client_default.convert_to_type(1, 'String')).to eq('1')
  225. 1 expect(api_client_default.convert_to_type('1', 'Integer')).to eq(1)
  226. 1 expect(api_client_default.convert_to_type('1', 'Float')).to eq(1.0)
  227. 1 expect(api_client_default.convert_to_type(1, 'Boolean')).to be false
  228. 1 expect(api_client_default.convert_to_type('2022-06-16T13:15:07.160Z', 'Time')).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  229. 1 expect(api_client_default.convert_to_type('2022-06-16', 'Date')).to eq(Date.parse('2022-06-16'))
  230. 1 expect(api_client_default.convert_to_type({ id: 1 }, 'Object')).to eq({ id: 1 })
  231. 1 expect(api_client_default.convert_to_type([[12, 34], [56]], 'Array<Array<Integer>>')).to eq([[12, 34], [56]])
  232. 1 expect(api_client_default.convert_to_type({ "id": 'test' }, 'Hash<String, String>')).to eq({ id: 'test' })
  233. 1 expect(api_client_default.convert_to_type({ valid: true }, 'VerifyCodeResponse')).to be_instance_of(Bandwidth::VerifyCodeResponse)
  234. end
  235. end
  236. 1 describe '#sanitize_filename' do
  237. 1 it 'sanitizes a filename by removing the path' do
  238. 1 expect(api_client_default.sanitize_filename('sun')).to eq('sun')
  239. 1 expect(api_client_default.sanitize_filename('sun.gif')).to eq('sun.gif')
  240. 1 expect(api_client_default.sanitize_filename('../sun.gif')).to eq('sun.gif')
  241. 1 expect(api_client_default.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
  242. 1 expect(api_client_default.sanitize_filename('./sun.gif')).to eq('sun.gif')
  243. 1 expect(api_client_default.sanitize_filename('..\sun.gif')).to eq('sun.gif')
  244. 1 expect(api_client_default.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
  245. 1 expect(api_client_default.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
  246. 1 expect(api_client_default.sanitize_filename('.\sun.gif')).to eq('sun.gif')
  247. end
  248. end
  249. 1 describe '#build_request_url' do
  250. 1 it 'adds leading and trailing slashes to path' do
  251. 1 expect(api_client_default.build_request_url('test/path')).to end_with('/test/path')
  252. end
  253. end
  254. 1 describe '#update_params_for_auth' do
  255. 1 it 'updates header and query params based on authentication settings' do
  256. end
  257. end
  258. 1 describe '#user_agent=' do
  259. 1 it 'sets user agent in HTTP header' do
  260. 1 api_client_default.user_agent = 'test-user-agent'
  261. 1 expect(api_client_default.default_headers['User-Agent']).to eq('test-user-agent')
  262. end
  263. end
  264. 1 describe '#select_header_accept' do
  265. 1 it 'returns Accept header based on an array of accepts provided' do
  266. 1 expect(api_client_default.select_header_accept(nil)).to be_nil
  267. 1 expect(api_client_default.select_header_accept([])).to be_nil
  268. 1 expect(api_client_default.select_header_accept(['application/json'])).to eq('application/json')
  269. 1 expect(api_client_default.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
  270. 1 expect(api_client_default.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
  271. 1 expect(api_client_default.select_header_accept(['application/xml'])).to eq('application/xml')
  272. 1 expect(api_client_default.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
  273. end
  274. end
  275. 1 describe '#select_header_content_type' do
  276. 1 it 'returns Content-Type header based on an array of content types provided' do
  277. 1 expect(api_client_default.select_header_content_type(nil)).to be_nil
  278. 1 expect(api_client_default.select_header_content_type([])).to be_nil
  279. 1 expect(api_client_default.select_header_content_type(['application/json'])).to eq('application/json')
  280. 1 expect(api_client_default.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
  281. 1 expect(api_client_default.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
  282. 1 expect(api_client_default.select_header_content_type(['application/xml'])).to eq('application/xml')
  283. 1 expect(api_client_default.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
  284. end
  285. end
  286. 1 describe '#object_to_http_body' do
  287. 1 it 'converts array to JSON string' do
  288. 1 model = [1, 2, 3]
  289. 1 expect(api_client_default.object_to_http_body(model)).to eq('[1,2,3]')
  290. end
  291. 1 it 'converts hash to JSON string' do
  292. 1 model = { id: 1 }
  293. 1 expect(api_client_default.object_to_http_body(model)).to eq('{"id":1}')
  294. end
  295. end
  296. 1 describe '#object_to_hash' do
  297. 1 it 'returns object when object cannot be converted to hash' do
  298. 1 model = Object.new
  299. 1 model.instance_variable_set(:@id, 1)
  300. 1 expect(api_client_default.object_to_hash(model)).to be_instance_of(Object)
  301. 1 expect(api_client_default.object_to_hash(model).instance_variable_get('@id')).to eq(1)
  302. end
  303. 1 it 'returns hash when object can be converted to hash' do
  304. 1 model = Bandwidth::VerifyCodeResponse.new({
  305. valid: true
  306. })
  307. 1 expected = { valid: true }
  308. 1 expect(api_client_default.object_to_hash(model)).to eq(expected)
  309. end
  310. end
  311. 1 describe '#build_collection_param' do
  312. 1 it 'builds parameter value according to the given collection format' do
  313. 1 param = ['aa', 'bb', 'cc']
  314. 1 expect(api_client_default.build_collection_param(param, :csv)).to eq('aa,bb,cc')
  315. 1 expect(api_client_default.build_collection_param(param, :ssv)).to eq('aa bb cc')
  316. 1 expect(api_client_default.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
  317. 1 expect(api_client_default.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
  318. 1 expect(api_client_default.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
  319. 1 expect {
  320. 1 api_client_default.build_collection_param(param, :INVALID)
  321. }.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
  322. end
  323. end
  324. end

spec/unit/client/api_error_spec.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::ApiError
  2. 1 describe Bandwidth::ApiError do
  3. 1 describe '#initialize' do
  4. 1 it 'initializes an instance of ApiError with message' do
  5. 1 api_error = Bandwidth::ApiError.new({ message: 'test' })
  6. 1 expect(api_error.message).to eq('test')
  7. end
  8. end
  9. 1 describe '#to_s' do
  10. 1 it 'returns message when to_s is called' do
  11. 1 api_error = Bandwidth::ApiError.new('test')
  12. 1 expect(api_error.to_s).to eq('test')
  13. end
  14. end
  15. 1 describe '#message' do
  16. 1 it 'returns default error message when none supplied' do
  17. 1 api_error = Bandwidth::ApiError.new
  18. 1 expect(api_error.message).to eq('Error message: the server returns an error')
  19. end
  20. end
  21. end

spec/unit/client/configuration_spec.rb

100.0% lines covered

166 relevant lines. 166 lines covered and 0 lines missed.
    
  1. 1 require 'uri'
  2. # Unit tests for Bandwidth::Configuration
  3. 1 describe Bandwidth::Configuration do
  4. 36 let(:config) { Bandwidth::Configuration.new }
  5. 4 let(:faraday_connection) { Faraday::Connection.new }
  6. 2 let(:uri) { URI.parse(BASE_CALLBACK_URL + '/path') }
  7. 8 let(:token) { 'abcd1234' }
  8. 1 let(:server) { [
  9. {
  10. 2 url: 'https://voice.bandwidth.com/api/{enum_var}/{default_var}',
  11. description: 'Production',
  12. variables: {
  13. enum_var: {
  14. enum_values: ['v1', 'v2', 'v3'],
  15. default_value: 'v2'
  16. },
  17. default_var: {
  18. default_value: 'default_value'
  19. }
  20. }
  21. }
  22. ] }
  23. 1 describe '#configure' do
  24. 1 it 'configures a Configuration instance using a a block' do
  25. 1 config.configure do |c|
  26. 1 c.scheme = uri.scheme
  27. 1 c.host = uri.host
  28. 1 c.base_path = uri.path
  29. end
  30. 1 expect(config.scheme).to eq(uri.scheme)
  31. 1 expect(config.host).to eq(uri.host)
  32. 1 expect(config.base_path).to eq(uri.path)
  33. end
  34. end
  35. 1 describe 'custom attribute writers' do
  36. 1 it '#scheme=' do
  37. 1 config.scheme = 'scheme://'
  38. 1 expect(config.scheme).to eq('scheme')
  39. end
  40. 1 it '#host=' do
  41. 1 config.host = 'https://hostname'
  42. 1 expect(config.host).to eq('hostname')
  43. end
  44. 1 it '#base_path=' do
  45. 1 config.base_path = 'basepath'
  46. 1 expect(config.base_path).to eq('/basepath')
  47. end
  48. end
  49. 1 describe '#base_url' do
  50. 1 it 'returns default value when invalid operation is passed' do
  51. 1 expect(config.base_url('invalid_operation')).to eq('http://localhost')
  52. end
  53. 1 it 'returns proper base URL when server index is set' do
  54. 1 operation, server = config.operation_server_settings.first
  55. 1 expect(config.base_url(operation)).to eq(server[0][:url])
  56. end
  57. 1 it 'should have the default value' do
  58. 1 expect(config.base_url).to eq('http://localhost')
  59. end
  60. 1 it 'returns default value when invalid operation is passed' do
  61. 1 expect(config.base_url('invalid_operation')).to eq('http://localhost')
  62. end
  63. 1 it 'throws argument error when attempting to use a server index that is out of bounds' do
  64. 1 config.server_operation_index = {
  65. :'MediaApi.upload_media' => 10
  66. }
  67. 1 expect {
  68. 1 config.base_url(:'MediaApi.upload_media')
  69. }.to raise_error(ArgumentError, 'Invalid index 10 when selecting the server. Must not be nil and must be less than 1')
  70. end
  71. end
  72. 1 describe '#api_key_with_prefix' do
  73. 1 it 'gets API key without prefix' do
  74. 1 config.api_key['Authorization'] = token
  75. 1 expect(config.api_key_with_prefix('Authorization')).to eq(token)
  76. end
  77. 1 it 'gets API key wit prefix' do
  78. 1 config.api_key_prefix['Authorization'] = 'Token'
  79. 1 config.api_key['Authorization'] = token
  80. 1 expect(config.api_key_with_prefix('Authorization')).to eq("Token #{token}")
  81. end
  82. end
  83. 1 describe '#access_token_with_refresh' do
  84. 1 it 'gets the static access_token when no access_token_getter is defined' do
  85. 1 config.access_token = token
  86. 1 expect(config.access_token_with_refresh).to eq(token)
  87. end
  88. 1 it 'gets access_token using access_token_getter' do
  89. 2 config.access_token_getter = proc { token }
  90. 1 expect(config.access_token_with_refresh).to eq(token)
  91. end
  92. end
  93. 1 describe '#basic_auth_token' do
  94. 1 it 'gets Basic Auth token string' do
  95. 1 config.username = 'username'
  96. 1 config.password = 'password'
  97. 1 expect(config.basic_auth_token).to eq('Basic dXNlcm5hbWU6cGFzc3dvcmQ=')
  98. end
  99. end
  100. 1 describe '#oauth_bearer_token' do
  101. 1 it 'returns the Bearer string when a static access_token is set' do
  102. 1 config.access_token = token
  103. 1 config.access_token_getter = nil
  104. 1 expect(config.oauth_bearer_token).to eq("Bearer #{token}")
  105. end
  106. 1 it 'returns the Bearer string using access_token_getter when defined' do
  107. 3 config.access_token_getter = proc { token }
  108. 1 expect(config.oauth_bearer_token).to eq("Bearer #{token}")
  109. end
  110. 1 it 'returns nil when no access_token is available' do
  111. 1 config.access_token = nil
  112. 2 config.access_token_getter = proc { nil }
  113. 1 expect(config.oauth_bearer_token).to be_nil
  114. end
  115. end
  116. 1 describe 'default access_token_getter' do
  117. 4 let(:client_id) { 'test_client_id' }
  118. 4 let(:client_secret) { 'test_client_secret' }
  119. 7 let(:faraday_conn) { instance_double(Faraday::Connection) }
  120. 3 let(:success_response) { instance_double(Faraday::Response, status: 200, body: '{"access_token":"refreshed_token","expires_in":3600}') }
  121. 2 let(:error_response) { instance_double(Faraday::Response, status: 401, body: 'unauthorized') }
  122. 1 before do
  123. 6 allow(Faraday).to receive(:new).and_return(faraday_conn)
  124. end
  125. 1 it 'returns the cached access_token when expiration is in the future' do
  126. 1 config.access_token = 'cached_token'
  127. 1 config.instance_variable_set(:@access_token_expiration, Time.now + 3600)
  128. 1 expect(faraday_conn).not_to receive(:post)
  129. 1 expect(config.access_token_getter.call).to eq('cached_token')
  130. end
  131. 1 it 'returns the cached access_token when expiration has never been set' do
  132. 1 config.access_token = 'cached_token'
  133. 1 expect(faraday_conn).not_to receive(:post)
  134. 1 expect(config.access_token_getter.call).to eq('cached_token')
  135. end
  136. 1 it 'returns nil when no cached token and no client credentials' do
  137. 1 expect(faraday_conn).not_to receive(:post)
  138. 1 expect(config.access_token_getter.call).to be_nil
  139. end
  140. 1 it 'fetches a new token via the token endpoint when no cached token exists' do
  141. 1 config.client_id = client_id
  142. 1 config.client_secret = client_secret
  143. 1 allow(faraday_conn).to receive(:post).and_return(success_response)
  144. 1 expect(config.access_token_getter.call).to eq('refreshed_token')
  145. 1 expect(config.access_token).to eq('refreshed_token')
  146. 1 expect(config.instance_variable_get(:@access_token_expiration)).to be_a(Time)
  147. end
  148. 1 it 'refreshes the token when the cached token is within the 60-second expiration buffer' do
  149. 1 config.client_id = client_id
  150. 1 config.client_secret = client_secret
  151. 1 config.access_token = 'expiring_soon'
  152. 1 config.instance_variable_set(:@access_token_expiration, Time.now + 30)
  153. 1 allow(faraday_conn).to receive(:post).and_return(success_response)
  154. 1 config.access_token_getter.call
  155. 1 expect(config.access_token).to eq('refreshed_token')
  156. end
  157. 1 it 'raises when the token endpoint returns a non-200 response' do
  158. 1 config.client_id = client_id
  159. 1 config.client_secret = client_secret
  160. 1 allow(faraday_conn).to receive(:post).and_return(error_response)
  161. 1 expect {
  162. 1 config.access_token_getter.call
  163. }.to raise_error(RuntimeError, /Failed to obtain access token: 401/)
  164. end
  165. end
  166. 1 describe '#auth_settings' do
  167. 1 it 'returns Basic auth entry for api client' do
  168. 1 basic_auth = config.auth_settings['Basic']
  169. 1 expect(basic_auth[:type]).to eq('basic')
  170. 1 expect(basic_auth[:in]).to eq('header')
  171. 1 expect(basic_auth[:key]).to eq('Authorization')
  172. 1 expect(basic_auth[:value]).to eq('Basic Og==')
  173. end
  174. 1 it 'returns OAuth2 auth entry for api client' do
  175. 1 config.access_token = token
  176. 1 config.access_token_getter = nil
  177. 1 oauth2 = config.auth_settings['OAuth2']
  178. 1 expect(oauth2[:type]).to eq('oauth2')
  179. 1 expect(oauth2[:in]).to eq('header')
  180. 1 expect(oauth2[:key]).to eq('Authorization')
  181. 1 expect(oauth2[:value]).to eq("Bearer #{token}")
  182. end
  183. end
  184. 1 describe '#server_url' do
  185. 1 it 'returns URL with enum variable substituted' do
  186. 1 expect(config.server_url(0, { enum_var: 'v3' }, server)).to eq('https://voice.bandwidth.com/api/v3/default_value')
  187. end
  188. 1 it 'causes an ArgumentError by passing an invalid index' do
  189. 1 expect {
  190. 1 config.server_url(100)
  191. }.to raise_error(ArgumentError)
  192. end
  193. 1 it 'causes an ArgumentError by passing an invalid value to an enum variable' do
  194. 1 expect {
  195. 1 config.server_url(0, { enum_var: 'v4' }, server)
  196. }.to raise_error(ArgumentError)
  197. end
  198. end
  199. 1 describe 'configure faraday connection' do
  200. 1 it '#configure_faraday_connection #configure_connection' do
  201. 1 config.configure_faraday_connection do |c|
  202. 1 config.username = 'username'
  203. end
  204. 1 config.configure_connection(faraday_connection)
  205. 1 expect(config.username).to eq('username')
  206. end
  207. end
  208. 1 describe '#set_faraday_middleware' do
  209. 1 it '#use' do
  210. 1 config.use(Faraday::Request::UrlEncoded)
  211. 1 expect(config.instance_variable_get('@middlewares')[:use]).to eq([[Faraday::Request::UrlEncoded, [], nil]])
  212. end
  213. 1 it '#request' do
  214. 1 config.request(:retry, max: 3, methods: [:get, :post], retry_statuses: [503])
  215. 1 expect(config.instance_variable_get('@middlewares')[:request]).to eq([[:retry, [{ :max => 3, :methods => [:get, :post], :retry_statuses => [503] }], nil]])
  216. end
  217. 1 it '#response' do
  218. 1 config.response(:logger, nil, { bodies: true, log_level: :debug })
  219. 1 expect(config.instance_variable_get('@middlewares')[:response]).to eq([[:logger, [nil, { :bodies => true, :log_level => :debug }], nil]])
  220. end
  221. 1 it 'causes an ArgumentError by passing an invalid middleware operation' do
  222. 1 expect {
  223. 1 config.set_faraday_middleware(:invalid_operation, Faraday::Request::UrlEncoded)
  224. }.to raise_error(ArgumentError)
  225. end
  226. end
  227. 1 describe '#configure_middleware' do
  228. 1 it 'builds connection using supplied response middleware' do
  229. 1 config.response(:logger)
  230. 1 config.configure_middleware(faraday_connection)
  231. 1 expect(faraday_connection.builder.handlers).to include(Faraday::Response::Logger)
  232. end
  233. 1 it 'builds connection using deleted middleware' do
  234. 1 config.set_faraday_middleware(:delete, Faraday::Request::UrlEncoded)
  235. 1 config.configure_middleware(faraday_connection)
  236. 1 expect(faraday_connection.builder.handlers).to eq([])
  237. end
  238. end
  239. end

spec/unit/models/account_statistics_spec.rb

100.0% lines covered

32 relevant lines. 32 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::AccountStatistics
  2. 1 describe Bandwidth::AccountStatistics do
  3. 2 let(:account_statistics_default) { Bandwidth::AccountStatistics.new }
  4. 4 let(:account_statistics_values) { Bandwidth::AccountStatistics.new({
  5. current_call_queue_size: 1,
  6. max_call_queue_size: 100
  7. }) }
  8. 1 describe '#initialize' do
  9. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  10. 1 expect {
  11. 1 Bandwidth::AccountStatistics.new([])
  12. }.to raise_error(ArgumentError)
  13. end
  14. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  15. 1 expect {
  16. 1 Bandwidth::AccountStatistics.new({ invalid: true })
  17. }.to raise_error(ArgumentError)
  18. end
  19. end
  20. 1 describe '#acceptable_attributes' do
  21. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  22. 1 expect(Bandwidth::AccountStatistics.acceptable_attributes).to eq(Bandwidth::AccountStatistics.attribute_map.values)
  23. end
  24. end
  25. 1 describe '#openapi_nullable' do
  26. 1 it 'expects nullable attributes to be an empty set' do
  27. 1 expect(Bandwidth::AccountStatistics.openapi_nullable).to eq(Set.new([]))
  28. end
  29. end
  30. 1 describe '#build_from_hash' do
  31. 1 it 'validates instance of AccountStatistics created by the build_from_hash method' do
  32. 1 account_statistics_from_hash = Bandwidth::AccountStatistics.build_from_hash({
  33. currentCallQueueSize: 1,
  34. maxCallQueueSize: 100
  35. })
  36. 1 expect(account_statistics_from_hash).to be_instance_of(Bandwidth::AccountStatistics)
  37. 1 expect(account_statistics_from_hash.current_call_queue_size).to eq(1)
  38. 1 expect(account_statistics_from_hash.max_call_queue_size).to eq(100)
  39. end
  40. end
  41. 1 describe '#to_s' do
  42. 1 it 'returns a string representation of the object' do
  43. 1 expect(account_statistics_values.to_s).to eq('{:currentCallQueueSize=>1, :maxCallQueueSize=>100}')
  44. end
  45. end
  46. 1 describe '#eq? #==' do
  47. 1 it 'returns true/false when comparing objects' do
  48. 1 expect(account_statistics_default.eql?(Bandwidth::AccountStatistics.new)).to be true
  49. 1 expect(account_statistics_default.eql?(account_statistics_values)).to be false
  50. end
  51. end
  52. 1 describe '#to_body #to_hash' do
  53. 1 it 'returns a hash representation of the object' do
  54. 1 expect(account_statistics_values.to_body).to eq({
  55. currentCallQueueSize: 1,
  56. maxCallQueueSize: 100
  57. })
  58. end
  59. end
  60. end

spec/unit/models/additional_denial_reason_spec.rb

100.0% lines covered

44 relevant lines. 44 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::AdditionalDenialReason
  2. 1 describe Bandwidth::AdditionalDenialReason do
  3. 2 let(:additional_denial_reason_default) { Bandwidth::AdditionalDenialReason.new({
  4. status_code: 100,
  5. reason: 'baseline',
  6. resubmit_allowed: false
  7. }) }
  8. 4 let(:additional_denial_reason_values) { Bandwidth::AdditionalDenialReason.new({
  9. status_code: 200,
  10. reason: 'reason text',
  11. resubmit_allowed: true
  12. }) }
  13. 1 describe '#initialize' do
  14. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  15. 1 expect {
  16. 1 Bandwidth::AdditionalDenialReason.new([])
  17. }.to raise_error(ArgumentError)
  18. end
  19. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  20. 1 expect {
  21. 1 Bandwidth::AdditionalDenialReason.new({ invalid: true })
  22. }.to raise_error(ArgumentError)
  23. end
  24. end
  25. 1 describe '#acceptable_attributes' do
  26. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  27. 1 expect(Bandwidth::AdditionalDenialReason.acceptable_attributes).to eq(Bandwidth::AdditionalDenialReason.attribute_map.values)
  28. end
  29. end
  30. 1 describe '#openapi_nullable' do
  31. 1 it 'expects nullable attributes to be an empty set' do
  32. 1 expect(Bandwidth::AdditionalDenialReason.openapi_nullable).to eq(Set.new([]))
  33. end
  34. end
  35. 1 describe '#build_from_hash' do
  36. 1 it 'validates instance of AdditionalDenialReason created by the build_from_hash method' do
  37. 1 additional_denial_reason_from_hash = Bandwidth::AdditionalDenialReason.build_from_hash({
  38. statusCode: 200,
  39. reason: 'reason text',
  40. resubmitAllowed: true
  41. })
  42. 1 expect(additional_denial_reason_from_hash).to be_instance_of(Bandwidth::AdditionalDenialReason)
  43. 1 expect(additional_denial_reason_from_hash.status_code).to eq(200)
  44. 1 expect(additional_denial_reason_from_hash.reason).to eq('reason text')
  45. 1 expect(additional_denial_reason_from_hash.resubmit_allowed).to eq(true)
  46. end
  47. end
  48. 1 describe '#to_s' do
  49. 1 it 'returns a string representation of the object' do
  50. 1 expect(additional_denial_reason_values.to_s).to eq('{:statusCode=>200, :reason=>"reason text", :resubmitAllowed=>true}')
  51. end
  52. end
  53. 1 describe '#eq? #==' do
  54. 1 it 'returns true/false when comparing objects' do
  55. 1 additional_denial_reason_equal = Bandwidth::AdditionalDenialReason.new({
  56. status_code: 100,
  57. reason: 'baseline',
  58. resubmit_allowed: false
  59. })
  60. 1 expect(additional_denial_reason_default.eql?(additional_denial_reason_equal)).to be true
  61. 1 expect(additional_denial_reason_default.eql?(additional_denial_reason_values)).to be false
  62. end
  63. end
  64. 1 describe '#to_body #to_hash' do
  65. 1 it 'returns a hash representation of the object' do
  66. 1 expect(additional_denial_reason_values.to_body).to eq({
  67. statusCode: 200,
  68. reason: 'reason text',
  69. resubmitAllowed: true
  70. })
  71. end
  72. end
  73. 1 describe 'custom attribute writers' do
  74. 1 it '#status_code=' do
  75. 1 expect {
  76. 1 Bandwidth::AdditionalDenialReason.new({ status_code: nil, reason: 'a', resubmit_allowed: false })
  77. }.to raise_error(ArgumentError, 'status_code cannot be nil')
  78. end
  79. 1 it '#reason=' do
  80. 1 expect {
  81. 1 Bandwidth::AdditionalDenialReason.new({ status_code: 1, reason: nil, resubmit_allowed: false })
  82. }.to raise_error(ArgumentError, 'reason cannot be nil')
  83. end
  84. 1 it '#resubmit_allowed=' do
  85. 1 expect {
  86. 1 Bandwidth::AdditionalDenialReason.new({ status_code: 1, reason: 'a', resubmit_allowed: nil })
  87. }.to raise_error(ArgumentError, 'resubmit_allowed cannot be nil')
  88. end
  89. end
  90. end

spec/unit/models/address_spec.rb

100.0% lines covered

80 relevant lines. 80 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Address
  2. 1 describe Bandwidth::Address do
  3. 2 let(:address_default) { Bandwidth::Address.new({
  4. name: 'Bandwidth',
  5. addr1: '900 Main Campus Dr',
  6. city: 'Raleigh',
  7. state: 'NC',
  8. zip: '27606',
  9. url: 'https://www.bandwidth.com'
  10. }) }
  11. 4 let(:address_values) { Bandwidth::Address.new({
  12. name: 'Bandwidth',
  13. addr1: '900 Main Campus Dr',
  14. addr2: 'Suite 100',
  15. city: 'Raleigh',
  16. state: 'NC',
  17. zip: '27606',
  18. url: 'https://www.bandwidth.com'
  19. }) }
  20. 1 describe '#initialize' do
  21. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  22. 1 expect {
  23. 1 Bandwidth::Address.new([])
  24. }.to raise_error(ArgumentError)
  25. end
  26. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  27. 1 expect {
  28. 1 Bandwidth::Address.new({ invalid: true })
  29. }.to raise_error(ArgumentError)
  30. end
  31. end
  32. 1 describe '#acceptable_attributes' do
  33. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  34. 1 expect(Bandwidth::Address.acceptable_attributes).to eq(Bandwidth::Address.attribute_map.values)
  35. end
  36. end
  37. 1 describe '#openapi_nullable' do
  38. 1 it 'expects nullable attributes to be the set of nullable fields' do
  39. 1 expect(Bandwidth::Address.openapi_nullable).to eq(Set.new([:'addr2']))
  40. end
  41. end
  42. 1 describe '#build_from_hash' do
  43. 1 it 'validates instance of Address created by the build_from_hash method' do
  44. 1 address_from_hash = Bandwidth::Address.build_from_hash({
  45. name: 'Bandwidth',
  46. addr1: '900 Main Campus Dr',
  47. addr2: 'Suite 100',
  48. city: 'Raleigh',
  49. state: 'NC',
  50. zip: '27606',
  51. url: 'https://www.bandwidth.com'
  52. })
  53. 1 expect(address_from_hash).to be_instance_of(Bandwidth::Address)
  54. 1 expect(address_from_hash.name).to eq('Bandwidth')
  55. 1 expect(address_from_hash.addr1).to eq('900 Main Campus Dr')
  56. 1 expect(address_from_hash.addr2).to eq('Suite 100')
  57. 1 expect(address_from_hash.city).to eq('Raleigh')
  58. 1 expect(address_from_hash.state).to eq('NC')
  59. 1 expect(address_from_hash.zip).to eq('27606')
  60. 1 expect(address_from_hash.url).to eq('https://www.bandwidth.com')
  61. end
  62. end
  63. 1 describe '#to_s' do
  64. 1 it 'returns a string representation of the object' do
  65. 1 expect(address_values.to_s).to eq('{:name=>"Bandwidth", :addr1=>"900 Main Campus Dr", :addr2=>"Suite 100", :city=>"Raleigh", :state=>"NC", :zip=>"27606", :url=>"https://www.bandwidth.com"}')
  66. end
  67. end
  68. 1 describe '#eq? #==' do
  69. 1 it 'returns true/false when comparing objects' do
  70. 1 address_equal = Bandwidth::Address.new({
  71. name: 'Bandwidth',
  72. addr1: '900 Main Campus Dr',
  73. city: 'Raleigh',
  74. state: 'NC',
  75. zip: '27606',
  76. url: 'https://www.bandwidth.com'
  77. })
  78. 1 expect(address_default.eql?(address_equal)).to be true
  79. 1 expect(address_default.eql?(address_values)).to be false
  80. end
  81. end
  82. 1 describe '#to_body #to_hash' do
  83. 1 it 'returns a hash representation of the object' do
  84. 1 expect(address_values.to_body).to eq({
  85. name: 'Bandwidth',
  86. addr1: '900 Main Campus Dr',
  87. addr2: 'Suite 100',
  88. city: 'Raleigh',
  89. state: 'NC',
  90. zip: '27606',
  91. url: 'https://www.bandwidth.com'
  92. })
  93. end
  94. end
  95. 1 describe 'custom attribute writers' do
  96. 1 it '#name=' do
  97. 1 expect {
  98. 1 Bandwidth::Address.new({ name: nil })
  99. }.to raise_error(ArgumentError, 'name cannot be nil')
  100. 1 expect {
  101. 1 Bandwidth::Address.new({ name: 'a' * 501 })
  102. }.to raise_error(ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 500.')
  103. 1 expect {
  104. 1 Bandwidth::Address.new({ name: '' })
  105. }.to raise_error(ArgumentError, 'invalid value for "name", the character length must be greater than or equal to 1.')
  106. end
  107. 1 it '#addr1=' do
  108. 1 expect {
  109. 1 Bandwidth::Address.new({ name: 'Bandwidth', addr1: nil })
  110. }.to raise_error(ArgumentError, 'addr1 cannot be nil')
  111. 1 expect {
  112. 1 Bandwidth::Address.new({ name: 'Bandwidth', addr1: 'a' * 501 })
  113. }.to raise_error(ArgumentError, 'invalid value for "addr1", the character length must be smaller than or equal to 500.')
  114. 1 expect {
  115. 1 Bandwidth::Address.new({ name: 'Bandwidth', addr1: '' })
  116. }.to raise_error(ArgumentError, 'invalid value for "addr1", the character length must be greater than or equal to 1.')
  117. end
  118. 1 it '#addr2=' do
  119. 1 expect {
  120. 1 Bandwidth::Address.new({ name: 'Bandwidth', addr1: '900 Main Campus Dr', addr2: 'a' * 501, city: 'Raleigh', state: 'NC', zip: '27606', url: 'https://www.bandwidth.com' })
  121. }.to raise_error(ArgumentError, 'invalid value for "addr2", the character length must be smaller than or equal to 500.')
  122. end
  123. 1 it '#city=' do
  124. 1 expect {
  125. 1 Bandwidth::Address.new({ name: 'Bandwidth', addr1: '900 Main Campus Dr', city: nil })
  126. }.to raise_error(ArgumentError, 'city cannot be nil')
  127. 1 expect {
  128. 1 Bandwidth::Address.new({ name: 'Bandwidth', addr1: '900 Main Campus Dr', city: 'a' * 501 })
  129. }.to raise_error(ArgumentError, 'invalid value for "city", the character length must be smaller than or equal to 500.')
  130. 1 expect {
  131. 1 Bandwidth::Address.new({ name: 'Bandwidth', addr1: '900 Main Campus Dr', city: '' })
  132. }.to raise_error(ArgumentError, 'invalid value for "city", the character length must be greater than or equal to 1.')
  133. end
  134. 1 it '#state=' do
  135. 1 expect {
  136. 1 Bandwidth::Address.new({ name: 'Bandwidth', addr1: '900 Main Campus Dr', city: 'Raleigh', state: nil })
  137. }.to raise_error(ArgumentError, 'state cannot be nil')
  138. 1 expect {
  139. 1 Bandwidth::Address.new({ name: 'Bandwidth', addr1: '900 Main Campus Dr', city: 'Raleigh', state: 'a' * 501 })
  140. }.to raise_error(ArgumentError, 'invalid value for "state", the character length must be smaller than or equal to 500.')
  141. 1 expect {
  142. 1 Bandwidth::Address.new({ name: 'Bandwidth', addr1: '900 Main Campus Dr', city: 'Raleigh', state: '' })
  143. }.to raise_error(ArgumentError, 'invalid value for "state", the character length must be greater than or equal to 1.')
  144. end
  145. 1 it '#zip=' do
  146. 1 expect {
  147. 1 Bandwidth::Address.new({ name: 'Bandwidth', addr1: '900 Main Campus Dr', city: 'Raleigh', state: 'NC', zip: nil })
  148. }.to raise_error(ArgumentError, 'zip cannot be nil')
  149. end
  150. 1 it '#url=' do
  151. 1 expect {
  152. 1 Bandwidth::Address.new({ name: 'Bandwidth', addr1: '900 Main Campus Dr', city: 'Raleigh', state: 'NC', zip: '27606', url: nil })
  153. }.to raise_error(ArgumentError, 'url cannot be nil')
  154. 1 expect {
  155. 1 Bandwidth::Address.new({ name: 'Bandwidth', addr1: '900 Main Campus Dr', city: 'Raleigh', state: 'NC', zip: '27606', url: 'a' * 501 })
  156. }.to raise_error(ArgumentError, 'invalid value for "url", the character length must be smaller than or equal to 500.')
  157. 1 expect {
  158. 1 Bandwidth::Address.new({ name: 'Bandwidth', addr1: '900 Main Campus Dr', city: 'Raleigh', state: 'NC', zip: '27606', url: '' })
  159. }.to raise_error(ArgumentError, 'invalid value for "url", the character length must be greater than or equal to 1.')
  160. end
  161. end
  162. end

spec/unit/models/answer_callback_spec.rb

100.0% lines covered

46 relevant lines. 46 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::AnswerCallback
  2. 1 describe Bandwidth::AnswerCallback do
  3. 2 let(:answer_callback_default) { Bandwidth::AnswerCallback.new }
  4. 4 let(:answer_callback_values) { Bandwidth::AnswerCallback.new({
  5. event_type: 'answer',
  6. event_time: '2022-06-16T13:15:07.160Z',
  7. account_id: '9900000',
  8. application_id: '04e88489-df02-4e34-a0ee-27a91849555f',
  9. from: '+19195554321',
  10. to: '+19195551234',
  11. direction: Bandwidth::CallDirectionEnum::INBOUND,
  12. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  13. call_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  14. enqueued_time: '2022-06-16T13:15:07.160Z',
  15. start_time: '2022-06-16T13:15:07.160Z',
  16. answer_time: '2022-06-16T13:15:18.126Z',
  17. tag: 'custom tag',
  18. machine_detection_result: { value: 'human', duration: 'PT5S' }
  19. }) }
  20. 1 describe '#initialize' do
  21. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  22. 1 expect {
  23. 1 Bandwidth::AnswerCallback.new([])
  24. }.to raise_error(ArgumentError)
  25. end
  26. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  27. 1 expect {
  28. 1 Bandwidth::AnswerCallback.new({ invalid: true })
  29. }.to raise_error(ArgumentError)
  30. end
  31. end
  32. 1 describe '#acceptable_attributes' do
  33. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  34. 1 expect(Bandwidth::AnswerCallback.acceptable_attributes).to eq(Bandwidth::AnswerCallback.attribute_map.values)
  35. end
  36. end
  37. 1 describe '#openapi_nullable' do
  38. 1 it 'expects nullable attributes to be the set of nullable fields' do
  39. 1 expect(Bandwidth::AnswerCallback.openapi_nullable).to eq(Set.new([
  40. :'enqueued_time',
  41. :'answer_time',
  42. :'tag',
  43. :'machine_detection_result'
  44. ]))
  45. end
  46. end
  47. 1 describe '#build_from_hash' do
  48. 1 it 'validates instance of AnswerCallback created by the build_from_hash method' do
  49. 1 answer_callback_from_hash = Bandwidth::AnswerCallback.build_from_hash({
  50. eventType: 'answer',
  51. eventTime: '2022-06-16T13:15:07.160Z',
  52. accountId: '9900000',
  53. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  54. from: '+19195554321',
  55. to: '+19195551234',
  56. direction: Bandwidth::CallDirectionEnum::INBOUND,
  57. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  58. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  59. enqueuedTime: '2022-06-16T13:15:07.160Z',
  60. startTime: '2022-06-16T13:15:07.160Z',
  61. answerTime: '2022-06-16T13:15:18.126Z',
  62. tag: 'custom tag',
  63. machineDetectionResult: { value: 'human', duration: 'PT5S' }
  64. })
  65. 1 expect(answer_callback_from_hash).to be_instance_of(Bandwidth::AnswerCallback)
  66. 1 expect(answer_callback_from_hash.event_type).to eq('answer')
  67. 1 expect(answer_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  68. 1 expect(answer_callback_from_hash.account_id).to eq('9900000')
  69. 1 expect(answer_callback_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f')
  70. 1 expect(answer_callback_from_hash.from).to eq('+19195554321')
  71. 1 expect(answer_callback_from_hash.to).to eq('+19195551234')
  72. 1 expect(answer_callback_from_hash.direction).to eq(Bandwidth::CallDirectionEnum::INBOUND)
  73. 1 expect(answer_callback_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  74. 1 expect(answer_callback_from_hash.call_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  75. 1 expect(answer_callback_from_hash.enqueued_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  76. 1 expect(answer_callback_from_hash.start_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  77. 1 expect(answer_callback_from_hash.answer_time).to eq(Time.parse('2022-06-16T13:15:18.126Z'))
  78. 1 expect(answer_callback_from_hash.tag).to eq('custom tag')
  79. 1 expect(answer_callback_from_hash.machine_detection_result).to be_instance_of(Bandwidth::MachineDetectionResult)
  80. 1 expect(answer_callback_from_hash.machine_detection_result.value).to eq('human')
  81. 1 expect(answer_callback_from_hash.machine_detection_result.duration).to eq('PT5S')
  82. end
  83. end
  84. 1 describe '#to_s' do
  85. 1 it 'returns a string representation of the object' do
  86. 1 expect(answer_callback_values.to_s).to eq('{:eventType=>"answer", :eventTime=>"2022-06-16T13:15:07.160Z", :accountId=>"9900000", :applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :from=>"+19195554321", :to=>"+19195551234", :direction=>"inbound", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :callUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :enqueuedTime=>"2022-06-16T13:15:07.160Z", :startTime=>"2022-06-16T13:15:07.160Z", :answerTime=>"2022-06-16T13:15:18.126Z", :tag=>"custom tag", :machineDetectionResult=>{:value=>"human", :duration=>"PT5S"}}')
  87. end
  88. end
  89. 1 describe '#eq? #==' do
  90. 1 it 'returns true/false when comparing objects' do
  91. 1 expect(answer_callback_default.eql?(Bandwidth::AnswerCallback.new)).to be true
  92. 1 expect(answer_callback_default.eql?(answer_callback_values)).to be false
  93. end
  94. end
  95. 1 describe '#to_body #to_hash' do
  96. 1 it 'returns a hash representation of the object' do
  97. 1 expect(answer_callback_values.to_body).to eq({
  98. eventType: 'answer',
  99. eventTime: '2022-06-16T13:15:07.160Z',
  100. accountId: '9900000',
  101. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  102. from: '+19195554321',
  103. to: '+19195551234',
  104. direction: Bandwidth::CallDirectionEnum::INBOUND,
  105. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  106. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  107. enqueuedTime: '2022-06-16T13:15:07.160Z',
  108. startTime: '2022-06-16T13:15:07.160Z',
  109. answerTime: '2022-06-16T13:15:18.126Z',
  110. tag: 'custom tag',
  111. machineDetectionResult: { value: 'human', duration: 'PT5S' }
  112. })
  113. end
  114. end
  115. end

spec/unit/models/async_lookup_request_spec.rb

100.0% lines covered

36 relevant lines. 36 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::AsyncLookupRequest
  2. 1 describe Bandwidth::AsyncLookupRequest do
  3. 2 let(:async_lookup_request_default) { Bandwidth::AsyncLookupRequest.new({
  4. phone_numbers: ['+19195551234']
  5. }) }
  6. 5 let(:async_lookup_request_values) { Bandwidth::AsyncLookupRequest.new({
  7. phone_numbers: ['+19195551234', '+19195554321']
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::AsyncLookupRequest.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::AsyncLookupRequest.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::AsyncLookupRequest.acceptable_attributes).to eq(Bandwidth::AsyncLookupRequest.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be an empty set' do
  28. 1 expect(Bandwidth::AsyncLookupRequest.openapi_nullable).to eq(Set.new([]))
  29. end
  30. end
  31. 1 describe '#build_from_hash' do
  32. 1 it 'validates instance of AsyncLookupRequest created by the build_from_hash method' do
  33. 1 async_lookup_request_from_hash = Bandwidth::AsyncLookupRequest.build_from_hash({
  34. phoneNumbers: ['+19195551234', '+19195554321']
  35. })
  36. 1 expect(async_lookup_request_from_hash).to be_instance_of(Bandwidth::AsyncLookupRequest)
  37. 1 expect(async_lookup_request_from_hash.phone_numbers).to eq(['+19195551234', '+19195554321'])
  38. end
  39. end
  40. 1 describe '#to_s' do
  41. 1 it 'returns a string representation of the object' do
  42. 1 expect(async_lookup_request_values.to_s).to eq('{:phoneNumbers=>["+19195551234", "+19195554321"]}')
  43. end
  44. end
  45. 1 describe '#eq? #==' do
  46. 1 it 'returns true/false when comparing objects' do
  47. 1 async_lookup_request_equal = Bandwidth::AsyncLookupRequest.new({
  48. phone_numbers: ['+19195551234']
  49. })
  50. 1 expect(async_lookup_request_default.eql?(async_lookup_request_equal)).to be true
  51. 1 expect(async_lookup_request_default.eql?(async_lookup_request_values)).to be false
  52. end
  53. end
  54. 1 describe '#to_body #to_hash' do
  55. 1 it 'returns a hash representation of the object' do
  56. 1 expect(async_lookup_request_values.to_body).to eq({
  57. phoneNumbers: ['+19195551234', '+19195554321']
  58. })
  59. end
  60. end
  61. 1 describe 'custom attribute writers' do
  62. 1 it '#phone_numbers=' do
  63. 1 expect {
  64. 1 async_lookup_request_values.phone_numbers = nil
  65. }.to raise_error(ArgumentError, 'phone_numbers cannot be nil')
  66. end
  67. end
  68. end

spec/unit/models/blocked_webhook_spec.rb

100.0% lines covered

46 relevant lines. 46 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::BlockedWebhook
  2. 1 describe Bandwidth::BlockedWebhook do
  3. 2 let(:blocked_webhook_default) { Bandwidth::BlockedWebhook.new }
  4. 4 let(:blocked_webhook_values) { Bandwidth::BlockedWebhook.new({
  5. account_id: '9900000',
  6. phone_number: '+18005551234',
  7. status: 'VERIFIED',
  8. internal_ticket_number: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
  9. blocked: true,
  10. blocked_reason: 'spam'
  11. }) }
  12. 1 describe '#initialize' do
  13. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  14. 1 expect {
  15. 1 Bandwidth::BlockedWebhook.new([])
  16. }.to raise_error(ArgumentError)
  17. end
  18. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  19. 1 expect {
  20. 1 Bandwidth::BlockedWebhook.new({ invalid: true })
  21. }.to raise_error(ArgumentError)
  22. end
  23. end
  24. 1 describe '#acceptable_attributes' do
  25. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  26. 1 expect(Bandwidth::BlockedWebhook.acceptable_attributes).to eq(Bandwidth::BlockedWebhook.attribute_map.values)
  27. end
  28. end
  29. 1 describe '#openapi_nullable' do
  30. 1 it 'expects nullable attributes to be an empty set' do
  31. 1 expect(Bandwidth::BlockedWebhook.openapi_nullable).to eq(Set.new([]))
  32. end
  33. end
  34. 1 describe '#build_from_hash' do
  35. 1 it 'validates instance of BlockedWebhook created by the build_from_hash method' do
  36. 1 blocked_webhook_from_hash = Bandwidth::BlockedWebhook.build_from_hash({
  37. accountId: '9900000',
  38. phoneNumber: '+18005551234',
  39. status: 'VERIFIED',
  40. internalTicketNumber: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
  41. blocked: true,
  42. blockedReason: 'spam'
  43. })
  44. 1 expect(blocked_webhook_from_hash).to be_instance_of(Bandwidth::BlockedWebhook)
  45. 1 expect(blocked_webhook_from_hash.account_id).to eq('9900000')
  46. 1 expect(blocked_webhook_from_hash.phone_number).to eq('+18005551234')
  47. 1 expect(blocked_webhook_from_hash.status).to eq('VERIFIED')
  48. 1 expect(blocked_webhook_from_hash.internal_ticket_number).to eq('aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee')
  49. 1 expect(blocked_webhook_from_hash.blocked).to eq(true)
  50. 1 expect(blocked_webhook_from_hash.blocked_reason).to eq('spam')
  51. end
  52. end
  53. 1 describe '#to_s' do
  54. 1 it 'returns a string representation of the object' do
  55. 1 expect(blocked_webhook_values.to_s).to eq('{:accountId=>"9900000", :phoneNumber=>"+18005551234", :status=>"VERIFIED", :internalTicketNumber=>"aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", :blocked=>true, :blockedReason=>"spam"}')
  56. end
  57. end
  58. 1 describe '#eq? #==' do
  59. 1 it 'returns true/false when comparing objects' do
  60. 1 expect(blocked_webhook_default.eql?(Bandwidth::BlockedWebhook.new)).to be true
  61. 1 expect(blocked_webhook_default.eql?(blocked_webhook_values)).to be false
  62. end
  63. end
  64. 1 describe '#to_body #to_hash' do
  65. 1 it 'returns a hash representation of the object' do
  66. 1 expect(blocked_webhook_values.to_body).to eq({
  67. accountId: '9900000',
  68. phoneNumber: '+18005551234',
  69. status: 'VERIFIED',
  70. internalTicketNumber: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
  71. blocked: true,
  72. blockedReason: 'spam'
  73. })
  74. end
  75. end
  76. 1 describe 'custom attribute writers' do
  77. 1 it '#phone_number=' do
  78. 1 expect {
  79. 1 Bandwidth::BlockedWebhook.new({ phone_number: nil })
  80. }.to raise_error(ArgumentError, 'phone_number cannot be nil')
  81. 1 expect {
  82. 1 Bandwidth::BlockedWebhook.new({ phone_number: '+1800555123456' })
  83. }.to raise_error(ArgumentError, 'invalid value for "phone_number", the character length must be smaller than or equal to 12.')
  84. 1 expect {
  85. 1 Bandwidth::BlockedWebhook.new({ phone_number: '+1800555' })
  86. }.to raise_error(ArgumentError, 'invalid value for "phone_number", the character length must be greater than or equal to 12.')
  87. 1 expect {
  88. 1 Bandwidth::BlockedWebhook.new({ phone_number: '+19195551234' })
  89. }.to raise_error(ArgumentError, /invalid value for "phone_number", must conform to the pattern/)
  90. end
  91. end
  92. end

spec/unit/models/bridge_complete_callback_spec.rb

100.0% lines covered

46 relevant lines. 46 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::BridgeCompleteCallback
  2. 1 describe Bandwidth::BridgeCompleteCallback do
  3. 2 let(:bridge_complete_callback_default) { Bandwidth::BridgeCompleteCallback.new }
  4. 4 let(:bridge_complete_callback_values) { Bandwidth::BridgeCompleteCallback.new({
  5. event_type: 'bridgeComplete',
  6. event_time: '2022-06-16T13:15:07.160Z',
  7. account_id: '9900000',
  8. application_id: '04e88489-df02-4e34-a0ee-27a91849555f',
  9. from: '+19195554321',
  10. to: '+19195551234',
  11. direction: Bandwidth::CallDirectionEnum::OUTBOUND,
  12. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  13. call_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  14. enqueued_time: '2022-06-16T13:15:07.160Z',
  15. start_time: '2022-06-16T13:15:07.160Z',
  16. answer_time: '2022-06-16T13:15:18.126Z',
  17. tag: 'custom tag',
  18. cause: 'hangup',
  19. error_message: 'call rejected',
  20. error_id: '4642074b-7b58-478b-96e4-3a60955c6765'
  21. }) }
  22. 1 describe '#initialize' do
  23. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  24. 1 expect {
  25. 1 Bandwidth::BridgeCompleteCallback.new([])
  26. }.to raise_error(ArgumentError)
  27. end
  28. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  29. 1 expect {
  30. 1 Bandwidth::BridgeCompleteCallback.new({ invalid: true })
  31. }.to raise_error(ArgumentError)
  32. end
  33. end
  34. 1 describe '#acceptable_attributes' do
  35. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  36. 1 expect(Bandwidth::BridgeCompleteCallback.acceptable_attributes).to eq(Bandwidth::BridgeCompleteCallback.attribute_map.values)
  37. end
  38. end
  39. 1 describe '#openapi_nullable' do
  40. 1 it 'expects nullable attributes to be the set of nullable fields' do
  41. 1 expect(Bandwidth::BridgeCompleteCallback.openapi_nullable).to eq(Set.new([
  42. :'enqueued_time',
  43. :'answer_time',
  44. :'tag',
  45. :'error_message',
  46. :'error_id'
  47. ]))
  48. end
  49. end
  50. 1 describe '#build_from_hash' do
  51. 1 it 'validates instance of BridgeCompleteCallback created by the build_from_hash method' do
  52. 1 bridge_complete_callback_from_hash = Bandwidth::BridgeCompleteCallback.build_from_hash({
  53. eventType: 'bridgeComplete',
  54. eventTime: '2022-06-16T13:15:07.160Z',
  55. accountId: '9900000',
  56. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  57. from: '+19195554321',
  58. to: '+19195551234',
  59. direction: Bandwidth::CallDirectionEnum::OUTBOUND,
  60. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  61. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  62. enqueuedTime: '2022-06-16T13:15:07.160Z',
  63. startTime: '2022-06-16T13:15:07.160Z',
  64. answerTime: '2022-06-16T13:15:18.126Z',
  65. tag: 'custom tag',
  66. cause: 'hangup',
  67. errorMessage: 'call rejected',
  68. errorId: '4642074b-7b58-478b-96e4-3a60955c6765'
  69. })
  70. 1 expect(bridge_complete_callback_from_hash).to be_instance_of(Bandwidth::BridgeCompleteCallback)
  71. 1 expect(bridge_complete_callback_from_hash.event_type).to eq('bridgeComplete')
  72. 1 expect(bridge_complete_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  73. 1 expect(bridge_complete_callback_from_hash.account_id).to eq('9900000')
  74. 1 expect(bridge_complete_callback_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f')
  75. 1 expect(bridge_complete_callback_from_hash.from).to eq('+19195554321')
  76. 1 expect(bridge_complete_callback_from_hash.to).to eq('+19195551234')
  77. 1 expect(bridge_complete_callback_from_hash.direction).to eq(Bandwidth::CallDirectionEnum::OUTBOUND)
  78. 1 expect(bridge_complete_callback_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  79. 1 expect(bridge_complete_callback_from_hash.call_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  80. 1 expect(bridge_complete_callback_from_hash.enqueued_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  81. 1 expect(bridge_complete_callback_from_hash.start_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  82. 1 expect(bridge_complete_callback_from_hash.answer_time).to eq(Time.parse('2022-06-16T13:15:18.126Z'))
  83. 1 expect(bridge_complete_callback_from_hash.tag).to eq('custom tag')
  84. 1 expect(bridge_complete_callback_from_hash.cause).to eq('hangup')
  85. 1 expect(bridge_complete_callback_from_hash.error_message).to eq('call rejected')
  86. 1 expect(bridge_complete_callback_from_hash.error_id).to eq('4642074b-7b58-478b-96e4-3a60955c6765')
  87. end
  88. end
  89. 1 describe '#to_s' do
  90. 1 it 'returns a string representation of the object' do
  91. 1 expect(bridge_complete_callback_values.to_s).to eq('{:eventType=>"bridgeComplete", :eventTime=>"2022-06-16T13:15:07.160Z", :accountId=>"9900000", :applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :from=>"+19195554321", :to=>"+19195551234", :direction=>"outbound", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :callUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :enqueuedTime=>"2022-06-16T13:15:07.160Z", :startTime=>"2022-06-16T13:15:07.160Z", :answerTime=>"2022-06-16T13:15:18.126Z", :tag=>"custom tag", :cause=>"hangup", :errorMessage=>"call rejected", :errorId=>"4642074b-7b58-478b-96e4-3a60955c6765"}')
  92. end
  93. end
  94. 1 describe '#eq? #==' do
  95. 1 it 'returns true/false when comparing objects' do
  96. 1 expect(bridge_complete_callback_default.eql?(Bandwidth::BridgeCompleteCallback.new)).to be true
  97. 1 expect(bridge_complete_callback_default.eql?(bridge_complete_callback_values)).to be false
  98. end
  99. end
  100. 1 describe '#to_body #to_hash' do
  101. 1 it 'returns a hash representation of the object' do
  102. 1 expect(bridge_complete_callback_values.to_body).to eq({
  103. eventType: 'bridgeComplete',
  104. eventTime: '2022-06-16T13:15:07.160Z',
  105. accountId: '9900000',
  106. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  107. from: '+19195554321',
  108. to: '+19195551234',
  109. direction: Bandwidth::CallDirectionEnum::OUTBOUND,
  110. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  111. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  112. enqueuedTime: '2022-06-16T13:15:07.160Z',
  113. startTime: '2022-06-16T13:15:07.160Z',
  114. answerTime: '2022-06-16T13:15:18.126Z',
  115. tag: 'custom tag',
  116. cause: 'hangup',
  117. errorMessage: 'call rejected',
  118. errorId: '4642074b-7b58-478b-96e4-3a60955c6765'
  119. })
  120. end
  121. end
  122. end

spec/unit/models/bridge_target_complete_callback_spec.rb

100.0% lines covered

43 relevant lines. 43 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::BridgeTargetCompleteCallback
  2. 1 describe Bandwidth::BridgeTargetCompleteCallback do
  3. 2 let(:bridge_target_complete_callback_default) { Bandwidth::BridgeTargetCompleteCallback.new }
  4. 4 let(:bridge_target_complete_callback_values) { Bandwidth::BridgeTargetCompleteCallback.new({
  5. event_type: 'bridgeTargetComplete',
  6. event_time: '2022-06-16T13:15:07.160Z',
  7. account_id: '9900000',
  8. application_id: '04e88489-df02-4e34-a0ee-27a91849555f',
  9. from: '+19195554321',
  10. to: '+19195551234',
  11. direction: Bandwidth::CallDirectionEnum::OUTBOUND,
  12. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  13. call_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  14. enqueued_time: '2022-06-16T13:15:07.160Z',
  15. start_time: '2022-06-16T13:15:07.160Z',
  16. answer_time: '2022-06-16T13:15:18.126Z',
  17. tag: 'custom tag'
  18. }) }
  19. 1 describe '#initialize' do
  20. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  21. 1 expect {
  22. 1 Bandwidth::BridgeTargetCompleteCallback.new([])
  23. }.to raise_error(ArgumentError)
  24. end
  25. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  26. 1 expect {
  27. 1 Bandwidth::BridgeTargetCompleteCallback.new({ invalid: true })
  28. }.to raise_error(ArgumentError)
  29. end
  30. end
  31. 1 describe '#acceptable_attributes' do
  32. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  33. 1 expect(Bandwidth::BridgeTargetCompleteCallback.acceptable_attributes).to eq(Bandwidth::BridgeTargetCompleteCallback.attribute_map.values)
  34. end
  35. end
  36. 1 describe '#openapi_nullable' do
  37. 1 it 'expects nullable attributes to be the set of nullable fields' do
  38. 1 expect(Bandwidth::BridgeTargetCompleteCallback.openapi_nullable).to eq(Set.new([
  39. :'enqueued_time',
  40. :'answer_time',
  41. :'tag'
  42. ]))
  43. end
  44. end
  45. 1 describe '#build_from_hash' do
  46. 1 it 'validates instance of BridgeTargetCompleteCallback created by the build_from_hash method' do
  47. 1 bridge_target_complete_callback_from_hash = Bandwidth::BridgeTargetCompleteCallback.build_from_hash({
  48. eventType: 'bridgeTargetComplete',
  49. eventTime: '2022-06-16T13:15:07.160Z',
  50. accountId: '9900000',
  51. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  52. from: '+19195554321',
  53. to: '+19195551234',
  54. direction: Bandwidth::CallDirectionEnum::OUTBOUND,
  55. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  56. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  57. enqueuedTime: '2022-06-16T13:15:07.160Z',
  58. startTime: '2022-06-16T13:15:07.160Z',
  59. answerTime: '2022-06-16T13:15:18.126Z',
  60. tag: 'custom tag'
  61. })
  62. 1 expect(bridge_target_complete_callback_from_hash).to be_instance_of(Bandwidth::BridgeTargetCompleteCallback)
  63. 1 expect(bridge_target_complete_callback_from_hash.event_type).to eq('bridgeTargetComplete')
  64. 1 expect(bridge_target_complete_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  65. 1 expect(bridge_target_complete_callback_from_hash.account_id).to eq('9900000')
  66. 1 expect(bridge_target_complete_callback_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f')
  67. 1 expect(bridge_target_complete_callback_from_hash.from).to eq('+19195554321')
  68. 1 expect(bridge_target_complete_callback_from_hash.to).to eq('+19195551234')
  69. 1 expect(bridge_target_complete_callback_from_hash.direction).to eq(Bandwidth::CallDirectionEnum::OUTBOUND)
  70. 1 expect(bridge_target_complete_callback_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  71. 1 expect(bridge_target_complete_callback_from_hash.call_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  72. 1 expect(bridge_target_complete_callback_from_hash.enqueued_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  73. 1 expect(bridge_target_complete_callback_from_hash.start_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  74. 1 expect(bridge_target_complete_callback_from_hash.answer_time).to eq(Time.parse('2022-06-16T13:15:18.126Z'))
  75. 1 expect(bridge_target_complete_callback_from_hash.tag).to eq('custom tag')
  76. end
  77. end
  78. 1 describe '#to_s' do
  79. 1 it 'returns a string representation of the object' do
  80. 1 expect(bridge_target_complete_callback_values.to_s).to eq('{:eventType=>"bridgeTargetComplete", :eventTime=>"2022-06-16T13:15:07.160Z", :accountId=>"9900000", :applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :from=>"+19195554321", :to=>"+19195551234", :direction=>"outbound", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :callUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :enqueuedTime=>"2022-06-16T13:15:07.160Z", :startTime=>"2022-06-16T13:15:07.160Z", :answerTime=>"2022-06-16T13:15:18.126Z", :tag=>"custom tag"}')
  81. end
  82. end
  83. 1 describe '#eq? #==' do
  84. 1 it 'returns true/false when comparing objects' do
  85. 1 expect(bridge_target_complete_callback_default.eql?(Bandwidth::BridgeTargetCompleteCallback.new)).to be true
  86. 1 expect(bridge_target_complete_callback_default.eql?(bridge_target_complete_callback_values)).to be false
  87. end
  88. end
  89. 1 describe '#to_body #to_hash' do
  90. 1 it 'returns a hash representation of the object' do
  91. 1 expect(bridge_target_complete_callback_values.to_body).to eq({
  92. eventType: 'bridgeTargetComplete',
  93. eventTime: '2022-06-16T13:15:07.160Z',
  94. accountId: '9900000',
  95. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  96. from: '+19195554321',
  97. to: '+19195551234',
  98. direction: Bandwidth::CallDirectionEnum::OUTBOUND,
  99. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  100. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  101. enqueuedTime: '2022-06-16T13:15:07.160Z',
  102. startTime: '2022-06-16T13:15:07.160Z',
  103. answerTime: '2022-06-16T13:15:18.126Z',
  104. tag: 'custom tag'
  105. })
  106. end
  107. end
  108. end

spec/unit/models/brtc_error_response_spec.rb

100.0% lines covered

41 relevant lines. 41 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::BrtcErrorResponse
  2. 1 describe Bandwidth::BrtcErrorResponse do
  3. 2 let(:brtc_error_response_default) { Bandwidth::BrtcErrorResponse.new({
  4. links: [],
  5. errors: []
  6. }) }
  7. 6 let(:brtc_error_response_values) { Bandwidth::BrtcErrorResponse.new({
  8. links: [Bandwidth::BrtcLink.new({ href: 'https://example.com', rel: 'self', method: 'GET' })],
  9. data: { foo: 'bar' },
  10. errors: [Bandwidth::BrtcError.new({ type: 'validation', description: 'bad input' })]
  11. }) }
  12. 1 describe '#initialize' do
  13. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  14. 1 expect {
  15. 1 Bandwidth::BrtcErrorResponse.new([])
  16. }.to raise_error(ArgumentError)
  17. end
  18. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  19. 1 expect {
  20. 1 Bandwidth::BrtcErrorResponse.new({ invalid: true })
  21. }.to raise_error(ArgumentError)
  22. end
  23. end
  24. 1 describe '#acceptable_attributes' do
  25. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  26. 1 expect(Bandwidth::BrtcErrorResponse.acceptable_attributes).to eq(Bandwidth::BrtcErrorResponse.attribute_map.values)
  27. end
  28. end
  29. 1 describe '#openapi_nullable' do
  30. 1 it 'expects nullable attributes to be the set of nullable fields' do
  31. 1 expect(Bandwidth::BrtcErrorResponse.openapi_nullable).to eq(Set.new([:'data']))
  32. end
  33. end
  34. 1 describe '#build_from_hash' do
  35. 1 it 'validates instance of BrtcErrorResponse created by the build_from_hash method' do
  36. 1 brtc_error_response_from_hash = Bandwidth::BrtcErrorResponse.build_from_hash({
  37. links: [{ href: 'https://example.com', rel: 'self', method: 'GET' }],
  38. data: { foo: 'bar' },
  39. errors: [{ type: 'validation', description: 'bad input' }]
  40. })
  41. 1 expect(brtc_error_response_from_hash).to be_instance_of(Bandwidth::BrtcErrorResponse)
  42. 1 expect(brtc_error_response_from_hash.links.first).to be_instance_of(Bandwidth::BrtcLink)
  43. 1 expect(brtc_error_response_from_hash.data).to eq({ foo: 'bar' })
  44. 1 expect(brtc_error_response_from_hash.errors.first).to be_instance_of(Bandwidth::BrtcError)
  45. end
  46. end
  47. 1 describe '#to_s' do
  48. 1 it 'returns a string representation of the object' do
  49. 1 expect(brtc_error_response_values.to_s).to eq('{:links=>[{:href=>"https://example.com", :rel=>"self", :method=>"GET"}], :data=>{:foo=>"bar"}, :errors=>[{:type=>"validation", :description=>"bad input"}]}')
  50. end
  51. end
  52. 1 describe '#eq? #==' do
  53. 1 it 'returns true/false when comparing objects' do
  54. 1 brtc_error_response_equal = Bandwidth::BrtcErrorResponse.new({
  55. links: [],
  56. errors: []
  57. })
  58. 1 expect(brtc_error_response_default.eql?(brtc_error_response_equal)).to be true
  59. 1 expect(brtc_error_response_default.eql?(brtc_error_response_values)).to be false
  60. end
  61. end
  62. 1 describe '#to_body #to_hash' do
  63. 1 it 'returns a hash representation of the object' do
  64. 1 expect(brtc_error_response_values.to_body).to eq({
  65. links: [{ href: 'https://example.com', rel: 'self', method: 'GET' }],
  66. data: { foo: 'bar' },
  67. errors: [{ type: 'validation', description: 'bad input' }]
  68. })
  69. end
  70. end
  71. 1 describe 'custom attribute writers' do
  72. 1 it '#links=' do
  73. 1 expect {
  74. 1 brtc_error_response_values.links = nil
  75. }.to raise_error(ArgumentError, 'links cannot be nil')
  76. end
  77. 1 it '#errors=' do
  78. 1 expect {
  79. 1 brtc_error_response_values.errors = nil
  80. }.to raise_error(ArgumentError, 'errors cannot be nil')
  81. end
  82. end
  83. end

spec/unit/models/brtc_error_source_spec.rb

100.0% lines covered

34 relevant lines. 34 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::BrtcErrorSource
  2. 1 describe Bandwidth::BrtcErrorSource do
  3. 2 let(:brtc_error_source_default) { Bandwidth::BrtcErrorSource.new }
  4. 4 let(:brtc_error_source_values) { Bandwidth::BrtcErrorSource.new({
  5. parameter: 'limit',
  6. field: 'phoneNumber',
  7. header: 'Authorization',
  8. reference: '/accounts/9900000'
  9. }) }
  10. 1 describe '#initialize' do
  11. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  12. 1 expect {
  13. 1 Bandwidth::BrtcErrorSource.new([])
  14. }.to raise_error(ArgumentError)
  15. end
  16. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  17. 1 expect {
  18. 1 Bandwidth::BrtcErrorSource.new({ invalid: true })
  19. }.to raise_error(ArgumentError)
  20. end
  21. end
  22. 1 describe '#acceptable_attributes' do
  23. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  24. 1 expect(Bandwidth::BrtcErrorSource.acceptable_attributes).to eq(Bandwidth::BrtcErrorSource.attribute_map.values)
  25. end
  26. end
  27. 1 describe '#openapi_nullable' do
  28. 1 it 'expects nullable attributes to be an empty set' do
  29. 1 expect(Bandwidth::BrtcErrorSource.openapi_nullable).to eq(Set.new([]))
  30. end
  31. end
  32. 1 describe '#build_from_hash' do
  33. 1 it 'validates instance of BrtcErrorSource created by the build_from_hash method' do
  34. 1 brtc_error_source_from_hash = Bandwidth::BrtcErrorSource.build_from_hash({
  35. parameter: 'limit',
  36. field: 'phoneNumber',
  37. header: 'Authorization',
  38. reference: '/accounts/9900000'
  39. })
  40. 1 expect(brtc_error_source_from_hash).to be_instance_of(Bandwidth::BrtcErrorSource)
  41. 1 expect(brtc_error_source_from_hash.parameter).to eq('limit')
  42. 1 expect(brtc_error_source_from_hash.field).to eq('phoneNumber')
  43. 1 expect(brtc_error_source_from_hash.header).to eq('Authorization')
  44. 1 expect(brtc_error_source_from_hash.reference).to eq('/accounts/9900000')
  45. end
  46. end
  47. 1 describe '#to_s' do
  48. 1 it 'returns a string representation of the object' do
  49. 1 expect(brtc_error_source_values.to_s).to eq('{:parameter=>"limit", :field=>"phoneNumber", :header=>"Authorization", :reference=>"/accounts/9900000"}')
  50. end
  51. end
  52. 1 describe '#eq? #==' do
  53. 1 it 'returns true/false when comparing objects' do
  54. 1 expect(brtc_error_source_default.eql?(Bandwidth::BrtcErrorSource.new)).to be true
  55. 1 expect(brtc_error_source_default.eql?(brtc_error_source_values)).to be false
  56. end
  57. end
  58. 1 describe '#to_body #to_hash' do
  59. 1 it 'returns a hash representation of the object' do
  60. 1 expect(brtc_error_source_values.to_body).to eq({
  61. parameter: 'limit',
  62. field: 'phoneNumber',
  63. header: 'Authorization',
  64. reference: '/accounts/9900000'
  65. })
  66. end
  67. end
  68. end

spec/unit/models/brtc_error_spec.rb

100.0% lines covered

43 relevant lines. 43 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::BrtcError
  2. 1 describe Bandwidth::BrtcError do
  3. 2 let(:brtc_error_default) { Bandwidth::BrtcError.new({
  4. type: 'baseline',
  5. description: 'baseline description'
  6. }) }
  7. 4 let(:brtc_error_values) { Bandwidth::BrtcError.new({
  8. id: 'abc-123',
  9. type: 'validation',
  10. description: 'bad input',
  11. code: 'E1001',
  12. source: Bandwidth::BrtcErrorSource.new({ field: 'phoneNumber' })
  13. }) }
  14. 1 describe '#initialize' do
  15. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::BrtcError.new([])
  18. }.to raise_error(ArgumentError)
  19. end
  20. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  21. 1 expect {
  22. 1 Bandwidth::BrtcError.new({ invalid: true })
  23. }.to raise_error(ArgumentError)
  24. end
  25. end
  26. 1 describe '#acceptable_attributes' do
  27. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  28. 1 expect(Bandwidth::BrtcError.acceptable_attributes).to eq(Bandwidth::BrtcError.attribute_map.values)
  29. end
  30. end
  31. 1 describe '#openapi_nullable' do
  32. 1 it 'expects nullable attributes to be an empty set' do
  33. 1 expect(Bandwidth::BrtcError.openapi_nullable).to eq(Set.new([]))
  34. end
  35. end
  36. 1 describe '#build_from_hash' do
  37. 1 it 'validates instance of BrtcError created by the build_from_hash method' do
  38. 1 brtc_error_from_hash = Bandwidth::BrtcError.build_from_hash({
  39. id: 'abc-123',
  40. type: 'validation',
  41. description: 'bad input',
  42. code: 'E1001',
  43. source: { field: 'phoneNumber' }
  44. })
  45. 1 expect(brtc_error_from_hash).to be_instance_of(Bandwidth::BrtcError)
  46. 1 expect(brtc_error_from_hash.id).to eq('abc-123')
  47. 1 expect(brtc_error_from_hash.type).to eq('validation')
  48. 1 expect(brtc_error_from_hash.description).to eq('bad input')
  49. 1 expect(brtc_error_from_hash.code).to eq('E1001')
  50. 1 expect(brtc_error_from_hash.source).to be_instance_of(Bandwidth::BrtcErrorSource)
  51. end
  52. end
  53. 1 describe '#to_s' do
  54. 1 it 'returns a string representation of the object' do
  55. 1 expect(brtc_error_values.to_s).to eq('{:id=>"abc-123", :type=>"validation", :description=>"bad input", :code=>"E1001", :source=>{:field=>"phoneNumber"}}')
  56. end
  57. end
  58. 1 describe '#eq? #==' do
  59. 1 it 'returns true/false when comparing objects' do
  60. 1 brtc_error_equal = Bandwidth::BrtcError.new({
  61. type: 'baseline',
  62. description: 'baseline description'
  63. })
  64. 1 expect(brtc_error_default.eql?(brtc_error_equal)).to be true
  65. 1 expect(brtc_error_default.eql?(brtc_error_values)).to be false
  66. end
  67. end
  68. 1 describe '#to_body #to_hash' do
  69. 1 it 'returns a hash representation of the object' do
  70. 1 expect(brtc_error_values.to_body).to eq({
  71. id: 'abc-123',
  72. type: 'validation',
  73. description: 'bad input',
  74. code: 'E1001',
  75. source: { field: 'phoneNumber' }
  76. })
  77. end
  78. end
  79. 1 describe 'custom attribute writers' do
  80. 1 it '#type=' do
  81. 1 expect {
  82. 1 Bandwidth::BrtcError.new({ type: nil, description: 'a' })
  83. }.to raise_error(ArgumentError, 'type cannot be nil')
  84. end
  85. 1 it '#description=' do
  86. 1 expect {
  87. 1 Bandwidth::BrtcError.new({ type: 'a', description: nil })
  88. }.to raise_error(ArgumentError, 'description cannot be nil')
  89. end
  90. end
  91. end

spec/unit/models/brtc_link_spec.rb

100.0% lines covered

33 relevant lines. 33 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::BrtcLink
  2. 1 describe Bandwidth::BrtcLink do
  3. 2 let(:brtc_link_default) { Bandwidth::BrtcLink.new }
  4. 4 let(:brtc_link_values) { Bandwidth::BrtcLink.new({
  5. href: 'https://example.com',
  6. rel: 'self',
  7. method: 'GET'
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::BrtcLink.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::BrtcLink.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::BrtcLink.acceptable_attributes).to eq(Bandwidth::BrtcLink.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be an empty set' do
  28. 1 expect(Bandwidth::BrtcLink.openapi_nullable).to eq(Set.new([]))
  29. end
  30. end
  31. 1 describe '#build_from_hash' do
  32. 1 it 'validates instance of BrtcLink created by the build_from_hash method' do
  33. 1 brtc_link_from_hash = Bandwidth::BrtcLink.build_from_hash({
  34. href: 'https://example.com',
  35. rel: 'self',
  36. method: 'GET'
  37. })
  38. 1 expect(brtc_link_from_hash).to be_instance_of(Bandwidth::BrtcLink)
  39. 1 expect(brtc_link_from_hash.href).to eq('https://example.com')
  40. 1 expect(brtc_link_from_hash.rel).to eq('self')
  41. 1 expect(brtc_link_from_hash.method).to eq('GET')
  42. end
  43. end
  44. 1 describe '#to_s' do
  45. 1 it 'returns a string representation of the object' do
  46. 1 expect(brtc_link_values.to_s).to eq('{:href=>"https://example.com", :rel=>"self", :method=>"GET"}')
  47. end
  48. end
  49. 1 describe '#eq? #==' do
  50. 1 it 'returns true/false when comparing objects' do
  51. 1 expect(brtc_link_default.eql?(Bandwidth::BrtcLink.new)).to be true
  52. 1 expect(brtc_link_default.eql?(brtc_link_values)).to be false
  53. end
  54. end
  55. 1 describe '#to_body #to_hash' do
  56. 1 it 'returns a hash representation of the object' do
  57. 1 expect(brtc_link_values.to_body).to eq({
  58. href: 'https://example.com',
  59. rel: 'self',
  60. method: 'GET'
  61. })
  62. end
  63. end
  64. end

spec/unit/models/business_entity_type_enum_spec.rb

100.0% lines covered

25 relevant lines. 25 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::BusinessEntityTypeEnum
  2. 1 describe Bandwidth::BusinessEntityTypeEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines SOLE_PROPRIETOR' do
  5. 1 expect(Bandwidth::BusinessEntityTypeEnum::SOLE_PROPRIETOR).to eq('SOLE_PROPRIETOR')
  6. end
  7. 1 it 'defines PRIVATE_PROFIT' do
  8. 1 expect(Bandwidth::BusinessEntityTypeEnum::PRIVATE_PROFIT).to eq('PRIVATE_PROFIT')
  9. end
  10. 1 it 'defines PUBLIC_PROFIT' do
  11. 1 expect(Bandwidth::BusinessEntityTypeEnum::PUBLIC_PROFIT).to eq('PUBLIC_PROFIT')
  12. end
  13. 1 it 'defines NON_PROFIT' do
  14. 1 expect(Bandwidth::BusinessEntityTypeEnum::NON_PROFIT).to eq('NON_PROFIT')
  15. end
  16. 1 it 'defines GOVERNMENT' do
  17. 1 expect(Bandwidth::BusinessEntityTypeEnum::GOVERNMENT).to eq('GOVERNMENT')
  18. end
  19. end
  20. 1 describe '.all_vars' do
  21. 1 it 'returns every valid enum value' do
  22. 1 expect(Bandwidth::BusinessEntityTypeEnum.all_vars).to eq([
  23. 'SOLE_PROPRIETOR',
  24. 'PRIVATE_PROFIT',
  25. 'PUBLIC_PROFIT',
  26. 'NON_PROFIT',
  27. 'GOVERNMENT'
  28. ])
  29. end
  30. end
  31. 1 describe '.build_from_hash' do
  32. 1 it 'returns the value when it matches a valid enum value' do
  33. 1 expect(Bandwidth::BusinessEntityTypeEnum.build_from_hash('SOLE_PROPRIETOR')).to eq('SOLE_PROPRIETOR')
  34. 1 expect(Bandwidth::BusinessEntityTypeEnum.build_from_hash('PRIVATE_PROFIT')).to eq('PRIVATE_PROFIT')
  35. 1 expect(Bandwidth::BusinessEntityTypeEnum.build_from_hash('PUBLIC_PROFIT')).to eq('PUBLIC_PROFIT')
  36. 1 expect(Bandwidth::BusinessEntityTypeEnum.build_from_hash('NON_PROFIT')).to eq('NON_PROFIT')
  37. 1 expect(Bandwidth::BusinessEntityTypeEnum.build_from_hash('GOVERNMENT')).to eq('GOVERNMENT')
  38. end
  39. 1 it 'raises an error for an invalid enum value' do
  40. 1 expect {
  41. 1 Bandwidth::BusinessEntityTypeEnum.build_from_hash('invalid')
  42. }.to raise_error(RuntimeError)
  43. end
  44. end
  45. end

spec/unit/models/business_registration_type_enum_spec.rb

100.0% lines covered

64 relevant lines. 64 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::BusinessRegistrationTypeEnum
  2. 1 describe Bandwidth::BusinessRegistrationTypeEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines EIN' do
  5. 1 expect(Bandwidth::BusinessRegistrationTypeEnum::EIN).to eq('EIN')
  6. end
  7. 1 it 'defines CBN' do
  8. 1 expect(Bandwidth::BusinessRegistrationTypeEnum::CBN).to eq('CBN')
  9. end
  10. 1 it 'defines NEQ' do
  11. 1 expect(Bandwidth::BusinessRegistrationTypeEnum::NEQ).to eq('NEQ')
  12. end
  13. 1 it 'defines PROVINCIAL_NUMBER' do
  14. 1 expect(Bandwidth::BusinessRegistrationTypeEnum::PROVINCIAL_NUMBER).to eq('PROVINCIAL_NUMBER')
  15. end
  16. 1 it 'defines CRN' do
  17. 1 expect(Bandwidth::BusinessRegistrationTypeEnum::CRN).to eq('CRN')
  18. end
  19. 1 it 'defines VAT' do
  20. 1 expect(Bandwidth::BusinessRegistrationTypeEnum::VAT).to eq('VAT')
  21. end
  22. 1 it 'defines ACN' do
  23. 1 expect(Bandwidth::BusinessRegistrationTypeEnum::ACN).to eq('ACN')
  24. end
  25. 1 it 'defines ABN' do
  26. 1 expect(Bandwidth::BusinessRegistrationTypeEnum::ABN).to eq('ABN')
  27. end
  28. 1 it 'defines BRN' do
  29. 1 expect(Bandwidth::BusinessRegistrationTypeEnum::BRN).to eq('BRN')
  30. end
  31. 1 it 'defines SIREN' do
  32. 1 expect(Bandwidth::BusinessRegistrationTypeEnum::SIREN).to eq('SIREN')
  33. end
  34. 1 it 'defines SIRET' do
  35. 1 expect(Bandwidth::BusinessRegistrationTypeEnum::SIRET).to eq('SIRET')
  36. end
  37. 1 it 'defines NZBN' do
  38. 1 expect(Bandwidth::BusinessRegistrationTypeEnum::NZBN).to eq('NZBN')
  39. end
  40. 1 it 'defines UST_IDNR' do
  41. 1 expect(Bandwidth::BusinessRegistrationTypeEnum::UST_IDNR).to eq('UST_IDNR')
  42. end
  43. 1 it 'defines CIF' do
  44. 1 expect(Bandwidth::BusinessRegistrationTypeEnum::CIF).to eq('CIF')
  45. end
  46. 1 it 'defines NIF' do
  47. 1 expect(Bandwidth::BusinessRegistrationTypeEnum::NIF).to eq('NIF')
  48. end
  49. 1 it 'defines CNPJ' do
  50. 1 expect(Bandwidth::BusinessRegistrationTypeEnum::CNPJ).to eq('CNPJ')
  51. end
  52. 1 it 'defines UID' do
  53. 1 expect(Bandwidth::BusinessRegistrationTypeEnum::UID).to eq('UID')
  54. end
  55. 1 it 'defines OTHER' do
  56. 1 expect(Bandwidth::BusinessRegistrationTypeEnum::OTHER).to eq('OTHER')
  57. end
  58. end
  59. 1 describe '.all_vars' do
  60. 1 it 'returns every valid enum value' do
  61. 1 expect(Bandwidth::BusinessRegistrationTypeEnum.all_vars).to eq([
  62. 'EIN',
  63. 'CBN',
  64. 'NEQ',
  65. 'PROVINCIAL_NUMBER',
  66. 'CRN',
  67. 'VAT',
  68. 'ACN',
  69. 'ABN',
  70. 'BRN',
  71. 'SIREN',
  72. 'SIRET',
  73. 'NZBN',
  74. 'UST_IDNR',
  75. 'CIF',
  76. 'NIF',
  77. 'CNPJ',
  78. 'UID',
  79. 'OTHER'
  80. ])
  81. end
  82. end
  83. 1 describe '.build_from_hash' do
  84. 1 it 'returns the value when it matches a valid enum value' do
  85. 1 expect(Bandwidth::BusinessRegistrationTypeEnum.build_from_hash('EIN')).to eq('EIN')
  86. 1 expect(Bandwidth::BusinessRegistrationTypeEnum.build_from_hash('CBN')).to eq('CBN')
  87. 1 expect(Bandwidth::BusinessRegistrationTypeEnum.build_from_hash('NEQ')).to eq('NEQ')
  88. 1 expect(Bandwidth::BusinessRegistrationTypeEnum.build_from_hash('PROVINCIAL_NUMBER')).to eq('PROVINCIAL_NUMBER')
  89. 1 expect(Bandwidth::BusinessRegistrationTypeEnum.build_from_hash('CRN')).to eq('CRN')
  90. 1 expect(Bandwidth::BusinessRegistrationTypeEnum.build_from_hash('VAT')).to eq('VAT')
  91. 1 expect(Bandwidth::BusinessRegistrationTypeEnum.build_from_hash('ACN')).to eq('ACN')
  92. 1 expect(Bandwidth::BusinessRegistrationTypeEnum.build_from_hash('ABN')).to eq('ABN')
  93. 1 expect(Bandwidth::BusinessRegistrationTypeEnum.build_from_hash('BRN')).to eq('BRN')
  94. 1 expect(Bandwidth::BusinessRegistrationTypeEnum.build_from_hash('SIREN')).to eq('SIREN')
  95. 1 expect(Bandwidth::BusinessRegistrationTypeEnum.build_from_hash('SIRET')).to eq('SIRET')
  96. 1 expect(Bandwidth::BusinessRegistrationTypeEnum.build_from_hash('NZBN')).to eq('NZBN')
  97. 1 expect(Bandwidth::BusinessRegistrationTypeEnum.build_from_hash('UST_IDNR')).to eq('UST_IDNR')
  98. 1 expect(Bandwidth::BusinessRegistrationTypeEnum.build_from_hash('CIF')).to eq('CIF')
  99. 1 expect(Bandwidth::BusinessRegistrationTypeEnum.build_from_hash('NIF')).to eq('NIF')
  100. 1 expect(Bandwidth::BusinessRegistrationTypeEnum.build_from_hash('CNPJ')).to eq('CNPJ')
  101. 1 expect(Bandwidth::BusinessRegistrationTypeEnum.build_from_hash('UID')).to eq('UID')
  102. 1 expect(Bandwidth::BusinessRegistrationTypeEnum.build_from_hash('OTHER')).to eq('OTHER')
  103. end
  104. 1 it 'raises an error for an invalid enum value' do
  105. 1 expect {
  106. 1 Bandwidth::BusinessRegistrationTypeEnum.build_from_hash('invalid')
  107. }.to raise_error(RuntimeError)
  108. end
  109. end
  110. end

spec/unit/models/bxml/bxml_spec.rb

100.0% lines covered

26 relevant lines. 26 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::Bxml
  2. 1 describe 'Bandwidth::Bxml::Bxml' do
  3. 5 let(:instance) { Bandwidth::Bxml::Bxml.new }
  4. 5 let(:pause_recording) { Bandwidth::Bxml::PauseRecording.new }
  5. 1 describe 'test an instance of Bxml' do
  6. 1 it 'validates instance of Bxml' do
  7. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::Bxml)
  8. 1 expect(instance).to be_a(Bandwidth::Bxml::Root)
  9. end
  10. 1 it 'test initializing with a single nested verb' do
  11. 1 instance = Bandwidth::Bxml::Bxml.new(pause_recording)
  12. 1 expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Bxml>\n <PauseRecording/>\n</Bxml>\n"
  13. 1 expect(instance.to_bxml).to eq(expected)
  14. end
  15. 1 it 'test initializing with multiple nested verbs' do
  16. 1 instance = Bandwidth::Bxml::Bxml.new([pause_recording, pause_recording])
  17. 1 expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Bxml>\n <PauseRecording/>\n <PauseRecording/>\n</Bxml>\n"
  18. 1 expect(instance.to_bxml).to eq(expected)
  19. end
  20. 1 it 'test adding a single verb to the Bxml instance' do
  21. 1 instance.add_verbs(pause_recording)
  22. 1 expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Bxml>\n <PauseRecording/>\n</Bxml>\n"
  23. 1 expect(instance.to_bxml).to eq(expected)
  24. end
  25. 1 it 'test adding multiple verbs to the Bxml instance' do
  26. 1 instance.add_verbs([pause_recording, pause_recording])
  27. 1 expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Bxml>\n <PauseRecording/>\n <PauseRecording/>\n</Bxml>\n"
  28. 1 expect(instance.to_bxml).to eq(expected)
  29. end
  30. 1 it 'test the to_bxml method of the Bxml instance' do
  31. 1 expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Bxml/>\n"
  32. 1 expect(instance.to_bxml).to eq(expected)
  33. end
  34. end
  35. end

spec/unit/models/bxml/nestable_verb_spec.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::NestableVerb
  2. 1 describe 'Bandwidth::Bxml::NestableVerb' do
  3. 2 let(:instance) { Bandwidth::Bxml::NestableVerb.new('Test') }
  4. 1 describe 'test an instance of NestableVerb' do
  5. 1 it 'validates instance of NestableVerb' do
  6. 1 expect(instance).to be_a(Bandwidth::Bxml::NestableVerb)
  7. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  8. end
  9. end
  10. end

spec/unit/models/bxml/response_spec.rb

100.0% lines covered

26 relevant lines. 26 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::Response
  2. 1 describe 'Bandwidth::Bxml::Response' do
  3. 5 let(:instance) { Bandwidth::Bxml::Response.new }
  4. 5 let(:pause_recording) { Bandwidth::Bxml::PauseRecording.new }
  5. 1 describe 'test an instance of Response' do
  6. 1 it 'validates instance of Response' do
  7. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::Response)
  8. 1 expect(instance).to be_a(Bandwidth::Bxml::Root)
  9. end
  10. 1 it 'test initializing with a single nested verb' do
  11. 1 instance = Bandwidth::Bxml::Response.new(pause_recording)
  12. 1 expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Response>\n <PauseRecording/>\n</Response>\n"
  13. 1 expect(instance.to_bxml).to eq(expected)
  14. end
  15. 1 it 'test initializing with multiple nested verbs' do
  16. 1 instance = Bandwidth::Bxml::Response.new([pause_recording, pause_recording])
  17. 1 expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Response>\n <PauseRecording/>\n <PauseRecording/>\n</Response>\n"
  18. 1 expect(instance.to_bxml).to eq(expected)
  19. end
  20. 1 it 'test adding a single verb to the Response instance' do
  21. 1 instance.add_verbs(pause_recording)
  22. 1 expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Response>\n <PauseRecording/>\n</Response>\n"
  23. 1 expect(instance.to_bxml).to eq(expected)
  24. end
  25. 1 it 'test adding multiple verbs to the Response instance' do
  26. 1 instance.add_verbs([pause_recording, pause_recording])
  27. 1 expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Response>\n <PauseRecording/>\n <PauseRecording/>\n</Response>\n"
  28. 1 expect(instance.to_bxml).to eq(expected)
  29. end
  30. 1 it 'test the to_bxml method of the Response instance' do
  31. 1 expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Response/>\n"
  32. 1 expect(instance.to_bxml).to eq(expected)
  33. end
  34. end
  35. end

spec/unit/models/bxml/verb_spec.rb

100.0% lines covered

8 relevant lines. 8 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::Verb
  2. 1 describe 'Bandwidth::Bxml::Verb' do
  3. 3 let(:instance) { Bandwidth::Bxml::Verb.new('Test') }
  4. 1 describe 'test an instance of Verb' do
  5. 1 it 'validates instance of Verb' do
  6. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  7. end
  8. 1 it 'tests the to_bxml method of the Verb instance' do
  9. 1 expected = "\n<Test/>\n"
  10. 1 expect(instance.to_bxml).to eq(expected)
  11. end
  12. end
  13. end

spec/unit/models/bxml/verbs/bridge_spec.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::Bridge
  2. 1 describe 'Bandwidth::Bxml::Bridge' do
  3. 1 let(:initial_attributes) {
  4. {
  5. 3 bridge_complete_url: 'https://initial.com',
  6. bridge_complete_method: 'POST',
  7. bridge_complete_fallback_url: 'https://initial.com',
  8. bridge_complete_fallback_method: 'POST',
  9. bridge_target_complete_url: 'https://initial.com',
  10. bridge_target_complete_method: 'POST',
  11. bridge_target_complete_fallback_url: 'https://initial.com',
  12. bridge_target_complete_fallback_method: 'POST',
  13. username: 'initial_username',
  14. password: 'initial_password',
  15. fallback_username: 'initial_fallback_username',
  16. fallback_password: 'initial_fallback_password',
  17. tag: 'initial_tag'
  18. }
  19. }
  20. 1 let(:new_attributes) {
  21. {
  22. 1 bridge_complete_url: 'https://new.com',
  23. bridge_complete_method: 'GET',
  24. bridge_complete_fallback_url: 'https://new.com',
  25. bridge_complete_fallback_method: 'GET',
  26. bridge_target_complete_url: 'https://new.com',
  27. bridge_target_complete_method: 'GET',
  28. bridge_target_complete_fallback_url: 'https://new.com',
  29. bridge_target_complete_fallback_method: 'GET',
  30. username: 'new_username',
  31. password: 'new_password',
  32. fallback_username: 'new_fallback_username',
  33. fallback_password: 'new_fallback_password',
  34. tag: 'new_tag'
  35. }
  36. }
  37. 4 let(:instance) { Bandwidth::Bxml::Bridge.new('c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d', initial_attributes) }
  38. 1 describe 'test an instance of Bridge' do
  39. 1 it 'validates instance of Bridge' do
  40. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::Bridge)
  41. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  42. end
  43. 1 it 'tests the to_bxml method of the Bridge instance' do
  44. 1 expected = "\n<Bridge bridgeCompleteUrl=\"https://initial.com\" bridgeCompleteMethod=\"POST\" bridgeCompleteFallbackUrl=\"https://initial.com\" bridgeCompleteFallbackMethod=\"POST\" bridgeTargetCompleteUrl=\"https://initial.com\" bridgeTargetCompleteMethod=\"POST\" bridgeTargetCompleteFallbackUrl=\"https://initial.com\" bridgeTargetCompleteFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\">c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d</Bridge>\n"
  45. 1 expect(instance.to_bxml).to eq(expected)
  46. end
  47. 1 it 'tests the set_attributes method of the Bridge instance' do
  48. 1 instance.set_attributes(new_attributes)
  49. 1 expected = "\n<Bridge bridgeCompleteUrl=\"https://new.com\" bridgeCompleteMethod=\"GET\" bridgeCompleteFallbackUrl=\"https://new.com\" bridgeCompleteFallbackMethod=\"GET\" bridgeTargetCompleteUrl=\"https://new.com\" bridgeTargetCompleteMethod=\"GET\" bridgeTargetCompleteFallbackUrl=\"https://new.com\" bridgeTargetCompleteFallbackMethod=\"GET\" username=\"new_username\" password=\"new_password\" fallbackUsername=\"new_fallback_username\" fallbackPassword=\"new_fallback_password\" tag=\"new_tag\">c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d</Bridge>\n"
  50. 1 expect(instance.to_bxml).to eq(expected)
  51. end
  52. end
  53. end

spec/unit/models/bxml/verbs/conference_spec.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::Conference
  2. 1 describe 'Bandwidth::Bxml::Conference' do
  3. 1 let(:initial_attributes) {
  4. {
  5. 3 mute: true,
  6. hold: true,
  7. call_ids_to_coach: 'initial',
  8. conference_event_url: 'https://initial.com',
  9. conference_event_method: 'POST',
  10. conference_event_fallback_url: 'https://initial.com',
  11. conference_event_fallback_method: 'POST',
  12. username: 'initial_username',
  13. password: 'initial_password',
  14. fallback_username: 'initial_fallback_username',
  15. fallback_password: 'initial_fallback_password',
  16. tag: 'initial_tag',
  17. callback_timeout: 5.0
  18. }
  19. }
  20. 1 let(:new_attributes) {
  21. {
  22. 1 mute: false,
  23. hold: false,
  24. call_ids_to_coach: 'new',
  25. conference_event_url: 'https://new.com',
  26. conference_event_method: 'GET',
  27. conference_event_fallback_url: 'https://new.com',
  28. conference_event_fallback_method: 'GET',
  29. username: 'new_username',
  30. password: 'new_password',
  31. fallback_username: 'new_fallback_username',
  32. fallback_password: 'new_fallback_password',
  33. tag: 'new_tag',
  34. callback_timeout: 10.0
  35. }
  36. }
  37. 4 let(:instance) { Bandwidth::Bxml::Conference.new('conference_name', initial_attributes) }
  38. 1 describe 'test an instance of Conference' do
  39. 1 it 'validates instance of Conference' do
  40. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::Conference)
  41. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  42. end
  43. 1 it 'tests the to_bxml method of the Conference instance' do
  44. 1 expected = "\n<Conference mute=\"true\" hold=\"true\" callIdsToCoach=\"initial\" conferenceEventUrl=\"https://initial.com\" conferenceEventMethod=\"POST\" conferenceEventFallbackUrl=\"https://initial.com\" conferenceEventFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" callbackTimeout=\"5.0\">conference_name</Conference>\n"
  45. 1 expect(instance.to_bxml).to eq(expected)
  46. end
  47. 1 it 'tests the set_attributes method of the Conference instance' do
  48. 1 instance.set_attributes(new_attributes)
  49. 1 expected = "\n<Conference mute=\"false\" hold=\"false\" callIdsToCoach=\"new\" conferenceEventUrl=\"https://new.com\" conferenceEventMethod=\"GET\" conferenceEventFallbackUrl=\"https://new.com\" conferenceEventFallbackMethod=\"GET\" username=\"new_username\" password=\"new_password\" fallbackUsername=\"new_fallback_username\" fallbackPassword=\"new_fallback_password\" tag=\"new_tag\" callbackTimeout=\"10.0\">conference_name</Conference>\n"
  50. 1 expect(instance.to_bxml).to eq(expected)
  51. end
  52. end
  53. end

spec/unit/models/bxml/verbs/custom_param_spec.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::CustomParam
  2. 1 describe 'Bandwidth::Bxml::CustomParam' do
  3. 1 let(:initial_attributes) {
  4. {
  5. 3 name: 'initial_name',
  6. value: 'initial_value'
  7. }
  8. }
  9. 1 let(:new_attributes) {
  10. {
  11. 1 name: 'new_name',
  12. value: 'new_value'
  13. }
  14. }
  15. 4 let(:instance) { Bandwidth::Bxml::CustomParam.new(initial_attributes) }
  16. 1 describe 'test an instance of CustomParam' do
  17. 1 it 'validates instance of CustomParam' do
  18. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::CustomParam)
  19. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  20. end
  21. 1 it 'tests the to_bxml method of the CustomParam instance' do
  22. 1 expected = "\n<CustomParam name=\"initial_name\" value=\"initial_value\"/>\n"
  23. 1 expect(instance.to_bxml).to eq(expected)
  24. end
  25. 1 it 'tests the set_attributes method of the CustomParam instance' do
  26. 1 instance.set_attributes(new_attributes)
  27. 1 expected = "\n<CustomParam name=\"new_name\" value=\"new_value\"/>\n"
  28. 1 expect(instance.to_bxml).to eq(expected)
  29. end
  30. end
  31. end

spec/unit/models/bxml/verbs/forward_spec.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::Forward
  2. 1 describe 'Bandwidth::Bxml::Forward' do
  3. 1 let(:initial_attributes) {
  4. {
  5. 3 to: '+19195551234',
  6. from: '+19195554321',
  7. call_timeout: 5,
  8. diversion_treatment: 'propagate',
  9. diversion_reason: 'user-busy',
  10. uui: '93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt'
  11. }
  12. }
  13. 1 let(:new_attributes) {
  14. {
  15. 1 to: '+19195554321',
  16. from: '+19195551234',
  17. call_timeout: 10,
  18. diversion_treatment: 'stack',
  19. diversion_reason: 'no-answer',
  20. uui: '4fa28015d8ede84bd1a493d6f3c0be5845960b74;encoding=base64,fdsa;encoding=jwt'
  21. }
  22. }
  23. 4 let(:instance) { Bandwidth::Bxml::Forward.new(initial_attributes) }
  24. 1 describe 'test an instance of Forward' do
  25. 1 it 'validates instance of Forward' do
  26. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::Forward)
  27. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  28. end
  29. 1 it 'tests the to_bxml method of the Forward instance' do
  30. 1 expected = "\n<Forward to=\"+19195551234\" from=\"+19195554321\" callTimeout=\"5\" diversionTreatment=\"propagate\" diversionReason=\"user-busy\" uui=\"93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt\"/>\n"
  31. 1 expect(instance.to_bxml).to eq(expected)
  32. end
  33. 1 it 'tests the set_attributes method of the Forward instance' do
  34. 1 instance.set_attributes(new_attributes)
  35. 1 expected = "\n<Forward to=\"+19195554321\" from=\"+19195551234\" callTimeout=\"10\" diversionTreatment=\"stack\" diversionReason=\"no-answer\" uui=\"4fa28015d8ede84bd1a493d6f3c0be5845960b74;encoding=base64,fdsa;encoding=jwt\"/>\n"
  36. 1 expect(instance.to_bxml).to eq(expected)
  37. end
  38. end
  39. end

spec/unit/models/bxml/verbs/gather_spec.rb

100.0% lines covered

34 relevant lines. 34 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::Gather
  2. 1 describe 'Bandwidth::Bxml::Gather' do
  3. 1 let(:initial_attributes) {
  4. {
  5. 6 gather_url: 'https://initial.com',
  6. gather_method: 'POST',
  7. gather_fallback_url: 'https://initial.com',
  8. gather_fallback_method: 'POST',
  9. username: 'initial_username',
  10. password: 'initial_password',
  11. fallback_username: 'initial_fallback_username',
  12. fallback_password: 'initial_fallback_password',
  13. tag: 'initial_tag',
  14. terminating_digits: '5',
  15. max_digits: 5,
  16. inter_digit_timeout: 5,
  17. first_digit_timeout: 5,
  18. repeat_count: 5
  19. }
  20. }
  21. 1 let(:new_attributes) {
  22. {
  23. 1 gather_url: 'https://new.com',
  24. gather_method: 'POST',
  25. gather_fallback_url: 'https://new.com',
  26. gather_fallback_method: 'GET',
  27. username: 'new_username',
  28. password: 'new_password',
  29. fallback_username: 'new_fallback_username',
  30. fallback_password: 'new_fallback_password',
  31. tag: 'new_tag',
  32. terminating_digits: '10',
  33. max_digits: 10,
  34. inter_digit_timeout: 10,
  35. first_digit_timeout: 10,
  36. repeat_count: 10
  37. }
  38. }
  39. 4 let (:play_audio) { Bandwidth::Bxml::PlayAudio.new('https://audio.url/audio1.wav') }
  40. 2 let (:speak_sentence) { Bandwidth::Bxml::SpeakSentence.new('<lang xml:lang="es-MX">Hola</lang>ruby speak sentence <emphasis>SSML test</emphasis>') }
  41. 4 let(:instance) { Bandwidth::Bxml::Gather.new([], initial_attributes) }
  42. 4 let(:instance_nested) { Bandwidth::Bxml::Gather.new(play_audio, initial_attributes) }
  43. 1 describe 'test an instance of Gather' do
  44. 1 it 'validates instance of Gather' do
  45. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::Gather)
  46. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  47. end
  48. 1 it 'tests the to_bxml method of the Gather instance' do
  49. 1 expected = "\n<Gather gatherUrl=\"https://initial.com\" gatherMethod=\"POST\" gatherFallbackUrl=\"https://initial.com\" gatherFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" terminatingDigits=\"5\" maxDigits=\"5\" interDigitTimeout=\"5\" firstDigitTimeout=\"5\" repeatCount=\"5\"/>\n"
  50. 1 expect(instance.to_bxml).to eq(expected)
  51. end
  52. 1 it 'tests the set_attributes method of the Gather instance' do
  53. 1 instance.set_attributes(new_attributes)
  54. 1 expected = "\n<Gather gatherUrl=\"https://new.com\" gatherMethod=\"POST\" gatherFallbackUrl=\"https://new.com\" gatherFallbackMethod=\"GET\" username=\"new_username\" password=\"new_password\" fallbackUsername=\"new_fallback_username\" fallbackPassword=\"new_fallback_password\" tag=\"new_tag\" terminatingDigits=\"10\" maxDigits=\"10\" interDigitTimeout=\"10\" firstDigitTimeout=\"10\" repeatCount=\"10\"/>\n"
  55. 1 expect(instance.to_bxml).to eq(expected)
  56. end
  57. end
  58. 1 describe 'test an instance of Gather with nested verbs' do
  59. 1 it 'validates instance of Gather' do
  60. 1 expect(instance_nested).to be_instance_of(Bandwidth::Bxml::Gather)
  61. 1 expect(instance_nested).to be_a(Bandwidth::Bxml::Verb)
  62. end
  63. 1 it 'tests the to_bxml method of the nested Gather instance' do
  64. 1 expected = "\n<Gather gatherUrl=\"https://initial.com\" gatherMethod=\"POST\" gatherFallbackUrl=\"https://initial.com\" gatherFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" terminatingDigits=\"5\" maxDigits=\"5\" interDigitTimeout=\"5\" firstDigitTimeout=\"5\" repeatCount=\"5\">\n <PlayAudio>https://audio.url/audio1.wav</PlayAudio>\n</Gather>\n"
  65. 1 expect(instance_nested.to_bxml).to eq(expected)
  66. end
  67. 1 it 'tests the add_verb method of the nested Gather instance' do
  68. 1 expected_single = "\n<Gather gatherUrl=\"https://initial.com\" gatherMethod=\"POST\" gatherFallbackUrl=\"https://initial.com\" gatherFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" terminatingDigits=\"5\" maxDigits=\"5\" interDigitTimeout=\"5\" firstDigitTimeout=\"5\" repeatCount=\"5\">\n <PlayAudio>https://audio.url/audio1.wav</PlayAudio>\n <SpeakSentence><lang xml:lang=\"es-MX\">Hola</lang>ruby speak sentence <emphasis>SSML test</emphasis></SpeakSentence>\n</Gather>\n"
  69. 1 instance_nested.add_audio_verbs(speak_sentence)
  70. 1 expect(instance_nested.to_bxml).to eq(expected_single)
  71. 1 expected_multiple = "\n<Gather gatherUrl=\"https://initial.com\" gatherMethod=\"POST\" gatherFallbackUrl=\"https://initial.com\" gatherFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" terminatingDigits=\"5\" maxDigits=\"5\" interDigitTimeout=\"5\" firstDigitTimeout=\"5\" repeatCount=\"5\">\n <PlayAudio>https://audio.url/audio1.wav</PlayAudio>\n <SpeakSentence><lang xml:lang=\"es-MX\">Hola</lang>ruby speak sentence <emphasis>SSML test</emphasis></SpeakSentence>\n <SpeakSentence><lang xml:lang=\"es-MX\">Hola</lang>ruby speak sentence <emphasis>SSML test</emphasis></SpeakSentence>\n <PlayAudio>https://audio.url/audio1.wav</PlayAudio>\n</Gather>\n"
  72. 1 instance_nested.add_audio_verbs([speak_sentence, play_audio])
  73. 1 expect(instance_nested.to_bxml).to eq(expected_multiple)
  74. end
  75. end
  76. end

spec/unit/models/bxml/verbs/hangup_spec.rb

100.0% lines covered

9 relevant lines. 9 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::Hangup
  2. 1 describe 'Bandwidth::Bxml::Hangup' do
  3. 3 let(:instance) { Bandwidth::Bxml::Hangup.new }
  4. 1 describe 'test an instance of Hangup' do
  5. 1 it 'validates instance of Hangup' do
  6. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::Hangup)
  7. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  8. end
  9. 1 it 'tests the to_bxml method of the Hangup instance' do
  10. 1 expected = "\n<Hangup/>\n"
  11. 1 expect(instance.to_bxml).to eq(expected)
  12. end
  13. end
  14. end

spec/unit/models/bxml/verbs/pause_recording_spec.rb

100.0% lines covered

9 relevant lines. 9 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::PauseRecording
  2. 1 describe 'Bandwidth::Bxml::PauseRecording' do
  3. 3 let(:instance) { Bandwidth::Bxml::PauseRecording.new }
  4. 1 describe 'test an instance of PauseRecording' do
  5. 1 it 'validates instance of PauseRecording' do
  6. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::PauseRecording)
  7. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  8. end
  9. 1 it 'tests the to_bxml method of the PauseRecording instance' do
  10. 1 expected = "\n<PauseRecording/>\n"
  11. 1 expect(instance.to_bxml).to eq(expected)
  12. end
  13. end
  14. end

spec/unit/models/bxml/verbs/pause_spec.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::Pause
  2. 1 describe 'Bandwidth::Bxml::Pause' do
  3. 1 let(:initial_attributes) {
  4. 3 {
  5. duration: 5
  6. }
  7. }
  8. 1 let(:new_attributes) {
  9. 1 {
  10. duration: 10
  11. }
  12. }
  13. 4 let(:instance) { Bandwidth::Bxml::Pause.new(initial_attributes) }
  14. 1 describe 'test an instance of Pause' do
  15. 1 it 'validates instance of Pause' do
  16. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::Pause)
  17. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  18. end
  19. 1 it 'tests the to_bxml method of the Pause instance' do
  20. 1 expected = "\n<Pause duration=\"5\"/>\n"
  21. 1 expect(instance.to_bxml).to eq(expected)
  22. end
  23. 1 it 'tests the set_attributes method of the Pause instance' do
  24. 1 instance.set_attributes(new_attributes)
  25. 1 expected = "\n<Pause duration=\"10\"/>\n"
  26. 1 expect(instance.to_bxml).to eq(expected)
  27. end
  28. end
  29. end

spec/unit/models/bxml/verbs/phone_number_spec.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::PhoneNumber
  2. 1 describe 'Bandwidth::Bxml::PhoneNumber' do
  3. 1 let(:initial_attributes) {
  4. {
  5. 3 transfer_answer_url: 'https://initial.com',
  6. transfer_answer_method: 'POST',
  7. transfer_answer_fallback_url: 'https://initial.com',
  8. transfer_answer_fallback_method: 'POST',
  9. transfer_disconnect_url: 'https://initial.com',
  10. transfer_disconnect_method: 'POST',
  11. username: 'initial_username',
  12. password: 'initial_password',
  13. fallback_username: 'initial_fallback_username',
  14. fallback_password: 'initial_fallback_password',
  15. tag: 'initial_tag',
  16. uui: 'initial_uui'
  17. }
  18. }
  19. 1 let(:new_attributes) {
  20. {
  21. 1 transfer_answer_url: 'https://new.com',
  22. transfer_answer_method: 'GET',
  23. transfer_answer_fallback_url: 'https://new.com',
  24. transfer_answer_fallback_method: 'GET',
  25. transfer_disconnect_url: 'https://new.com',
  26. transfer_disconnect_method: 'GET',
  27. username: 'new_username',
  28. password: 'new_password',
  29. fallback_username: 'new_fallback_username',
  30. fallback_password: 'new_fallback_password',
  31. tag: 'new_tag',
  32. uui: 'new_uui'
  33. }
  34. }
  35. 4 let(:instance) { Bandwidth::Bxml::PhoneNumber.new('+19195551234', initial_attributes) }
  36. 1 describe 'test an instance of PhoneNumber' do
  37. 1 it 'validates instance of PhoneNumber' do
  38. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::PhoneNumber)
  39. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  40. end
  41. 1 it 'tests the to_bxml method of the PhoneNumber instance' do
  42. 1 expected = "\n<PhoneNumber transferAnswerUrl=\"https://initial.com\" transferAnswerMethod=\"POST\" transferAnswerFallbackUrl=\"https://initial.com\" transferAnswerFallbackMethod=\"POST\" transferDisconnectUrl=\"https://initial.com\" transferDisconnectMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" uui=\"initial_uui\">+19195551234</PhoneNumber>\n"
  43. 1 expect(instance.to_bxml).to eq(expected)
  44. end
  45. 1 it 'tests the set_attributes method of the PhoneNumber instance' do
  46. 1 instance.set_attributes(new_attributes)
  47. 1 expected = "\n<PhoneNumber transferAnswerUrl=\"https://new.com\" transferAnswerMethod=\"GET\" transferAnswerFallbackUrl=\"https://new.com\" transferAnswerFallbackMethod=\"GET\" transferDisconnectUrl=\"https://new.com\" transferDisconnectMethod=\"GET\" username=\"new_username\" password=\"new_password\" fallbackUsername=\"new_fallback_username\" fallbackPassword=\"new_fallback_password\" tag=\"new_tag\" uui=\"new_uui\">+19195551234</PhoneNumber>\n"
  48. 1 expect(instance.to_bxml).to eq(expected)
  49. end
  50. end
  51. end

spec/unit/models/bxml/verbs/play_audio_spec.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::PlayAudio
  2. 1 describe 'Bandwidth::Bxml::PlayAudio' do
  3. 1 let(:initial_attributes) {
  4. {
  5. 3 username: 'initial_username',
  6. password: 'initial_password'
  7. }
  8. }
  9. 1 let(:new_attributes) {
  10. {
  11. 1 username: 'new_username',
  12. password: 'new_password'
  13. }
  14. }
  15. 4 let(:instance) { Bandwidth::Bxml::PlayAudio.new('https://audio.url/audio1.wav', initial_attributes) }
  16. 1 describe 'test an instance of PlayAudio' do
  17. 1 it 'validates instance of PlayAudio' do
  18. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::PlayAudio)
  19. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  20. end
  21. 1 it 'tests the to_bxml method of the PlayAudio instance' do
  22. 1 expected = "\n<PlayAudio username=\"initial_username\" password=\"initial_password\">https://audio.url/audio1.wav</PlayAudio>\n"
  23. 1 expect(instance.to_bxml).to eq(expected)
  24. end
  25. 1 it 'tests the set_attributes method of the PlayAudio instance' do
  26. 1 instance.set_attributes(new_attributes)
  27. 1 expected = "\n<PlayAudio username=\"new_username\" password=\"new_password\">https://audio.url/audio1.wav</PlayAudio>\n"
  28. 1 expect(instance.to_bxml).to eq(expected)
  29. end
  30. end
  31. end

spec/unit/models/bxml/verbs/record_spec.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::Record
  2. 1 describe 'Bandwidth::Bxml::Record' do
  3. 1 let(:initial_attributes) {
  4. {
  5. 3 record_complete_url: 'https://initial.com',
  6. record_complete_method: 'POST',
  7. record_complete_fallback_url: 'https://initial.com',
  8. record_complete_fallback_method: 'POST',
  9. recording_available_url: 'https://initial.com',
  10. recording_available_method: 'POST',
  11. transcribe: true,
  12. transcription_available_url: 'https://initial.com',
  13. transcription_available_method: 'POST',
  14. username: 'initial_username',
  15. password: 'initial_password',
  16. fallback_username: 'initial_fallback_username',
  17. fallback_password: 'initial_fallback_password',
  18. tag: 'initial_tag',
  19. terminating_digits: '5',
  20. max_duration: 5,
  21. silence_timeout: 5,
  22. file_format: 'wav'
  23. }
  24. }
  25. 1 let(:new_attributes) {
  26. {
  27. 1 record_complete_url: 'https://new.com',
  28. record_complete_method: 'GET',
  29. record_complete_fallback_url: 'https://new.com',
  30. record_complete_fallback_method: 'GET',
  31. recording_available_url: 'https://new.com',
  32. recording_available_method: 'GET',
  33. transcribe: true,
  34. transcription_available_url: 'https://new.com',
  35. transcription_available_method: 'GET',
  36. username: 'new_username',
  37. password: 'new_password',
  38. fallback_username: 'new_fallback_username',
  39. fallback_password: 'new_fallback_password',
  40. tag: 'new_tag',
  41. terminating_digits: '0',
  42. max_duration: 10,
  43. silence_timeout: 10,
  44. file_format: 'mp3'
  45. }
  46. }
  47. 4 let(:instance) { Bandwidth::Bxml::Record.new(initial_attributes) }
  48. 1 describe 'test an instance of Record' do
  49. 1 it 'validates instance of Record' do
  50. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::Record)
  51. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  52. end
  53. 1 it 'tests the to_bxml method of the Record instance' do
  54. 1 expected = "\n<Record recordCompleteUrl=\"https://initial.com\" recordCompleteMethod=\"POST\" recordCompleteFallbackUrl=\"https://initial.com\" recordCompleteFallbackMethod=\"POST\" recordingAvailableUrl=\"https://initial.com\" recordingAvailableMethod=\"POST\" transcribe=\"true\" transcriptionAvailableUrl=\"https://initial.com\" transcriptionAvailableMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" terminatingDigits=\"5\" maxDuration=\"5\" silenceTimeout=\"5\" fileFormat=\"wav\"/>\n"
  55. 1 expect(instance.to_bxml).to eq(expected)
  56. end
  57. 1 it 'tests the set_attributes method of the Record instance' do
  58. 1 instance.set_attributes(new_attributes)
  59. 1 expected = "\n<Record recordCompleteUrl=\"https://new.com\" recordCompleteMethod=\"GET\" recordCompleteFallbackUrl=\"https://new.com\" recordCompleteFallbackMethod=\"GET\" recordingAvailableUrl=\"https://new.com\" recordingAvailableMethod=\"GET\" transcribe=\"true\" transcriptionAvailableUrl=\"https://new.com\" transcriptionAvailableMethod=\"GET\" username=\"new_username\" password=\"new_password\" fallbackUsername=\"new_fallback_username\" fallbackPassword=\"new_fallback_password\" tag=\"new_tag\" terminatingDigits=\"0\" maxDuration=\"10\" silenceTimeout=\"10\" fileFormat=\"mp3\"/>\n"
  60. 1 expect(instance.to_bxml).to eq(expected)
  61. end
  62. end
  63. end

spec/unit/models/bxml/verbs/redirect_spec.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::Redirect
  2. 1 describe 'Bandwidth::Bxml::Redirect' do
  3. 1 let(:initial_attributes) {
  4. {
  5. 3 redirect_url: 'https://initial.com',
  6. redirect_method: 'POST',
  7. redirect_fallback_url: 'https://initial.com',
  8. redirect_fallback_method: 'POST',
  9. username: 'initial_username',
  10. password: 'initial_password',
  11. fallback_username: 'initial_fallback_username',
  12. fallback_password: 'initial_fallback_password',
  13. tag: 'initial_tag'
  14. }
  15. }
  16. 1 let(:new_attributes) {
  17. {
  18. 1 redirect_url: 'https://new.com',
  19. redirect_method: 'GET',
  20. redirect_fallback_url: 'https://new.com',
  21. redirect_fallback_method: 'GET',
  22. username: 'new_username',
  23. password: 'new_password',
  24. fallback_username: 'new_fallback_username',
  25. fallback_password: 'new_fallback_password',
  26. tag: 'new_tag'
  27. }
  28. }
  29. 4 let(:instance) { Bandwidth::Bxml::Redirect.new(initial_attributes) }
  30. 1 describe 'test an instance of Redirect' do
  31. 1 it 'validates instance of Redirect' do
  32. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::Redirect)
  33. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  34. end
  35. 1 it 'tests the to_bxml method of the Redirect instance' do
  36. 1 expected = "\n<Redirect redirectUrl=\"https://initial.com\" redirectMethod=\"POST\" redirectFallbackUrl=\"https://initial.com\" redirectFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\"/>\n"
  37. 1 expect(instance.to_bxml).to eq(expected)
  38. end
  39. 1 it 'tests the set_attributes method of the Redirect instance' do
  40. 1 instance.set_attributes(new_attributes)
  41. 1 expected = "\n<Redirect redirectUrl=\"https://new.com\" redirectMethod=\"GET\" redirectFallbackUrl=\"https://new.com\" redirectFallbackMethod=\"GET\" username=\"new_username\" password=\"new_password\" fallbackUsername=\"new_fallback_username\" fallbackPassword=\"new_fallback_password\" tag=\"new_tag\"/>\n"
  42. 1 expect(instance.to_bxml).to eq(expected)
  43. end
  44. end
  45. end

spec/unit/models/bxml/verbs/resume_recording_spec.rb

100.0% lines covered

9 relevant lines. 9 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::ResumeRecording
  2. 1 describe 'Bandwidth::Bxml::ResumeRecording' do
  3. 3 let(:instance) { Bandwidth::Bxml::ResumeRecording.new }
  4. 1 describe 'test an instance of ResumeRecording' do
  5. 1 it 'validates instance of ResumeRecording' do
  6. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::ResumeRecording)
  7. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  8. end
  9. 1 it 'tests the to_bxml method of the ResumeRecording instance' do
  10. 1 expected = "\n<ResumeRecording/>\n"
  11. 1 expect(instance.to_bxml).to eq(expected)
  12. end
  13. end
  14. end

spec/unit/models/bxml/verbs/ring_spec.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::Ring
  2. 1 describe 'Bandwidth::Bxml::Ring' do
  3. 1 let(:initial_attributes) {
  4. 3 {
  5. duration: 5.0,
  6. answer_call: true
  7. }
  8. }
  9. 1 let(:new_attributes) {
  10. 1 {
  11. duration: 10.0,
  12. answer_call: false
  13. }
  14. }
  15. 4 let(:instance) { Bandwidth::Bxml::Ring.new(initial_attributes) }
  16. 1 describe 'test an instance of Ring' do
  17. 1 it 'validates instance of Ring' do
  18. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::Ring)
  19. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  20. end
  21. 1 it 'tests the to_bxml method of the Ring instance' do
  22. 1 expected = "\n<Ring duration=\"5.0\" answerCall=\"true\"/>\n"
  23. 1 expect(instance.to_bxml).to eq(expected)
  24. end
  25. 1 it 'tests the set_attributes method of the Ring instance' do
  26. 1 instance.set_attributes(new_attributes)
  27. 1 expected = "\n<Ring duration=\"10.0\" answerCall=\"false\"/>\n"
  28. 1 expect(instance.to_bxml).to eq(expected)
  29. end
  30. end
  31. end

spec/unit/models/bxml/verbs/send_dtmf_spec.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::SendDtmf
  2. 1 describe 'Bandwidth::Bxml::SendDtmf' do
  3. 1 let(:initial_attributes) {
  4. 3 {
  5. tone_duration: 5,
  6. tone_interval: 5
  7. }
  8. }
  9. 1 let(:new_attributes) {
  10. 1 {
  11. tone_duration: 10,
  12. tone_interval: 10
  13. }
  14. }
  15. 4 let(:instance) { Bandwidth::Bxml::SendDtmf.new('1234', initial_attributes) }
  16. 1 describe 'test an instance of SendDtmf' do
  17. 1 it 'validates instance of SendDtmf' do
  18. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::SendDtmf)
  19. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  20. end
  21. 1 it 'tests the to_bxml method of the SendDtmf instance' do
  22. 1 expected = "\n<SendDtmf toneDuration=\"5\" toneInterval=\"5\">1234</SendDtmf>\n"
  23. 1 expect(instance.to_bxml).to eq(expected)
  24. end
  25. 1 it 'tests the set_attributes method of the SendDtmf instance' do
  26. 1 instance.set_attributes(new_attributes)
  27. 1 expected = "\n<SendDtmf toneDuration=\"10\" toneInterval=\"10\">1234</SendDtmf>\n"
  28. 1 expect(instance.to_bxml).to eq(expected)
  29. end
  30. end
  31. end

spec/unit/models/bxml/verbs/sip_uri_spec.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::SipUri
  2. 1 describe 'Bandwidth::Bxml::SipUri' do
  3. 1 let(:initial_attributes) {
  4. {
  5. 3 uui: 'abc123',
  6. transfer_answer_url: 'https://initial.com',
  7. transfer_answer_method: 'POST',
  8. transfer_answer_fallback_url: 'https://initial.com',
  9. transfer_answer_fallback_method: 'POST',
  10. transfer_disconnect_url: 'https://initial.com',
  11. transfer_disconnect_method: 'POST',
  12. username: 'initial_username',
  13. password: 'initial_password',
  14. fallback_username: 'initial_fallback_username',
  15. fallback_password: 'initial_fallback_password',
  16. tag: 'initial_tag'
  17. }
  18. }
  19. 1 let(:new_attributes) {
  20. {
  21. 1 uui: '123abc',
  22. transfer_answer_url: 'https://new.com',
  23. transfer_answer_method: 'GET',
  24. transfer_answer_fallback_url: 'https://new.com',
  25. transfer_answer_fallback_method: 'GET',
  26. transfer_disconnect_url: 'https://new.com',
  27. transfer_disconnect_method: 'GET',
  28. username: 'new_username',
  29. password: 'new_password',
  30. fallback_username: 'new_fallback_username',
  31. fallback_password: 'new_fallback_password',
  32. tag: 'new_tag'
  33. }
  34. }
  35. 4 let(:instance) { Bandwidth::Bxml::SipUri.new('sip:1-999-123-4567@voip-provider.example.net', initial_attributes) }
  36. 1 describe 'test an instance of SipUri' do
  37. 1 it 'validates instance of SipUri' do
  38. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::SipUri)
  39. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  40. end
  41. 1 it 'tests the to_bxml method of the SipUri instance' do
  42. 1 expected = "\n<SipUri uui=\"abc123\" transferAnswerUrl=\"https://initial.com\" transferAnswerMethod=\"POST\" transferAnswerFallbackUrl=\"https://initial.com\" transferAnswerFallbackMethod=\"POST\" transferDisconnectUrl=\"https://initial.com\" transferDisconnectMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\">sip:1-999-123-4567@voip-provider.example.net</SipUri>\n"
  43. 1 expect(instance.to_bxml).to eq(expected)
  44. end
  45. 1 it 'tests the set_attributes method of the SipUri instance' do
  46. 1 instance.set_attributes(new_attributes)
  47. 1 expected = "\n<SipUri uui=\"123abc\" transferAnswerUrl=\"https://new.com\" transferAnswerMethod=\"GET\" transferAnswerFallbackUrl=\"https://new.com\" transferAnswerFallbackMethod=\"GET\" transferDisconnectUrl=\"https://new.com\" transferDisconnectMethod=\"GET\" username=\"new_username\" password=\"new_password\" fallbackUsername=\"new_fallback_username\" fallbackPassword=\"new_fallback_password\" tag=\"new_tag\">sip:1-999-123-4567@voip-provider.example.net</SipUri>\n"
  48. 1 expect(instance.to_bxml).to eq(expected)
  49. end
  50. end
  51. end

spec/unit/models/bxml/verbs/speak_sentence_spec.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::SpeakSentence
  2. 1 describe 'Bandwidth::Bxml::SpeakSentence' do
  3. 1 let(:initial_attributes) {
  4. {
  5. 3 voice: 'julie',
  6. gender: 'female',
  7. locale: 'en_US'
  8. }
  9. }
  10. 1 let(:new_attributes) {
  11. {
  12. 1 voice: 'simon',
  13. gender: 'male',
  14. locale: 'en_UK'
  15. }
  16. }
  17. 4 let(:instance) { Bandwidth::Bxml::SpeakSentence.new('<lang xml:lang="es-MX">Hola</lang>ruby speak sentence <emphasis>SSML test</emphasis>', initial_attributes) }
  18. 1 describe 'test an instance of SpeakSentence' do
  19. 1 it 'validates instance of SpeakSentence' do
  20. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::SpeakSentence)
  21. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  22. end
  23. 1 it 'tests the to_bxml method of the SpeakSentence instance' do
  24. 1 expected = "\n<SpeakSentence voice=\"julie\" gender=\"female\" locale=\"en_US\"><lang xml:lang=\"es-MX\">Hola</lang>ruby speak sentence <emphasis>SSML test</emphasis></SpeakSentence>\n"
  25. 1 expect(instance.to_bxml).to eq(expected)
  26. end
  27. 1 it 'tests the set_attributes method of the SpeakSentence instance' do
  28. 1 instance.set_attributes(new_attributes)
  29. 1 expected = "\n<SpeakSentence voice=\"simon\" gender=\"male\" locale=\"en_UK\"><lang xml:lang=\"es-MX\">Hola</lang>ruby speak sentence <emphasis>SSML test</emphasis></SpeakSentence>\n"
  30. 1 expect(instance.to_bxml).to eq(expected)
  31. end
  32. end
  33. end

spec/unit/models/bxml/verbs/start_gather_spec.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::StartGather
  2. 1 describe 'Bandwidth::Bxml::StartGather' do
  3. 1 let(:initial_attributes) {
  4. {
  5. 3 dtmf_url: 'https://initial.com',
  6. dtmf_method: 'POST',
  7. username: 'initial_username',
  8. password: 'initial_password',
  9. tag: 'initial_tag'
  10. }
  11. }
  12. 1 let(:new_attributes) {
  13. {
  14. 1 dtmf_url: 'https://new.com',
  15. dtmf_method: 'GET',
  16. username: 'new_username',
  17. password: 'new_password',
  18. tag: 'new_tag'
  19. }
  20. }
  21. 4 let(:instance) { Bandwidth::Bxml::StartGather.new(initial_attributes) }
  22. 1 describe 'test an instance of StartGather' do
  23. 1 it 'validates instance of StartGather' do
  24. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::StartGather)
  25. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  26. end
  27. 1 it 'tests the to_bxml method of the StartGather instance' do
  28. 1 expected = "\n<StartGather dtmfUrl=\"https://initial.com\" dtmfMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" tag=\"initial_tag\"/>\n"
  29. 1 expect(instance.to_bxml).to eq(expected)
  30. end
  31. 1 it 'tests the set_attributes method of the StartGather instance' do
  32. 1 instance.set_attributes(new_attributes)
  33. 1 expected = "\n<StartGather dtmfUrl=\"https://new.com\" dtmfMethod=\"GET\" username=\"new_username\" password=\"new_password\" tag=\"new_tag\"/>\n"
  34. 1 expect(instance.to_bxml).to eq(expected)
  35. end
  36. end
  37. end

spec/unit/models/bxml/verbs/start_recording_spec.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::StartRecording
  2. 1 describe 'Bandwidth::Bxml::StartRecording' do
  3. 1 let(:initial_attributes) {
  4. {
  5. 3 recording_available_url: 'https://initial.com',
  6. recording_available_method: 'POST',
  7. transcribe: true,
  8. transcription_available_url: 'https://initial.com',
  9. transcription_available_method: 'POST',
  10. username: 'initial_username',
  11. password: 'initial_password',
  12. tag: 'initial_tag',
  13. file_format: 'wav',
  14. multi_channel: true
  15. }
  16. }
  17. 1 let(:new_attributes) {
  18. {
  19. 1 recording_available_url: 'https://new.com',
  20. recording_available_method: 'GET',
  21. transcribe: false,
  22. transcription_available_url: 'https://new.com',
  23. transcription_available_method: 'GET',
  24. username: 'new_username',
  25. password: 'new_password',
  26. tag: 'new_tag',
  27. file_format: 'mp3',
  28. multi_channel: false
  29. }
  30. }
  31. 4 let(:instance) { Bandwidth::Bxml::StartRecording.new(initial_attributes) }
  32. 1 describe 'test an instance of StartRecording' do
  33. 1 it 'validates instance of StartRecording' do
  34. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::StartRecording)
  35. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  36. end
  37. 1 it 'tests the to_bxml method of the StartRecording instance' do
  38. 1 expected = "\n<StartRecording recordingAvailableUrl=\"https://initial.com\" recordingAvailableMethod=\"POST\" transcribe=\"true\" transcriptionAvailableUrl=\"https://initial.com\" transcriptionAvailableMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" tag=\"initial_tag\" fileFormat=\"wav\" multiChannel=\"true\"/>\n"
  39. 1 expect(instance.to_bxml).to eq(expected)
  40. end
  41. 1 it 'tests the set_attributes method of the StartRecording instance' do
  42. 1 instance.set_attributes(new_attributes)
  43. 1 expected = "\n<StartRecording recordingAvailableUrl=\"https://new.com\" recordingAvailableMethod=\"GET\" transcribe=\"false\" transcriptionAvailableUrl=\"https://new.com\" transcriptionAvailableMethod=\"GET\" username=\"new_username\" password=\"new_password\" tag=\"new_tag\" fileFormat=\"mp3\" multiChannel=\"false\"/>\n"
  44. 1 expect(instance.to_bxml).to eq(expected)
  45. end
  46. end
  47. end

spec/unit/models/bxml/verbs/start_stream_spec.rb

100.0% lines covered

34 relevant lines. 34 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::StartStream
  2. 1 describe 'Bandwidth::Bxml::StartStream' do
  3. 1 let(:initial_attributes) {
  4. {
  5. 6 name: 'initial_name',
  6. mode: 'unidirectional',
  7. tracks: 'inbound',
  8. destination: 'https://initial.com',
  9. destination_username: 'initial_destination_username',
  10. destination_password: 'initial_destination_password',
  11. stream_event_url: 'https://initial.com',
  12. stream_event_method: 'POST',
  13. username: 'initial_username',
  14. password: 'initial_password'
  15. }
  16. }
  17. 1 let(:new_attributes) {
  18. {
  19. 1 name: 'new_name',
  20. mode: 'bidirectional',
  21. tracks: 'outbound',
  22. destination: 'https://new.com',
  23. destination_username: 'new_destination_username',
  24. destination_password: 'new_destination_password',
  25. stream_event_url: 'https://new.com',
  26. stream_event_method: 'GET',
  27. username: 'new_username',
  28. password: 'new_password'
  29. }
  30. }
  31. 4 let (:stream_param_1) { Bandwidth::Bxml::StreamParam.new({ name: 'stream_param_name_1', value: 'stream_param_value_1' }) }
  32. 2 let (:stream_param_2) { Bandwidth::Bxml::StreamParam.new({ name: 'stream_param_name_2', value: 'stream_param_value_2' }) }
  33. 4 let(:instance) { Bandwidth::Bxml::StartStream.new([], initial_attributes) }
  34. 4 let(:instance_nested) { Bandwidth::Bxml::StartStream.new(stream_param_1, initial_attributes) }
  35. 1 describe 'test an instance of StartStream' do
  36. 1 it 'validates instance of StartStream' do
  37. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::StartStream)
  38. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  39. end
  40. 1 it 'tests the to_bxml method of the StartStream instance' do
  41. 1 expected = "\n<StartStream name=\"initial_name\" mode=\"unidirectional\" tracks=\"inbound\" destination=\"https://initial.com\" destination_username=\"initial_destination_username\" destination_password=\"initial_destination_password\" streamEventUrl=\"https://initial.com\" streamEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\"/>\n"
  42. 1 expect(instance.to_bxml).to eq(expected)
  43. end
  44. 1 it 'tests the set_attributes method of the StartStream instance' do
  45. 1 instance.set_attributes(new_attributes)
  46. 1 expected = "\n<StartStream name=\"new_name\" mode=\"bidirectional\" tracks=\"outbound\" destination=\"https://new.com\" destination_username=\"new_destination_username\" destination_password=\"new_destination_password\" streamEventUrl=\"https://new.com\" streamEventMethod=\"GET\" username=\"new_username\" password=\"new_password\"/>\n"
  47. 1 expect(instance.to_bxml).to eq(expected)
  48. end
  49. end
  50. 1 describe 'test an instance of StartStream with nested verbs' do
  51. 1 it 'validates instance of StartStream' do
  52. 1 expect(instance_nested).to be_instance_of(Bandwidth::Bxml::StartStream)
  53. 1 expect(instance_nested).to be_a(Bandwidth::Bxml::Verb)
  54. end
  55. 1 it 'tests the to_bxml method of the nested StartStream instance' do
  56. 1 expected = "\n<StartStream name=\"initial_name\" mode=\"unidirectional\" tracks=\"inbound\" destination=\"https://initial.com\" destination_username=\"initial_destination_username\" destination_password=\"initial_destination_password\" streamEventUrl=\"https://initial.com\" streamEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\">\n <StreamParam name=\"stream_param_name_1\" value=\"stream_param_value_1\"/>\n</StartStream>\n"
  57. 1 expect(instance_nested.to_bxml).to eq(expected)
  58. end
  59. 1 it 'tests the add_stream_param method of the nested StartStream instance' do
  60. 1 expected_single = "\n<StartStream name=\"initial_name\" mode=\"unidirectional\" tracks=\"inbound\" destination=\"https://initial.com\" destination_username=\"initial_destination_username\" destination_password=\"initial_destination_password\" streamEventUrl=\"https://initial.com\" streamEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\">\n <StreamParam name=\"stream_param_name_1\" value=\"stream_param_value_1\"/>\n <StreamParam name=\"stream_param_name_2\" value=\"stream_param_value_2\"/>\n</StartStream>\n"
  61. 1 instance_nested.add_stream_params(stream_param_2)
  62. 1 expect(instance_nested.to_bxml).to eq(expected_single)
  63. 1 expected_multiple = "\n<StartStream name=\"initial_name\" mode=\"unidirectional\" tracks=\"inbound\" destination=\"https://initial.com\" destination_username=\"initial_destination_username\" destination_password=\"initial_destination_password\" streamEventUrl=\"https://initial.com\" streamEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\">\n <StreamParam name=\"stream_param_name_1\" value=\"stream_param_value_1\"/>\n <StreamParam name=\"stream_param_name_2\" value=\"stream_param_value_2\"/>\n <StreamParam name=\"stream_param_name_2\" value=\"stream_param_value_2\"/>\n <StreamParam name=\"stream_param_name_2\" value=\"stream_param_value_2\"/>\n</StartStream>\n"
  64. 1 instance_nested.add_stream_params([stream_param_2, stream_param_2])
  65. 1 expect(instance_nested.to_bxml).to eq(expected_multiple)
  66. end
  67. end
  68. end

spec/unit/models/bxml/verbs/start_transcription_spec.rb

100.0% lines covered

34 relevant lines. 34 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::StartTranscription
  2. 1 describe 'Bandwidth::Bxml::StartTranscription' do
  3. 1 let(:initial_attributes) {
  4. {
  5. 6 name: 'initial_name',
  6. tracks: 'inbound',
  7. transcription_event_url: 'https://initial.com',
  8. transcription_event_method: 'POST',
  9. username: 'initial_username',
  10. password: 'initial_password',
  11. destination: 'https://initial.com',
  12. stabilized: true
  13. }
  14. }
  15. 1 let(:new_attributes) {
  16. {
  17. 1 name: 'new_name',
  18. tracks: 'outbound',
  19. transcription_event_url: 'https://new.com',
  20. transcription_event_method: 'GET',
  21. username: 'new_username',
  22. password: 'new_password',
  23. destination: 'https://new.com',
  24. stabilized: false
  25. }
  26. }
  27. 4 let (:custom_param_1) { Bandwidth::Bxml::CustomParam.new({ name: 'custom_param_name_1', value: 'custom_param_value_1' }) }
  28. 2 let (:custom_param_2) { Bandwidth::Bxml::CustomParam.new({ name: 'custom_param_name_2', value: 'custom_param_value_2' }) }
  29. 4 let(:instance) { Bandwidth::Bxml::StartTranscription.new([], initial_attributes) }
  30. 4 let(:instance_nested) { Bandwidth::Bxml::StartTranscription.new(custom_param_1, initial_attributes) }
  31. 1 describe 'test an instance of StartTranscription' do
  32. 1 it 'validates instance of StartTranscription' do
  33. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::StartTranscription)
  34. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  35. end
  36. 1 it 'tests the to_bxml method of the StartTranscription instance' do
  37. 1 expected = "\n<StartTranscription name=\"initial_name\" tracks=\"inbound\" transcriptionEventUrl=\"https://initial.com\" transcriptionEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" destination=\"https://initial.com\" stabilized=\"true\"/>\n"
  38. 1 expect(instance.to_bxml).to eq(expected)
  39. end
  40. 1 it 'tests the set_attributes method of the StartTranscription instance' do
  41. 1 instance.set_attributes(new_attributes)
  42. 1 expected = "\n<StartTranscription name=\"new_name\" tracks=\"outbound\" transcriptionEventUrl=\"https://new.com\" transcriptionEventMethod=\"GET\" username=\"new_username\" password=\"new_password\" destination=\"https://new.com\" stabilized=\"false\"/>\n"
  43. 1 expect(instance.to_bxml).to eq(expected)
  44. end
  45. end
  46. 1 describe 'test an instance of StartTranscription with nested verbs' do
  47. 1 it 'validates instance of StartTranscription' do
  48. 1 expect(instance_nested).to be_instance_of(Bandwidth::Bxml::StartTranscription)
  49. 1 expect(instance_nested).to be_a(Bandwidth::Bxml::Verb)
  50. end
  51. 1 it 'tests the to_bxml method of the nested StartTranscription instance' do
  52. 1 expected = "\n<StartTranscription name=\"initial_name\" tracks=\"inbound\" transcriptionEventUrl=\"https://initial.com\" transcriptionEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" destination=\"https://initial.com\" stabilized=\"true\">\n <CustomParam name=\"custom_param_name_1\" value=\"custom_param_value_1\"/>\n</StartTranscription>\n"
  53. 1 expect(instance_nested.to_bxml).to eq(expected)
  54. end
  55. 1 it 'tests the add_custom_param method of the nested StartTranscription instance' do
  56. 1 expected_single = "\n<StartTranscription name=\"initial_name\" tracks=\"inbound\" transcriptionEventUrl=\"https://initial.com\" transcriptionEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" destination=\"https://initial.com\" stabilized=\"true\">\n <CustomParam name=\"custom_param_name_1\" value=\"custom_param_value_1\"/>\n <CustomParam name=\"custom_param_name_2\" value=\"custom_param_value_2\"/>\n</StartTranscription>\n"
  57. 1 instance_nested.add_custom_params(custom_param_2)
  58. 1 expect(instance_nested.to_bxml).to eq(expected_single)
  59. 1 expected_multiple = "\n<StartTranscription name=\"initial_name\" tracks=\"inbound\" transcriptionEventUrl=\"https://initial.com\" transcriptionEventMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" destination=\"https://initial.com\" stabilized=\"true\">\n <CustomParam name=\"custom_param_name_1\" value=\"custom_param_value_1\"/>\n <CustomParam name=\"custom_param_name_2\" value=\"custom_param_value_2\"/>\n <CustomParam name=\"custom_param_name_2\" value=\"custom_param_value_2\"/>\n <CustomParam name=\"custom_param_name_2\" value=\"custom_param_value_2\"/>\n</StartTranscription>\n"
  60. 1 instance_nested.add_custom_params([custom_param_2, custom_param_2])
  61. 1 expect(instance_nested.to_bxml).to eq(expected_multiple)
  62. end
  63. end
  64. end

spec/unit/models/bxml/verbs/stop_gather_spec.rb

100.0% lines covered

9 relevant lines. 9 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::StopGather
  2. 1 describe 'Bandwidth::Bxml::StopGather' do
  3. 3 let(:instance) { Bandwidth::Bxml::StopGather.new }
  4. 1 describe 'test an instance of StopGather' do
  5. 1 it 'validates instance of StopGather' do
  6. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::StopGather)
  7. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  8. end
  9. 1 it 'tests the to_bxml method of the StopGather instance' do
  10. 1 expected = "\n<StopGather/>\n"
  11. 1 expect(instance.to_bxml).to eq(expected)
  12. end
  13. end
  14. end

spec/unit/models/bxml/verbs/stop_recording_spec.rb

100.0% lines covered

9 relevant lines. 9 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::StopRecording
  2. 1 describe 'Bandwidth::Bxml::StopRecording' do
  3. 3 let(:instance) { Bandwidth::Bxml::StopRecording.new }
  4. 1 describe 'test an instance of StopRecording' do
  5. 1 it 'validates instance of StopRecording' do
  6. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::StopRecording)
  7. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  8. end
  9. 1 it 'tests the to_bxml method of the StopRecording instance' do
  10. 1 expected = "\n<StopRecording/>\n"
  11. 1 expect(instance.to_bxml).to eq(expected)
  12. end
  13. end
  14. end

spec/unit/models/bxml/verbs/stop_stream_spec.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::StopStream
  2. 1 describe 'Bandwidth::Bxml::StopStream' do
  3. 1 let(:initial_attributes) {
  4. {
  5. 3 name: 'initial_name',
  6. wait: true
  7. }
  8. }
  9. 1 let(:new_attributes) {
  10. {
  11. 1 name: 'new_name',
  12. wait: false
  13. }
  14. }
  15. 4 let(:instance) { Bandwidth::Bxml::StopStream.new(initial_attributes) }
  16. 1 describe 'test an instance of StopStream' do
  17. 1 it 'validates instance of StopStream' do
  18. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::StopStream)
  19. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  20. end
  21. 1 it 'tests the to_bxml method of the StopStream instance' do
  22. 1 expected = "\n<StopStream name=\"initial_name\" wait=\"true\"/>\n"
  23. 1 expect(instance.to_bxml).to eq(expected)
  24. end
  25. 1 it 'tests the set_attributes method of the StopStream instance' do
  26. 1 instance.set_attributes(new_attributes)
  27. 1 expected = "\n<StopStream name=\"new_name\" wait=\"false\"/>\n"
  28. 1 expect(instance.to_bxml).to eq(expected)
  29. end
  30. end
  31. end

spec/unit/models/bxml/verbs/stop_transcription_spec.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::StopTranscription
  2. 1 describe 'Bandwidth::Bxml::StopTranscription' do
  3. 1 let(:initial_attributes) {
  4. {
  5. 3 name: 'initial_name'
  6. }
  7. }
  8. 1 let(:new_attributes) {
  9. {
  10. 1 name: 'new_name'
  11. }
  12. }
  13. 4 let(:instance) { Bandwidth::Bxml::StopTranscription.new(initial_attributes) }
  14. 1 describe 'test an instance of StopTranscription' do
  15. 1 it 'validates instance of StopTranscription' do
  16. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::StopTranscription)
  17. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  18. end
  19. 1 it 'tests the to_bxml method of the StopTranscription instance' do
  20. 1 expected = "\n<StopTranscription name=\"initial_name\"/>\n"
  21. 1 expect(instance.to_bxml).to eq(expected)
  22. end
  23. 1 it 'tests the set_attributes method of the StopTranscription instance' do
  24. 1 instance.set_attributes(new_attributes)
  25. 1 expected = "\n<StopTranscription name=\"new_name\"/>\n"
  26. 1 expect(instance.to_bxml).to eq(expected)
  27. end
  28. end
  29. end

spec/unit/models/bxml/verbs/stream_param_spec.rb

100.0% lines covered

17 relevant lines. 17 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::StreamParam
  2. 1 describe 'Bandwidth::Bxml::StreamParam' do
  3. 1 let(:initial_attributes) {
  4. {
  5. 3 name: 'initial_name',
  6. value: 'initial_value'
  7. }
  8. }
  9. 1 let(:new_attributes) {
  10. {
  11. 1 name: 'new_name',
  12. value: 'new_value'
  13. }
  14. }
  15. 4 let(:instance) { Bandwidth::Bxml::StreamParam.new(initial_attributes) }
  16. 1 describe 'test an instance of StreamParam' do
  17. 1 it 'validates instance of StreamParam' do
  18. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::StreamParam)
  19. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  20. end
  21. 1 it 'tests the to_bxml method of the StreamParam instance' do
  22. 1 expected = "\n<StreamParam name=\"initial_name\" value=\"initial_value\"/>\n"
  23. 1 expect(instance.to_bxml).to eq(expected)
  24. end
  25. 1 it 'tests the set_attributes method of the StreamParam instance' do
  26. 1 instance.set_attributes(new_attributes)
  27. 1 expected = "\n<StreamParam name=\"new_name\" value=\"new_value\"/>\n"
  28. 1 expect(instance.to_bxml).to eq(expected)
  29. end
  30. end
  31. end

spec/unit/models/bxml/verbs/tag_spec.rb

100.0% lines covered

9 relevant lines. 9 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::Tag
  2. 1 describe 'Bandwidth::Bxml::Tag' do
  3. 3 let(:instance) { Bandwidth::Bxml::Tag.new('test_tag') }
  4. 1 describe 'test an instance of Tag' do
  5. 1 it 'validates instance of Tag' do
  6. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::Tag)
  7. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  8. end
  9. 1 it 'tests the to_bxml method of the Tag instance' do
  10. 1 expected = "\n<Tag>test_tag</Tag>\n"
  11. 1 expect(instance.to_bxml).to eq(expected)
  12. end
  13. end
  14. end

spec/unit/models/bxml/verbs/transfer_spec.rb

100.0% lines covered

34 relevant lines. 34 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Bxml::Transfer
  2. 1 describe 'Bandwidth::Bxml::Transfer' do
  3. 1 let(:initial_attributes) {
  4. {
  5. 6 transfer_caller_id: '+19195551234',
  6. transfer_caller_display_name: 'initial_caller',
  7. call_timeout: 5,
  8. transfer_complete_url: 'https://initial.com',
  9. transfer_complete_method: 'POST',
  10. transfer_complete_fallback_url: 'https://initial.com',
  11. transfer_complete_fallback_method: 'POST',
  12. username: 'initial_username',
  13. password: 'initial_password',
  14. fallback_username: 'initial_fallback_username',
  15. fallback_password: 'initial_fallback_password',
  16. tag: 'initial_tag',
  17. diversion_treatment: 'propagate',
  18. diversion_reason: 'user-busy'
  19. }
  20. }
  21. 1 let(:new_attributes) {
  22. {
  23. 1 transfer_caller_id: '+19195554321',
  24. transfer_caller_display_name: 'new_caller',
  25. call_timeout: 10,
  26. transfer_complete_url: 'https://new.com',
  27. transfer_complete_method: 'POST',
  28. transfer_complete_fallback_url: 'https://new.com',
  29. transfer_complete_fallback_method: 'POST',
  30. username: 'new_username',
  31. password: 'new_password',
  32. fallback_username: 'new_fallback_username',
  33. fallback_password: 'new_fallback_password',
  34. tag: 'new_tag',
  35. diversion_treatment: 'stack',
  36. diversion_reason: 'no-answer'
  37. }
  38. }
  39. 4 let(:phone_number) { Bandwidth::Bxml::PhoneNumber.new('+19195551234') }
  40. 2 let(:sip_uri) { Bandwidth::Bxml::SipUri.new('sip:1-999-123-4567@voip-provider.example.net') }
  41. 4 let(:instance) { Bandwidth::Bxml::Transfer.new([], initial_attributes) }
  42. 4 let(:instance_nested) { Bandwidth::Bxml::Transfer.new(phone_number, initial_attributes) }
  43. 1 describe 'test an instance of Transfer' do
  44. 1 it 'validates instance of Transfer' do
  45. 1 expect(instance).to be_instance_of(Bandwidth::Bxml::Transfer)
  46. 1 expect(instance).to be_a(Bandwidth::Bxml::Verb)
  47. end
  48. 1 it 'tests the to_bxml method of the Transfer instance' do
  49. 1 expected = "\n<Transfer transferCallerId=\"+19195551234\" transferCallerDisplayName=\"initial_caller\" callTimeout=\"5\" transferCompleteUrl=\"https://initial.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"https://initial.com\" transferCompleteFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" diversionTreatment=\"propagate\" diversionReason=\"user-busy\"/>\n"
  50. 1 expect(instance.to_bxml).to eq(expected)
  51. end
  52. 1 it 'tests the set_attributes method of the Transfer instance' do
  53. 1 instance.set_attributes(new_attributes)
  54. 1 expected = "\n<Transfer transferCallerId=\"+19195554321\" transferCallerDisplayName=\"new_caller\" callTimeout=\"10\" transferCompleteUrl=\"https://new.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"https://new.com\" transferCompleteFallbackMethod=\"POST\" username=\"new_username\" password=\"new_password\" fallbackUsername=\"new_fallback_username\" fallbackPassword=\"new_fallback_password\" tag=\"new_tag\" diversionTreatment=\"stack\" diversionReason=\"no-answer\"/>\n"
  55. 1 expect(instance.to_bxml).to eq(expected)
  56. end
  57. end
  58. 1 describe 'test an instance of Transfer with nested verbs' do
  59. 1 it 'validates instance of Transfer' do
  60. 1 expect(instance_nested).to be_instance_of(Bandwidth::Bxml::Transfer)
  61. 1 expect(instance_nested).to be_a(Bandwidth::Bxml::Verb)
  62. end
  63. 1 it 'tests the to_bxml method of the nested Transfer instance' do
  64. 1 expected = "\n<Transfer transferCallerId=\"+19195551234\" transferCallerDisplayName=\"initial_caller\" callTimeout=\"5\" transferCompleteUrl=\"https://initial.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"https://initial.com\" transferCompleteFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" diversionTreatment=\"propagate\" diversionReason=\"user-busy\">\n <PhoneNumber>+19195551234</PhoneNumber>\n</Transfer>\n"
  65. 1 expect(instance_nested.to_bxml).to eq(expected)
  66. end
  67. 1 it 'tests the add_verb method of the nested Transfer instance' do
  68. 1 expected_single = "\n<Transfer transferCallerId=\"+19195551234\" transferCallerDisplayName=\"initial_caller\" callTimeout=\"5\" transferCompleteUrl=\"https://initial.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"https://initial.com\" transferCompleteFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" diversionTreatment=\"propagate\" diversionReason=\"user-busy\">\n <PhoneNumber>+19195551234</PhoneNumber>\n <SipUri>sip:1-999-123-4567@voip-provider.example.net</SipUri>\n</Transfer>\n"
  69. 1 instance_nested.add_transfer_recipients(sip_uri)
  70. 1 expect(instance_nested.to_bxml).to eq(expected_single)
  71. 1 expected_multiple = "\n<Transfer transferCallerId=\"+19195551234\" transferCallerDisplayName=\"initial_caller\" callTimeout=\"5\" transferCompleteUrl=\"https://initial.com\" transferCompleteMethod=\"POST\" transferCompleteFallbackUrl=\"https://initial.com\" transferCompleteFallbackMethod=\"POST\" username=\"initial_username\" password=\"initial_password\" fallbackUsername=\"initial_fallback_username\" fallbackPassword=\"initial_fallback_password\" tag=\"initial_tag\" diversionTreatment=\"propagate\" diversionReason=\"user-busy\">\n <PhoneNumber>+19195551234</PhoneNumber>\n <SipUri>sip:1-999-123-4567@voip-provider.example.net</SipUri>\n <SipUri>sip:1-999-123-4567@voip-provider.example.net</SipUri>\n <PhoneNumber>+19195551234</PhoneNumber>\n</Transfer>\n"
  72. 1 instance_nested.add_transfer_recipients([sip_uri, phone_number])
  73. 1 expect(instance_nested.to_bxml).to eq(expected_multiple)
  74. end
  75. end
  76. end

spec/unit/models/call_direction_enum_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CallDirectionEnum
  2. 1 describe Bandwidth::CallDirectionEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines INBOUND' do
  5. 1 expect(Bandwidth::CallDirectionEnum::INBOUND).to eq('inbound')
  6. end
  7. 1 it 'defines OUTBOUND' do
  8. 1 expect(Bandwidth::CallDirectionEnum::OUTBOUND).to eq('outbound')
  9. end
  10. end
  11. 1 describe '.all_vars' do
  12. 1 it 'returns every valid enum value' do
  13. 1 expect(Bandwidth::CallDirectionEnum.all_vars).to eq([
  14. 'inbound',
  15. 'outbound'
  16. ])
  17. end
  18. end
  19. 1 describe '.build_from_hash' do
  20. 1 it 'returns the value when it matches a valid enum value' do
  21. 1 expect(Bandwidth::CallDirectionEnum.build_from_hash('inbound')).to eq('inbound')
  22. 1 expect(Bandwidth::CallDirectionEnum.build_from_hash('outbound')).to eq('outbound')
  23. end
  24. 1 it 'raises an error for an invalid enum value' do
  25. 1 expect {
  26. 1 Bandwidth::CallDirectionEnum.build_from_hash('invalid')
  27. }.to raise_error(RuntimeError)
  28. end
  29. end
  30. end

spec/unit/models/call_recording_metadata_spec.rb

100.0% lines covered

48 relevant lines. 48 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CallRecordingMetadata
  2. 1 describe Bandwidth::CallRecordingMetadata do
  3. 2 let(:call_recording_metadata_default) { Bandwidth::CallRecordingMetadata.new }
  4. 4 let(:call_recording_metadata_values) { Bandwidth::CallRecordingMetadata.new({
  5. application_id: '04e88489-df02-4e34-a0ee-27a91849555f',
  6. account_id: '9900000',
  7. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  8. parent_call_id: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  9. recording_id: 'r-fbe05094-9fd2b71d-a4e6-4f43-8c3e-5b04b1d8a4b4',
  10. to: '+19195551234',
  11. from: '+19195554321',
  12. transfer_caller_id: '+19195555678',
  13. transfer_to: '+19195558765',
  14. duration: 'PT13.67S',
  15. direction: Bandwidth::CallDirectionEnum::INBOUND,
  16. channels: 1,
  17. start_time: '2022-06-16T13:15:07.160Z',
  18. end_time: '2022-06-16T13:15:20.830Z',
  19. file_format: Bandwidth::FileFormatEnum::WAV,
  20. status: 'complete',
  21. media_url: 'https://example.com/recording.wav',
  22. transcription: { id: 't-123', url: 'https://example.com/t-123', status: 'available', completed_time: '2022-06-16T13:15:31.000Z' },
  23. recording_name: 'sample-recording'
  24. }) }
  25. 1 describe '#initialize' do
  26. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  27. 1 expect {
  28. 1 Bandwidth::CallRecordingMetadata.new([])
  29. }.to raise_error(ArgumentError)
  30. end
  31. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  32. 1 expect {
  33. 1 Bandwidth::CallRecordingMetadata.new({ invalid: true })
  34. }.to raise_error(ArgumentError)
  35. end
  36. end
  37. 1 describe '#acceptable_attributes' do
  38. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  39. 1 expect(Bandwidth::CallRecordingMetadata.acceptable_attributes).to eq(Bandwidth::CallRecordingMetadata.attribute_map.values)
  40. end
  41. end
  42. 1 describe '#openapi_nullable' do
  43. 1 it 'expects nullable attributes to be the set of nullable fields' do
  44. 1 expect(Bandwidth::CallRecordingMetadata.openapi_nullable).to eq(Set.new([
  45. :'media_url',
  46. :'transcription'
  47. ]))
  48. end
  49. end
  50. 1 describe '#build_from_hash' do
  51. 1 it 'validates instance of CallRecordingMetadata created by the build_from_hash method' do
  52. 1 call_recording_metadata_from_hash = Bandwidth::CallRecordingMetadata.build_from_hash({
  53. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  54. accountId: '9900000',
  55. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  56. parentCallId: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  57. recordingId: 'r-fbe05094-9fd2b71d-a4e6-4f43-8c3e-5b04b1d8a4b4',
  58. to: '+19195551234',
  59. from: '+19195554321',
  60. transferCallerId: '+19195555678',
  61. transferTo: '+19195558765',
  62. duration: 'PT13.67S',
  63. direction: 'inbound',
  64. channels: 1,
  65. startTime: '2022-06-16T13:15:07.160Z',
  66. endTime: '2022-06-16T13:15:20.830Z',
  67. fileFormat: 'wav',
  68. status: 'complete',
  69. mediaUrl: 'https://example.com/recording.wav',
  70. recordingName: 'sample-recording'
  71. })
  72. 1 expect(call_recording_metadata_from_hash).to be_instance_of(Bandwidth::CallRecordingMetadata)
  73. 1 expect(call_recording_metadata_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f')
  74. 1 expect(call_recording_metadata_from_hash.account_id).to eq('9900000')
  75. 1 expect(call_recording_metadata_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  76. 1 expect(call_recording_metadata_from_hash.parent_call_id).to eq('c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99')
  77. 1 expect(call_recording_metadata_from_hash.recording_id).to eq('r-fbe05094-9fd2b71d-a4e6-4f43-8c3e-5b04b1d8a4b4')
  78. 1 expect(call_recording_metadata_from_hash.to).to eq('+19195551234')
  79. 1 expect(call_recording_metadata_from_hash.from).to eq('+19195554321')
  80. 1 expect(call_recording_metadata_from_hash.transfer_caller_id).to eq('+19195555678')
  81. 1 expect(call_recording_metadata_from_hash.transfer_to).to eq('+19195558765')
  82. 1 expect(call_recording_metadata_from_hash.duration).to eq('PT13.67S')
  83. 1 expect(call_recording_metadata_from_hash.direction).to eq(Bandwidth::CallDirectionEnum::INBOUND)
  84. 1 expect(call_recording_metadata_from_hash.channels).to eq(1)
  85. 1 expect(call_recording_metadata_from_hash.start_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  86. 1 expect(call_recording_metadata_from_hash.end_time).to eq(Time.parse('2022-06-16T13:15:20.830Z'))
  87. 1 expect(call_recording_metadata_from_hash.file_format).to eq(Bandwidth::FileFormatEnum::WAV)
  88. 1 expect(call_recording_metadata_from_hash.status).to eq('complete')
  89. 1 expect(call_recording_metadata_from_hash.media_url).to eq('https://example.com/recording.wav')
  90. 1 expect(call_recording_metadata_from_hash.recording_name).to eq('sample-recording')
  91. end
  92. end
  93. 1 describe '#to_s' do
  94. 1 it 'returns a string representation of the object' do
  95. 1 expect(call_recording_metadata_values.to_s).to eq('{:applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :accountId=>"9900000", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :parentCallId=>"c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99", :recordingId=>"r-fbe05094-9fd2b71d-a4e6-4f43-8c3e-5b04b1d8a4b4", :to=>"+19195551234", :from=>"+19195554321", :transferCallerId=>"+19195555678", :transferTo=>"+19195558765", :duration=>"PT13.67S", :direction=>"inbound", :channels=>1, :startTime=>"2022-06-16T13:15:07.160Z", :endTime=>"2022-06-16T13:15:20.830Z", :fileFormat=>"wav", :status=>"complete", :mediaUrl=>"https://example.com/recording.wav", :transcription=>{:id=>"t-123", :url=>"https://example.com/t-123", :status=>"available", :completed_time=>"2022-06-16T13:15:31.000Z"}, :recordingName=>"sample-recording"}')
  96. end
  97. end
  98. 1 describe '#eq? #==' do
  99. 1 it 'returns true/false when comparing objects' do
  100. 1 expect(call_recording_metadata_default.eql?(Bandwidth::CallRecordingMetadata.new)).to be true
  101. 1 expect(call_recording_metadata_default.eql?(call_recording_metadata_values)).to be false
  102. end
  103. end
  104. 1 describe '#to_body #to_hash' do
  105. 1 it 'returns a hash representation of the object' do
  106. 1 expect(call_recording_metadata_values.to_body).to eq({
  107. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  108. accountId: '9900000',
  109. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  110. parentCallId: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  111. recordingId: 'r-fbe05094-9fd2b71d-a4e6-4f43-8c3e-5b04b1d8a4b4',
  112. to: '+19195551234',
  113. from: '+19195554321',
  114. transferCallerId: '+19195555678',
  115. transferTo: '+19195558765',
  116. duration: 'PT13.67S',
  117. direction: Bandwidth::CallDirectionEnum::INBOUND,
  118. channels: 1,
  119. startTime: '2022-06-16T13:15:07.160Z',
  120. endTime: '2022-06-16T13:15:20.830Z',
  121. fileFormat: Bandwidth::FileFormatEnum::WAV,
  122. status: 'complete',
  123. mediaUrl: 'https://example.com/recording.wav',
  124. transcription: { id: 't-123', url: 'https://example.com/t-123', status: 'available', completed_time: '2022-06-16T13:15:31.000Z' },
  125. recordingName: 'sample-recording'
  126. })
  127. end
  128. end
  129. end

spec/unit/models/call_state_enum_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CallStateEnum
  2. 1 describe Bandwidth::CallStateEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines ACTIVE' do
  5. 1 expect(Bandwidth::CallStateEnum::ACTIVE).to eq('active')
  6. end
  7. 1 it 'defines COMPLETED' do
  8. 1 expect(Bandwidth::CallStateEnum::COMPLETED).to eq('completed')
  9. end
  10. end
  11. 1 describe '.all_vars' do
  12. 1 it 'returns every valid enum value' do
  13. 1 expect(Bandwidth::CallStateEnum.all_vars).to eq(['active', 'completed'])
  14. end
  15. end
  16. 1 describe '.build_from_hash' do
  17. 1 it 'returns the value when it matches a valid enum value' do
  18. 1 expect(Bandwidth::CallStateEnum.build_from_hash('active')).to eq('active')
  19. 1 expect(Bandwidth::CallStateEnum.build_from_hash('completed')).to eq('completed')
  20. end
  21. 1 it 'raises an error for an invalid enum value' do
  22. 1 expect {
  23. 1 Bandwidth::CallStateEnum.build_from_hash('invalid')
  24. }.to raise_error(RuntimeError)
  25. end
  26. end
  27. end

spec/unit/models/call_state_spec.rb

100.0% lines covered

48 relevant lines. 48 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CallState
  2. 1 describe Bandwidth::CallState do
  3. 2 let(:call_state_default) { Bandwidth::CallState.new }
  4. 4 let(:call_state_values) { Bandwidth::CallState.new({
  5. application_id: '04e88489-df02-4e34-a0ee-27a91849555f',
  6. account_id: '9900000',
  7. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  8. parent_call_id: 'c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  9. to: '+19195551234',
  10. from: '+19195554321',
  11. direction: 'inbound',
  12. state: 'disconnected',
  13. stir_shaken: {
  14. 'verstat': 'TN-Verification-Passed',
  15. 'attestationIndicator': 'A',
  16. 'originatingId': 'abc123'
  17. },
  18. identity: 'eyJhbGciOiJFUzI1NiI',
  19. enqueued_time: '2022-06-16T13:15:07.160Z',
  20. start_time: '2022-06-16T13:15:07.160Z',
  21. answer_time: '2022-06-16T13:15:18.126Z',
  22. end_time: '2022-06-16T13:15:18.314Z',
  23. disconnect_cause: 'hangup',
  24. error_message: nil,
  25. error_id: nil,
  26. last_update: '2022-06-16T13:15:18.314Z'
  27. }) }
  28. 1 describe '#initialize' do
  29. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  30. 1 expect {
  31. 1 Bandwidth::CallState.new([])
  32. }.to raise_error(ArgumentError)
  33. end
  34. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  35. 1 expect {
  36. 1 Bandwidth::CallState.new({ invalid: true })
  37. }.to raise_error(ArgumentError)
  38. end
  39. end
  40. 1 describe '#acceptable_attributes' do
  41. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  42. 1 expect(Bandwidth::CallState.acceptable_attributes).to eq(Bandwidth::CallState.attribute_map.values)
  43. end
  44. end
  45. 1 describe '#openapi_nullable' do
  46. 1 it 'expects nullable attributes to be the set of nullable fields' do
  47. 1 expect(Bandwidth::CallState.openapi_nullable).to eq(Set.new([
  48. :'parent_call_id',
  49. :'stir_shaken',
  50. :'identity',
  51. :'enqueued_time',
  52. :'start_time',
  53. :'answer_time',
  54. :'end_time',
  55. :'disconnect_cause',
  56. :'error_message',
  57. :'error_id'
  58. ]))
  59. end
  60. end
  61. 1 describe '#build_from_hash' do
  62. 1 it 'validates instance of CallState created by the build_from_hash method' do
  63. 1 call_state_from_hash = Bandwidth::CallState.build_from_hash({
  64. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  65. accountId: '9900000',
  66. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  67. parentCallId: 'c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  68. to: '+19195551234',
  69. from: '+19195554321',
  70. direction: 'inbound',
  71. state: 'disconnected',
  72. stirShaken: {
  73. 'verstat': 'TN-Verification-Passed',
  74. 'attestationIndicator': 'A',
  75. 'originatingId': 'abc123'
  76. },
  77. identity: 'eyJhbGciOiJFUzI1NiI',
  78. enqueuedTime: '2022-06-16T13:15:07.160Z',
  79. startTime: '2022-06-16T13:15:07.160Z',
  80. answerTime: '2022-06-16T13:15:18.126Z',
  81. endTime: '2022-06-16T13:15:18.314Z',
  82. disconnectCause: 'hangup',
  83. errorMessage: nil,
  84. errorId: nil,
  85. lastUpdate: '2022-06-16T13:15:18.314Z'
  86. })
  87. 1 expect(call_state_from_hash).to be_instance_of(Bandwidth::CallState)
  88. 1 expect(call_state_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f')
  89. 1 expect(call_state_from_hash.account_id).to eq('9900000')
  90. 1 expect(call_state_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  91. 1 expect(call_state_from_hash.parent_call_id).to eq('c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  92. 1 expect(call_state_from_hash.to).to eq('+19195551234')
  93. 1 expect(call_state_from_hash.from).to eq('+19195554321')
  94. 1 expect(call_state_from_hash.direction).to eq('inbound')
  95. 1 expect(call_state_from_hash.state).to eq('disconnected')
  96. 1 expect(call_state_from_hash.stir_shaken).to eq({
  97. 'verstat' => 'TN-Verification-Passed',
  98. 'attestationIndicator' => 'A',
  99. 'originatingId' => 'abc123'
  100. })
  101. 1 expect(call_state_from_hash.identity).to eq('eyJhbGciOiJFUzI1NiI')
  102. 1 expect(call_state_from_hash.enqueued_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  103. 1 expect(call_state_from_hash.start_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  104. 1 expect(call_state_from_hash.answer_time).to eq(Time.parse('2022-06-16T13:15:18.126Z'))
  105. 1 expect(call_state_from_hash.end_time).to eq(Time.parse('2022-06-16T13:15:18.314Z'))
  106. 1 expect(call_state_from_hash.disconnect_cause).to eq('hangup')
  107. 1 expect(call_state_from_hash.error_message).to eq(nil)
  108. 1 expect(call_state_from_hash.error_id).to eq(nil)
  109. 1 expect(call_state_from_hash.last_update).to eq(Time.parse('2022-06-16T13:15:18.314Z'))
  110. end
  111. end
  112. 1 describe '#to_s' do
  113. 1 it 'returns a string representation of the object' do
  114. 1 expect(call_state_values.to_s).to eq('{:applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :accountId=>"9900000", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :parentCallId=>"c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :to=>"+19195551234", :from=>"+19195554321", :direction=>"inbound", :state=>"disconnected", :stirShaken=>{:verstat=>"TN-Verification-Passed", :attestationIndicator=>"A", :originatingId=>"abc123"}, :identity=>"eyJhbGciOiJFUzI1NiI", :enqueuedTime=>"2022-06-16T13:15:07.160Z", :startTime=>"2022-06-16T13:15:07.160Z", :answerTime=>"2022-06-16T13:15:18.126Z", :endTime=>"2022-06-16T13:15:18.314Z", :disconnectCause=>"hangup", :errorMessage=>nil, :errorId=>nil, :lastUpdate=>"2022-06-16T13:15:18.314Z"}')
  115. end
  116. end
  117. 1 describe '#eq? #==' do
  118. 1 it 'returns true/false when comparing objects' do
  119. 1 expect(call_state_default.eql?(Bandwidth::CallState.new)).to be true
  120. 1 expect(call_state_default.eql?(call_state_values)).to be false
  121. end
  122. end
  123. 1 describe '#to_body #to_hash' do
  124. 1 it 'returns a hash representation of the object' do
  125. 1 expect(call_state_values.to_body).to eq({
  126. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  127. accountId: '9900000',
  128. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  129. parentCallId: 'c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  130. to: '+19195551234',
  131. from: '+19195554321',
  132. direction: 'inbound',
  133. state: 'disconnected',
  134. stirShaken: {
  135. 'verstat': 'TN-Verification-Passed',
  136. 'attestationIndicator': 'A',
  137. 'originatingId': 'abc123'
  138. },
  139. identity: 'eyJhbGciOiJFUzI1NiI',
  140. enqueuedTime: '2022-06-16T13:15:07.160Z',
  141. startTime: '2022-06-16T13:15:07.160Z',
  142. answerTime: '2022-06-16T13:15:18.126Z',
  143. endTime: '2022-06-16T13:15:18.314Z',
  144. disconnectCause: 'hangup',
  145. errorMessage: nil,
  146. errorId: nil,
  147. lastUpdate: '2022-06-16T13:15:18.314Z'
  148. })
  149. end
  150. end
  151. end

spec/unit/models/call_transcription_detected_language_enum_spec.rb

100.0% lines covered

19 relevant lines. 19 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CallTranscriptionDetectedLanguageEnum
  2. 1 describe Bandwidth::CallTranscriptionDetectedLanguageEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines EN_US' do
  5. 1 expect(Bandwidth::CallTranscriptionDetectedLanguageEnum::EN_US).to eq('en-US')
  6. end
  7. 1 it 'defines ES_US' do
  8. 1 expect(Bandwidth::CallTranscriptionDetectedLanguageEnum::ES_US).to eq('es-US')
  9. end
  10. 1 it 'defines FR_FR' do
  11. 1 expect(Bandwidth::CallTranscriptionDetectedLanguageEnum::FR_FR).to eq('fr-FR')
  12. end
  13. end
  14. 1 describe '.all_vars' do
  15. 1 it 'returns every valid enum value' do
  16. 1 expect(Bandwidth::CallTranscriptionDetectedLanguageEnum.all_vars).to eq([
  17. 'en-US',
  18. 'es-US',
  19. 'fr-FR'
  20. ])
  21. end
  22. end
  23. 1 describe '.build_from_hash' do
  24. 1 it 'returns the value when it matches a valid enum value' do
  25. 1 expect(Bandwidth::CallTranscriptionDetectedLanguageEnum.build_from_hash('en-US')).to eq('en-US')
  26. 1 expect(Bandwidth::CallTranscriptionDetectedLanguageEnum.build_from_hash('es-US')).to eq('es-US')
  27. 1 expect(Bandwidth::CallTranscriptionDetectedLanguageEnum.build_from_hash('fr-FR')).to eq('fr-FR')
  28. end
  29. 1 it 'raises an error for an invalid enum value' do
  30. 1 expect {
  31. 1 Bandwidth::CallTranscriptionDetectedLanguageEnum.build_from_hash('invalid')
  32. }.to raise_error(RuntimeError)
  33. end
  34. end
  35. end

spec/unit/models/call_transcription_metadata_spec.rb

100.0% lines covered

33 relevant lines. 33 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CallTranscriptionMetadata
  2. 1 describe Bandwidth::CallTranscriptionMetadata do
  3. 2 let(:call_transcription_metadata_default) { Bandwidth::CallTranscriptionMetadata.new }
  4. 4 let(:call_transcription_metadata_values) { Bandwidth::CallTranscriptionMetadata.new({
  5. transcription_id: 't-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  6. transcription_name: 'live-transcription',
  7. transcription_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-1/transcriptions/t-1'
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::CallTranscriptionMetadata.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::CallTranscriptionMetadata.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::CallTranscriptionMetadata.acceptable_attributes).to eq(Bandwidth::CallTranscriptionMetadata.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be an empty set' do
  28. 1 expect(Bandwidth::CallTranscriptionMetadata.openapi_nullable).to eq(Set.new([]))
  29. end
  30. end
  31. 1 describe '#build_from_hash' do
  32. 1 it 'validates instance of CallTranscriptionMetadata created by the build_from_hash method' do
  33. 1 call_transcription_metadata_from_hash = Bandwidth::CallTranscriptionMetadata.build_from_hash({
  34. transcriptionId: 't-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  35. transcriptionName: 'live-transcription',
  36. transcriptionUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-1/transcriptions/t-1'
  37. })
  38. 1 expect(call_transcription_metadata_from_hash).to be_instance_of(Bandwidth::CallTranscriptionMetadata)
  39. 1 expect(call_transcription_metadata_from_hash.transcription_id).to eq('t-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  40. 1 expect(call_transcription_metadata_from_hash.transcription_name).to eq('live-transcription')
  41. 1 expect(call_transcription_metadata_from_hash.transcription_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-1/transcriptions/t-1')
  42. end
  43. end
  44. 1 describe '#to_s' do
  45. 1 it 'returns a string representation of the object' do
  46. 1 expect(call_transcription_metadata_values.to_s).to eq('{:transcriptionId=>"t-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :transcriptionName=>"live-transcription", :transcriptionUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-1/transcriptions/t-1"}')
  47. end
  48. end
  49. 1 describe '#eq? #==' do
  50. 1 it 'returns true/false when comparing objects' do
  51. 1 expect(call_transcription_metadata_default.eql?(Bandwidth::CallTranscriptionMetadata.new)).to be true
  52. 1 expect(call_transcription_metadata_default.eql?(call_transcription_metadata_values)).to be false
  53. end
  54. end
  55. 1 describe '#to_body #to_hash' do
  56. 1 it 'returns a hash representation of the object' do
  57. 1 expect(call_transcription_metadata_values.to_body).to eq({
  58. transcriptionId: 't-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  59. transcriptionName: 'live-transcription',
  60. transcriptionUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-1/transcriptions/t-1'
  61. })
  62. end
  63. end
  64. end

spec/unit/models/call_transcription_response_spec.rb

100.0% lines covered

34 relevant lines. 34 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CallTranscriptionResponse
  2. 1 describe Bandwidth::CallTranscriptionResponse do
  3. 2 let(:call_transcription_response_default) { Bandwidth::CallTranscriptionResponse.new }
  4. 4 let(:call_transcription_response_values) { Bandwidth::CallTranscriptionResponse.new({
  5. account_id: '9900000',
  6. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  7. transcription_id: 't-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  8. tracks: [Bandwidth::CallTranscription.new({ detected_language: 'en-US', track: 'inbound', transcript: 'Hello', confidence: 0.9 })]
  9. }) }
  10. 1 describe '#initialize' do
  11. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  12. 1 expect {
  13. 1 Bandwidth::CallTranscriptionResponse.new([])
  14. }.to raise_error(ArgumentError)
  15. end
  16. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  17. 1 expect {
  18. 1 Bandwidth::CallTranscriptionResponse.new({ invalid: true })
  19. }.to raise_error(ArgumentError)
  20. end
  21. end
  22. 1 describe '#acceptable_attributes' do
  23. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  24. 1 expect(Bandwidth::CallTranscriptionResponse.acceptable_attributes).to eq(Bandwidth::CallTranscriptionResponse.attribute_map.values)
  25. end
  26. end
  27. 1 describe '#openapi_nullable' do
  28. 1 it 'expects nullable attributes to be an empty set' do
  29. 1 expect(Bandwidth::CallTranscriptionResponse.openapi_nullable).to eq(Set.new([]))
  30. end
  31. end
  32. 1 describe '#build_from_hash' do
  33. 1 it 'validates instance of CallTranscriptionResponse created by the build_from_hash method' do
  34. 1 call_transcription_response_from_hash = Bandwidth::CallTranscriptionResponse.build_from_hash({
  35. accountId: '9900000',
  36. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  37. transcriptionId: 't-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  38. tracks: [{ detectedLanguage: 'en-US', track: 'inbound', transcript: 'Hello', confidence: 0.9 }]
  39. })
  40. 1 expect(call_transcription_response_from_hash).to be_instance_of(Bandwidth::CallTranscriptionResponse)
  41. 1 expect(call_transcription_response_from_hash.account_id).to eq('9900000')
  42. 1 expect(call_transcription_response_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  43. 1 expect(call_transcription_response_from_hash.transcription_id).to eq('t-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  44. 1 expect(call_transcription_response_from_hash.tracks.first).to be_instance_of(Bandwidth::CallTranscription)
  45. end
  46. end
  47. 1 describe '#to_s' do
  48. 1 it 'returns a string representation of the object' do
  49. 1 expect(call_transcription_response_values.to_s).to eq('{:accountId=>"9900000", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :transcriptionId=>"t-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :tracks=>[{:detectedLanguage=>"en-US", :track=>"inbound", :transcript=>"Hello", :confidence=>0.9}]}')
  50. end
  51. end
  52. 1 describe '#eq? #==' do
  53. 1 it 'returns true/false when comparing objects' do
  54. 1 expect(call_transcription_response_default.eql?(Bandwidth::CallTranscriptionResponse.new)).to be true
  55. 1 expect(call_transcription_response_default.eql?(call_transcription_response_values)).to be false
  56. end
  57. end
  58. 1 describe '#to_body #to_hash' do
  59. 1 it 'returns a hash representation of the object' do
  60. 1 expect(call_transcription_response_values.to_body).to eq({
  61. accountId: '9900000',
  62. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  63. transcriptionId: 't-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  64. tracks: [{ detectedLanguage: 'en-US', track: 'inbound', transcript: 'Hello', confidence: 0.9 }]
  65. })
  66. end
  67. end
  68. end

spec/unit/models/call_transcription_spec.rb

100.0% lines covered

42 relevant lines. 42 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CallTranscription
  2. 1 describe Bandwidth::CallTranscription do
  3. 2 let(:call_transcription_default) { Bandwidth::CallTranscription.new }
  4. 4 let(:call_transcription_values) { Bandwidth::CallTranscription.new({
  5. detected_language: Bandwidth::CallTranscriptionDetectedLanguageEnum::EN_US,
  6. track: Bandwidth::CallTranscriptionTrackEnum::INBOUND,
  7. transcript: 'Hello world',
  8. confidence: 0.9
  9. }) }
  10. 1 describe '#initialize' do
  11. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  12. 1 expect {
  13. 1 Bandwidth::CallTranscription.new([])
  14. }.to raise_error(ArgumentError)
  15. end
  16. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  17. 1 expect {
  18. 1 Bandwidth::CallTranscription.new({ invalid: true })
  19. }.to raise_error(ArgumentError)
  20. end
  21. end
  22. 1 describe '#acceptable_attributes' do
  23. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  24. 1 expect(Bandwidth::CallTranscription.acceptable_attributes).to eq(Bandwidth::CallTranscription.attribute_map.values)
  25. end
  26. end
  27. 1 describe '#openapi_nullable' do
  28. 1 it 'expects nullable attributes to be an empty set' do
  29. 1 expect(Bandwidth::CallTranscription.openapi_nullable).to eq(Set.new([]))
  30. end
  31. end
  32. 1 describe '#build_from_hash' do
  33. 1 it 'validates instance of CallTranscription created by the build_from_hash method' do
  34. 1 call_transcription_from_hash = Bandwidth::CallTranscription.build_from_hash({
  35. detectedLanguage: 'en-US',
  36. track: 'inbound',
  37. transcript: 'Hello world',
  38. confidence: 0.9
  39. })
  40. 1 expect(call_transcription_from_hash).to be_instance_of(Bandwidth::CallTranscription)
  41. 1 expect(call_transcription_from_hash.detected_language).to eq(Bandwidth::CallTranscriptionDetectedLanguageEnum::EN_US)
  42. 1 expect(call_transcription_from_hash.track).to eq(Bandwidth::CallTranscriptionTrackEnum::INBOUND)
  43. 1 expect(call_transcription_from_hash.transcript).to eq('Hello world')
  44. 1 expect(call_transcription_from_hash.confidence).to eq(0.9)
  45. end
  46. end
  47. 1 describe '#to_s' do
  48. 1 it 'returns a string representation of the object' do
  49. 1 expect(call_transcription_values.to_s).to eq('{:detectedLanguage=>"en-US", :track=>"inbound", :transcript=>"Hello world", :confidence=>0.9}')
  50. end
  51. end
  52. 1 describe '#eq? #==' do
  53. 1 it 'returns true/false when comparing objects' do
  54. 1 expect(call_transcription_default.eql?(Bandwidth::CallTranscription.new)).to be true
  55. 1 expect(call_transcription_default.eql?(call_transcription_values)).to be false
  56. end
  57. end
  58. 1 describe '#to_body #to_hash' do
  59. 1 it 'returns a hash representation of the object' do
  60. 1 expect(call_transcription_values.to_body).to eq({
  61. detectedLanguage: Bandwidth::CallTranscriptionDetectedLanguageEnum::EN_US,
  62. track: Bandwidth::CallTranscriptionTrackEnum::INBOUND,
  63. transcript: 'Hello world',
  64. confidence: 0.9
  65. })
  66. end
  67. end
  68. 1 describe 'custom attribute writers' do
  69. 1 it '#confidence=' do
  70. 1 expect {
  71. 1 Bandwidth::CallTranscription.new({ confidence: nil })
  72. }.to raise_error(ArgumentError, 'confidence cannot be nil')
  73. 1 expect {
  74. 1 Bandwidth::CallTranscription.new({ confidence: 1.5 })
  75. }.to raise_error(ArgumentError, 'invalid value for "confidence", must be smaller than or equal to 1.')
  76. 1 expect {
  77. 1 Bandwidth::CallTranscription.new({ confidence: -0.5 })
  78. }.to raise_error(ArgumentError, 'invalid value for "confidence", must be greater than or equal to 0.')
  79. end
  80. end
  81. end

spec/unit/models/call_transcription_track_enum_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CallTranscriptionTrackEnum
  2. 1 describe Bandwidth::CallTranscriptionTrackEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines INBOUND' do
  5. 1 expect(Bandwidth::CallTranscriptionTrackEnum::INBOUND).to eq('inbound')
  6. end
  7. 1 it 'defines OUTBOUND' do
  8. 1 expect(Bandwidth::CallTranscriptionTrackEnum::OUTBOUND).to eq('outbound')
  9. end
  10. end
  11. 1 describe '.all_vars' do
  12. 1 it 'returns every valid enum value' do
  13. 1 expect(Bandwidth::CallTranscriptionTrackEnum.all_vars).to eq([
  14. 'inbound',
  15. 'outbound'
  16. ])
  17. end
  18. end
  19. 1 describe '.build_from_hash' do
  20. 1 it 'returns the value when it matches a valid enum value' do
  21. 1 expect(Bandwidth::CallTranscriptionTrackEnum.build_from_hash('inbound')).to eq('inbound')
  22. 1 expect(Bandwidth::CallTranscriptionTrackEnum.build_from_hash('outbound')).to eq('outbound')
  23. end
  24. 1 it 'raises an error for an invalid enum value' do
  25. 1 expect {
  26. 1 Bandwidth::CallTranscriptionTrackEnum.build_from_hash('invalid')
  27. }.to raise_error(RuntimeError)
  28. end
  29. end
  30. end

spec/unit/models/callback_method_enum_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CallbackMethodEnum
  2. 1 describe Bandwidth::CallbackMethodEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines GET' do
  5. 1 expect(Bandwidth::CallbackMethodEnum::GET).to eq('GET')
  6. end
  7. 1 it 'defines POST' do
  8. 1 expect(Bandwidth::CallbackMethodEnum::POST).to eq('POST')
  9. end
  10. end
  11. 1 describe '.all_vars' do
  12. 1 it 'returns every valid enum value' do
  13. 1 expect(Bandwidth::CallbackMethodEnum.all_vars).to eq([
  14. 'GET',
  15. 'POST'
  16. ])
  17. end
  18. end
  19. 1 describe '.build_from_hash' do
  20. 1 it 'returns the value when it matches a valid enum value' do
  21. 1 expect(Bandwidth::CallbackMethodEnum.build_from_hash('GET')).to eq('GET')
  22. 1 expect(Bandwidth::CallbackMethodEnum.build_from_hash('POST')).to eq('POST')
  23. end
  24. 1 it 'raises an error for an invalid enum value' do
  25. 1 expect {
  26. 1 Bandwidth::CallbackMethodEnum.build_from_hash('invalid')
  27. }.to raise_error(RuntimeError)
  28. end
  29. end
  30. end

spec/unit/models/callback_spec.rb

100.0% lines covered

30 relevant lines. 30 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Callback
  2. 1 describe Bandwidth::Callback do
  3. 1 describe '.openapi_one_of' do
  4. 1 it 'lists the classes defined in oneOf' do
  5. 1 expect(Bandwidth::Callback.openapi_one_of).to eq([
  6. :'InboundCallback',
  7. :'StatusCallback'
  8. ])
  9. end
  10. end
  11. 1 describe '.openapi_discriminator_name' do
  12. 1 it 'returns the discriminator property name' do
  13. 1 expect(Bandwidth::Callback.openapi_discriminator_name).to eq(:'type')
  14. end
  15. end
  16. 1 describe '.openapi_discriminator_mapping' do
  17. 1 it 'maps every discriminator value to a oneOf class' do
  18. 1 expect(Bandwidth::Callback.openapi_discriminator_mapping).to eq({
  19. :'message-delivered' => :'StatusCallback',
  20. :'message-failed' => :'StatusCallback',
  21. :'message-read' => :'StatusCallback',
  22. :'message-received' => :'InboundCallback',
  23. :'message-sending' => :'StatusCallback',
  24. :'message-sent' => :'StatusCallback',
  25. :'request-location-response' => :'InboundCallback',
  26. :'suggestion-response' => :'InboundCallback'
  27. })
  28. end
  29. 1 it 'maps only to classes listed in openapi_one_of' do
  30. 1 mapping_targets = Bandwidth::Callback.openapi_discriminator_mapping.values.uniq.sort
  31. 1 expect(mapping_targets).to eq(Bandwidth::Callback.openapi_one_of.sort)
  32. end
  33. end
  34. 1 describe '.build' do
  35. 1 it 'routes inbound discriminator values to InboundCallback.build_from_hash' do
  36. 1 Bandwidth::Callback.openapi_discriminator_mapping.each do |discriminator, klass|
  37. 8 next unless klass == :'InboundCallback'
  38. 3 data = { type: discriminator.to_s }
  39. 3 expect(Bandwidth::InboundCallback).to receive(:build_from_hash).with(data).and_return(:inbound_result)
  40. 3 expect(Bandwidth::Callback.build(data)).to eq(:inbound_result)
  41. end
  42. end
  43. 1 it 'routes status discriminator values to StatusCallback.build_from_hash' do
  44. 1 Bandwidth::Callback.openapi_discriminator_mapping.each do |discriminator, klass|
  45. 8 next unless klass == :'StatusCallback'
  46. 5 data = { type: discriminator.to_s }
  47. 5 expect(Bandwidth::StatusCallback).to receive(:build_from_hash).with(data).and_return(:status_result)
  48. 5 expect(Bandwidth::Callback.build(data)).to eq(:status_result)
  49. end
  50. end
  51. 1 it 'returns nil when the discriminator value is missing' do
  52. 1 expect(Bandwidth::Callback.build({})).to be_nil
  53. end
  54. 1 it 'returns nil when the discriminator value does not match any mapping' do
  55. 1 expect(Bandwidth::Callback.build({ type: 'unknown' })).to be_nil
  56. end
  57. end
  58. end

spec/unit/models/card_width_enum_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CardWidthEnum
  2. 1 describe Bandwidth::CardWidthEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines SMALL' do
  5. 1 expect(Bandwidth::CardWidthEnum::SMALL).to eq('SMALL')
  6. end
  7. 1 it 'defines MEDIUM' do
  8. 1 expect(Bandwidth::CardWidthEnum::MEDIUM).to eq('MEDIUM')
  9. end
  10. end
  11. 1 describe '.all_vars' do
  12. 1 it 'returns every valid enum value' do
  13. 1 expect(Bandwidth::CardWidthEnum.all_vars).to eq([
  14. 'SMALL',
  15. 'MEDIUM'
  16. ])
  17. end
  18. end
  19. 1 describe '.build_from_hash' do
  20. 1 it 'returns the value when it matches a valid enum value' do
  21. 1 expect(Bandwidth::CardWidthEnum.build_from_hash('SMALL')).to eq('SMALL')
  22. 1 expect(Bandwidth::CardWidthEnum.build_from_hash('MEDIUM')).to eq('MEDIUM')
  23. end
  24. 1 it 'raises an error for an invalid enum value' do
  25. 1 expect {
  26. 1 Bandwidth::CardWidthEnum.build_from_hash('invalid')
  27. }.to raise_error(RuntimeError)
  28. end
  29. end
  30. end

spec/unit/models/code_request_spec.rb

100.0% lines covered

72 relevant lines. 72 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CodeRequest
  2. 1 describe Bandwidth::CodeRequest do
  3. 2 let(:code_request_default) { Bandwidth::CodeRequest.new({
  4. to: '+19195550100',
  5. from: '+19195550101',
  6. application_id: 'baseline-app',
  7. message: 'Your code is {CODE}',
  8. digits: 6
  9. }) }
  10. 4 let(:code_request_values) { Bandwidth::CodeRequest.new({
  11. to: '+19195551234',
  12. from: '+19195554321',
  13. application_id: '04e88489-df02-4e34-a0ee-27a91849555f',
  14. scope: '2FA',
  15. message: 'Your verification code is {CODE}',
  16. digits: 8
  17. }) }
  18. 1 describe '#initialize' do
  19. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  20. 1 expect {
  21. 1 Bandwidth::CodeRequest.new([])
  22. }.to raise_error(ArgumentError)
  23. end
  24. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  25. 1 expect {
  26. 1 Bandwidth::CodeRequest.new({ invalid: true })
  27. }.to raise_error(ArgumentError)
  28. end
  29. end
  30. 1 describe '#acceptable_attributes' do
  31. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  32. 1 expect(Bandwidth::CodeRequest.acceptable_attributes).to eq(Bandwidth::CodeRequest.attribute_map.values)
  33. end
  34. end
  35. 1 describe '#openapi_nullable' do
  36. 1 it 'expects nullable attributes to be an empty set' do
  37. 1 expect(Bandwidth::CodeRequest.openapi_nullable).to eq(Set.new([]))
  38. end
  39. end
  40. 1 describe '#build_from_hash' do
  41. 1 it 'validates instance of CodeRequest created by the build_from_hash method' do
  42. 1 code_request_from_hash = Bandwidth::CodeRequest.build_from_hash({
  43. to: '+19195551234',
  44. from: '+19195554321',
  45. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  46. scope: '2FA',
  47. message: 'Your verification code is {CODE}',
  48. digits: 8
  49. })
  50. 1 expect(code_request_from_hash).to be_instance_of(Bandwidth::CodeRequest)
  51. 1 expect(code_request_from_hash.to).to eq('+19195551234')
  52. 1 expect(code_request_from_hash.from).to eq('+19195554321')
  53. 1 expect(code_request_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f')
  54. 1 expect(code_request_from_hash.scope).to eq('2FA')
  55. 1 expect(code_request_from_hash.message).to eq('Your verification code is {CODE}')
  56. 1 expect(code_request_from_hash.digits).to eq(8)
  57. end
  58. end
  59. 1 describe '#to_s' do
  60. 1 it 'returns a string representation of the object' do
  61. 1 expect(code_request_values.to_s).to eq('{:to=>"+19195551234", :from=>"+19195554321", :applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :scope=>"2FA", :message=>"Your verification code is {CODE}", :digits=>8}')
  62. end
  63. end
  64. 1 describe '#eq? #==' do
  65. 1 it 'returns true/false when comparing objects' do
  66. 1 code_request_equal = Bandwidth::CodeRequest.new({
  67. to: '+19195550100',
  68. from: '+19195550101',
  69. application_id: 'baseline-app',
  70. message: 'Your code is {CODE}',
  71. digits: 6
  72. })
  73. 1 expect(code_request_default.eql?(code_request_equal)).to be true
  74. 1 expect(code_request_default.eql?(code_request_values)).to be false
  75. end
  76. end
  77. 1 describe '#to_body #to_hash' do
  78. 1 it 'returns a hash representation of the object' do
  79. 1 expect(code_request_values.to_body).to eq({
  80. to: '+19195551234',
  81. from: '+19195554321',
  82. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  83. scope: '2FA',
  84. message: 'Your verification code is {CODE}',
  85. digits: 8
  86. })
  87. end
  88. end
  89. 1 describe 'custom attribute writers' do
  90. 1 it '#to=' do
  91. 1 expect {
  92. 1 Bandwidth::CodeRequest.new({ to: nil, from: '+19195554321', application_id: 'a', message: 'm', digits: 6 })
  93. }.to raise_error(ArgumentError, 'to cannot be nil')
  94. 1 expect {
  95. 1 Bandwidth::CodeRequest.new({ to: 'invalid', from: '+19195554321', application_id: 'a', message: 'm', digits: 6 })
  96. }.to raise_error(ArgumentError, /invalid value for "to", must conform to the pattern/)
  97. end
  98. 1 it '#from=' do
  99. 1 expect {
  100. 1 Bandwidth::CodeRequest.new({ to: '+19195551234', from: nil, application_id: 'a', message: 'm', digits: 6 })
  101. }.to raise_error(ArgumentError, 'from cannot be nil')
  102. 1 expect {
  103. 1 Bandwidth::CodeRequest.new({ to: '+19195551234', from: '+1' + '9' * 32, application_id: 'a', message: 'm', digits: 6 })
  104. }.to raise_error(ArgumentError, 'invalid value for "from", the character length must be smaller than or equal to 32.')
  105. 1 expect {
  106. 1 Bandwidth::CodeRequest.new({ to: '+19195551234', from: 'invalid', application_id: 'a', message: 'm', digits: 6 })
  107. }.to raise_error(ArgumentError, /invalid value for "from", must conform to the pattern/)
  108. end
  109. 1 it '#application_id=' do
  110. 1 expect {
  111. 1 Bandwidth::CodeRequest.new({ to: '+19195551234', from: '+19195554321', application_id: nil, message: 'm', digits: 6 })
  112. }.to raise_error(ArgumentError, 'application_id cannot be nil')
  113. 1 expect {
  114. 1 Bandwidth::CodeRequest.new({ to: '+19195551234', from: '+19195554321', application_id: 'a' * 51, message: 'm', digits: 6 })
  115. }.to raise_error(ArgumentError, 'invalid value for "application_id", the character length must be smaller than or equal to 50.')
  116. end
  117. 1 it '#scope=' do
  118. 1 expect {
  119. 1 Bandwidth::CodeRequest.new({ to: '+19195551234', from: '+19195554321', application_id: 'a', scope: nil, message: 'm', digits: 6 })
  120. }.to raise_error(ArgumentError, 'scope cannot be nil')
  121. 1 expect {
  122. 1 Bandwidth::CodeRequest.new({ to: '+19195551234', from: '+19195554321', application_id: 'a', scope: 'a' * 26, message: 'm', digits: 6 })
  123. }.to raise_error(ArgumentError, 'invalid value for "scope", the character length must be smaller than or equal to 25.')
  124. end
  125. 1 it '#message=' do
  126. 1 expect {
  127. 1 Bandwidth::CodeRequest.new({ to: '+19195551234', from: '+19195554321', application_id: 'a', message: nil, digits: 6 })
  128. }.to raise_error(ArgumentError, 'message cannot be nil')
  129. 1 expect {
  130. 1 Bandwidth::CodeRequest.new({ to: '+19195551234', from: '+19195554321', application_id: 'a', message: 'a' * 2049, digits: 6 })
  131. }.to raise_error(ArgumentError, 'invalid value for "message", the character length must be smaller than or equal to 2048.')
  132. end
  133. 1 it '#digits=' do
  134. 1 expect {
  135. 1 Bandwidth::CodeRequest.new({ to: '+19195551234', from: '+19195554321', application_id: 'a', message: 'm', digits: nil })
  136. }.to raise_error(ArgumentError, 'digits cannot be nil')
  137. 1 expect {
  138. 1 Bandwidth::CodeRequest.new({ to: '+19195551234', from: '+19195554321', application_id: 'a', message: 'm', digits: 9 })
  139. }.to raise_error(ArgumentError, 'invalid value for "digits", must be smaller than or equal to 8.')
  140. 1 expect {
  141. 1 Bandwidth::CodeRequest.new({ to: '+19195551234', from: '+19195554321', application_id: 'a', message: 'm', digits: 3 })
  142. }.to raise_error(ArgumentError, 'invalid value for "digits", must be greater than or equal to 4.')
  143. end
  144. end
  145. end

spec/unit/models/completed_lookup_status_enum_spec.rb

100.0% lines covered

19 relevant lines. 19 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CompletedLookupStatusEnum
  2. 1 describe Bandwidth::CompletedLookupStatusEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines COMPLETE' do
  5. 1 expect(Bandwidth::CompletedLookupStatusEnum::COMPLETE).to eq('COMPLETE')
  6. end
  7. 1 it 'defines PARTIAL_COMPLETE' do
  8. 1 expect(Bandwidth::CompletedLookupStatusEnum::PARTIAL_COMPLETE).to eq('PARTIAL_COMPLETE')
  9. end
  10. 1 it 'defines FAILED' do
  11. 1 expect(Bandwidth::CompletedLookupStatusEnum::FAILED).to eq('FAILED')
  12. end
  13. end
  14. 1 describe '.all_vars' do
  15. 1 it 'returns every valid enum value' do
  16. 1 expect(Bandwidth::CompletedLookupStatusEnum.all_vars).to eq([
  17. 'COMPLETE',
  18. 'PARTIAL_COMPLETE',
  19. 'FAILED'
  20. ])
  21. end
  22. end
  23. 1 describe '.build_from_hash' do
  24. 1 it 'returns the value when it matches a valid enum value' do
  25. 1 expect(Bandwidth::CompletedLookupStatusEnum.build_from_hash('COMPLETE')).to eq('COMPLETE')
  26. 1 expect(Bandwidth::CompletedLookupStatusEnum.build_from_hash('PARTIAL_COMPLETE')).to eq('PARTIAL_COMPLETE')
  27. 1 expect(Bandwidth::CompletedLookupStatusEnum.build_from_hash('FAILED')).to eq('FAILED')
  28. end
  29. 1 it 'raises an error for an invalid enum value' do
  30. 1 expect {
  31. 1 Bandwidth::CompletedLookupStatusEnum.build_from_hash('invalid')
  32. }.to raise_error(RuntimeError)
  33. end
  34. end
  35. end

spec/unit/models/conference_completed_callback_spec.rb

100.0% lines covered

35 relevant lines. 35 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::ConferenceCompletedCallback
  2. 1 describe Bandwidth::ConferenceCompletedCallback do
  3. 2 let(:conference_completed_callback_default) { Bandwidth::ConferenceCompletedCallback.new }
  4. 4 let(:conference_completed_callback_values) { Bandwidth::ConferenceCompletedCallback.new({
  5. event_type: 'conferenceCompleted',
  6. event_time: '2022-06-16T13:15:07.160Z',
  7. conference_id: 'conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  8. name: 'my-conference-name',
  9. tag: 'custom tag'
  10. }) }
  11. 1 describe '#initialize' do
  12. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  13. 1 expect {
  14. 1 Bandwidth::ConferenceCompletedCallback.new([])
  15. }.to raise_error(ArgumentError)
  16. end
  17. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  18. 1 expect {
  19. 1 Bandwidth::ConferenceCompletedCallback.new({ invalid: true })
  20. }.to raise_error(ArgumentError)
  21. end
  22. end
  23. 1 describe '#acceptable_attributes' do
  24. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  25. 1 expect(Bandwidth::ConferenceCompletedCallback.acceptable_attributes).to eq(Bandwidth::ConferenceCompletedCallback.attribute_map.values)
  26. end
  27. end
  28. 1 describe '#openapi_nullable' do
  29. 1 it 'expects nullable attributes to be the set of nullable fields' do
  30. 1 expect(Bandwidth::ConferenceCompletedCallback.openapi_nullable).to eq(Set.new([
  31. :'tag'
  32. ]))
  33. end
  34. end
  35. 1 describe '#build_from_hash' do
  36. 1 it 'validates instance of ConferenceCompletedCallback created by the build_from_hash method' do
  37. 1 conference_completed_callback_from_hash = Bandwidth::ConferenceCompletedCallback.build_from_hash({
  38. eventType: 'conferenceCompleted',
  39. eventTime: '2022-06-16T13:15:07.160Z',
  40. conferenceId: 'conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  41. name: 'my-conference-name',
  42. tag: 'custom tag'
  43. })
  44. 1 expect(conference_completed_callback_from_hash).to be_instance_of(Bandwidth::ConferenceCompletedCallback)
  45. 1 expect(conference_completed_callback_from_hash.event_type).to eq('conferenceCompleted')
  46. 1 expect(conference_completed_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  47. 1 expect(conference_completed_callback_from_hash.conference_id).to eq('conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  48. 1 expect(conference_completed_callback_from_hash.name).to eq('my-conference-name')
  49. 1 expect(conference_completed_callback_from_hash.tag).to eq('custom tag')
  50. end
  51. end
  52. 1 describe '#to_s' do
  53. 1 it 'returns a string representation of the object' do
  54. 1 expect(conference_completed_callback_values.to_s).to eq('{:eventType=>"conferenceCompleted", :eventTime=>"2022-06-16T13:15:07.160Z", :conferenceId=>"conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :name=>"my-conference-name", :tag=>"custom tag"}')
  55. end
  56. end
  57. 1 describe '#eq? #==' do
  58. 1 it 'returns true/false when comparing objects' do
  59. 1 expect(conference_completed_callback_default.eql?(Bandwidth::ConferenceCompletedCallback.new)).to be true
  60. 1 expect(conference_completed_callback_default.eql?(conference_completed_callback_values)).to be false
  61. end
  62. end
  63. 1 describe '#to_body #to_hash' do
  64. 1 it 'returns a hash representation of the object' do
  65. 1 expect(conference_completed_callback_values.to_body).to eq({
  66. eventType: 'conferenceCompleted',
  67. eventTime: '2022-06-16T13:15:07.160Z',
  68. conferenceId: 'conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  69. name: 'my-conference-name',
  70. tag: 'custom tag'
  71. })
  72. end
  73. end
  74. end

spec/unit/models/conference_created_callback_spec.rb

100.0% lines covered

35 relevant lines. 35 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::ConferenceCreatedCallback
  2. 1 describe Bandwidth::ConferenceCreatedCallback do
  3. 2 let(:conference_created_callback_default) { Bandwidth::ConferenceCreatedCallback.new }
  4. 4 let(:conference_created_callback_values) { Bandwidth::ConferenceCreatedCallback.new({
  5. event_type: 'conferenceCreated',
  6. event_time: '2022-06-16T13:15:07.160Z',
  7. conference_id: 'conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  8. name: 'my-conference-name',
  9. tag: 'custom tag'
  10. }) }
  11. 1 describe '#initialize' do
  12. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  13. 1 expect {
  14. 1 Bandwidth::ConferenceCreatedCallback.new([])
  15. }.to raise_error(ArgumentError)
  16. end
  17. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  18. 1 expect {
  19. 1 Bandwidth::ConferenceCreatedCallback.new({ invalid: true })
  20. }.to raise_error(ArgumentError)
  21. end
  22. end
  23. 1 describe '#acceptable_attributes' do
  24. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  25. 1 expect(Bandwidth::ConferenceCreatedCallback.acceptable_attributes).to eq(Bandwidth::ConferenceCreatedCallback.attribute_map.values)
  26. end
  27. end
  28. 1 describe '#openapi_nullable' do
  29. 1 it 'expects nullable attributes to be the set of nullable fields' do
  30. 1 expect(Bandwidth::ConferenceCreatedCallback.openapi_nullable).to eq(Set.new([
  31. :'tag'
  32. ]))
  33. end
  34. end
  35. 1 describe '#build_from_hash' do
  36. 1 it 'validates instance of ConferenceCreatedCallback created by the build_from_hash method' do
  37. 1 conference_created_callback_from_hash = Bandwidth::ConferenceCreatedCallback.build_from_hash({
  38. eventType: 'conferenceCreated',
  39. eventTime: '2022-06-16T13:15:07.160Z',
  40. conferenceId: 'conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  41. name: 'my-conference-name',
  42. tag: 'custom tag'
  43. })
  44. 1 expect(conference_created_callback_from_hash).to be_instance_of(Bandwidth::ConferenceCreatedCallback)
  45. 1 expect(conference_created_callback_from_hash.event_type).to eq('conferenceCreated')
  46. 1 expect(conference_created_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  47. 1 expect(conference_created_callback_from_hash.conference_id).to eq('conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  48. 1 expect(conference_created_callback_from_hash.name).to eq('my-conference-name')
  49. 1 expect(conference_created_callback_from_hash.tag).to eq('custom tag')
  50. end
  51. end
  52. 1 describe '#to_s' do
  53. 1 it 'returns a string representation of the object' do
  54. 1 expect(conference_created_callback_values.to_s).to eq('{:eventType=>"conferenceCreated", :eventTime=>"2022-06-16T13:15:07.160Z", :conferenceId=>"conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :name=>"my-conference-name", :tag=>"custom tag"}')
  55. end
  56. end
  57. 1 describe '#eq? #==' do
  58. 1 it 'returns true/false when comparing objects' do
  59. 1 expect(conference_created_callback_default.eql?(Bandwidth::ConferenceCreatedCallback.new)).to be true
  60. 1 expect(conference_created_callback_default.eql?(conference_created_callback_values)).to be false
  61. end
  62. end
  63. 1 describe '#to_body #to_hash' do
  64. 1 it 'returns a hash representation of the object' do
  65. 1 expect(conference_created_callback_values.to_body).to eq({
  66. eventType: 'conferenceCreated',
  67. eventTime: '2022-06-16T13:15:07.160Z',
  68. conferenceId: 'conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  69. name: 'my-conference-name',
  70. tag: 'custom tag'
  71. })
  72. end
  73. end
  74. end

spec/unit/models/conference_member_exit_callback_spec.rb

100.0% lines covered

38 relevant lines. 38 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::ConferenceMemberExitCallback
  2. 1 describe Bandwidth::ConferenceMemberExitCallback do
  3. 2 let(:conference_member_exit_callback_default) { Bandwidth::ConferenceMemberExitCallback.new }
  4. 4 let(:conference_member_exit_callback_values) { Bandwidth::ConferenceMemberExitCallback.new({
  5. event_type: 'conferenceMemberExit',
  6. event_time: '2022-06-16T13:15:07.160Z',
  7. conference_id: 'conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  8. name: 'my-conference-name',
  9. from: '+19195554321',
  10. to: '+19195551234',
  11. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  12. tag: 'custom tag'
  13. }) }
  14. 1 describe '#initialize' do
  15. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::ConferenceMemberExitCallback.new([])
  18. }.to raise_error(ArgumentError)
  19. end
  20. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  21. 1 expect {
  22. 1 Bandwidth::ConferenceMemberExitCallback.new({ invalid: true })
  23. }.to raise_error(ArgumentError)
  24. end
  25. end
  26. 1 describe '#acceptable_attributes' do
  27. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  28. 1 expect(Bandwidth::ConferenceMemberExitCallback.acceptable_attributes).to eq(Bandwidth::ConferenceMemberExitCallback.attribute_map.values)
  29. end
  30. end
  31. 1 describe '#openapi_nullable' do
  32. 1 it 'expects nullable attributes to be the set of nullable fields' do
  33. 1 expect(Bandwidth::ConferenceMemberExitCallback.openapi_nullable).to eq(Set.new([
  34. :'tag'
  35. ]))
  36. end
  37. end
  38. 1 describe '#build_from_hash' do
  39. 1 it 'validates instance of ConferenceMemberExitCallback created by the build_from_hash method' do
  40. 1 conference_member_exit_callback_from_hash = Bandwidth::ConferenceMemberExitCallback.build_from_hash({
  41. eventType: 'conferenceMemberExit',
  42. eventTime: '2022-06-16T13:15:07.160Z',
  43. conferenceId: 'conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  44. name: 'my-conference-name',
  45. from: '+19195554321',
  46. to: '+19195551234',
  47. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  48. tag: 'custom tag'
  49. })
  50. 1 expect(conference_member_exit_callback_from_hash).to be_instance_of(Bandwidth::ConferenceMemberExitCallback)
  51. 1 expect(conference_member_exit_callback_from_hash.event_type).to eq('conferenceMemberExit')
  52. 1 expect(conference_member_exit_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  53. 1 expect(conference_member_exit_callback_from_hash.conference_id).to eq('conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  54. 1 expect(conference_member_exit_callback_from_hash.name).to eq('my-conference-name')
  55. 1 expect(conference_member_exit_callback_from_hash.from).to eq('+19195554321')
  56. 1 expect(conference_member_exit_callback_from_hash.to).to eq('+19195551234')
  57. 1 expect(conference_member_exit_callback_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  58. 1 expect(conference_member_exit_callback_from_hash.tag).to eq('custom tag')
  59. end
  60. end
  61. 1 describe '#to_s' do
  62. 1 it 'returns a string representation of the object' do
  63. 1 expect(conference_member_exit_callback_values.to_s).to eq('{:eventType=>"conferenceMemberExit", :eventTime=>"2022-06-16T13:15:07.160Z", :conferenceId=>"conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :name=>"my-conference-name", :from=>"+19195554321", :to=>"+19195551234", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :tag=>"custom tag"}')
  64. end
  65. end
  66. 1 describe '#eq? #==' do
  67. 1 it 'returns true/false when comparing objects' do
  68. 1 expect(conference_member_exit_callback_default.eql?(Bandwidth::ConferenceMemberExitCallback.new)).to be true
  69. 1 expect(conference_member_exit_callback_default.eql?(conference_member_exit_callback_values)).to be false
  70. end
  71. end
  72. 1 describe '#to_body #to_hash' do
  73. 1 it 'returns a hash representation of the object' do
  74. 1 expect(conference_member_exit_callback_values.to_body).to eq({
  75. eventType: 'conferenceMemberExit',
  76. eventTime: '2022-06-16T13:15:07.160Z',
  77. conferenceId: 'conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  78. name: 'my-conference-name',
  79. from: '+19195554321',
  80. to: '+19195551234',
  81. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  82. tag: 'custom tag'
  83. })
  84. end
  85. end
  86. end

spec/unit/models/conference_member_join_callback_spec.rb

100.0% lines covered

38 relevant lines. 38 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::ConferenceMemberJoinCallback
  2. 1 describe Bandwidth::ConferenceMemberJoinCallback do
  3. 2 let(:conference_member_join_callback_default) { Bandwidth::ConferenceMemberJoinCallback.new }
  4. 4 let(:conference_member_join_callback_values) { Bandwidth::ConferenceMemberJoinCallback.new({
  5. event_type: 'conferenceMemberJoin',
  6. event_time: '2022-06-16T13:15:07.160Z',
  7. conference_id: 'conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  8. name: 'my-conference-name',
  9. from: '+19195554321',
  10. to: '+19195551234',
  11. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  12. tag: 'custom tag'
  13. }) }
  14. 1 describe '#initialize' do
  15. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::ConferenceMemberJoinCallback.new([])
  18. }.to raise_error(ArgumentError)
  19. end
  20. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  21. 1 expect {
  22. 1 Bandwidth::ConferenceMemberJoinCallback.new({ invalid: true })
  23. }.to raise_error(ArgumentError)
  24. end
  25. end
  26. 1 describe '#acceptable_attributes' do
  27. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  28. 1 expect(Bandwidth::ConferenceMemberJoinCallback.acceptable_attributes).to eq(Bandwidth::ConferenceMemberJoinCallback.attribute_map.values)
  29. end
  30. end
  31. 1 describe '#openapi_nullable' do
  32. 1 it 'expects nullable attributes to be the set of nullable fields' do
  33. 1 expect(Bandwidth::ConferenceMemberJoinCallback.openapi_nullable).to eq(Set.new([
  34. :'tag'
  35. ]))
  36. end
  37. end
  38. 1 describe '#build_from_hash' do
  39. 1 it 'validates instance of ConferenceMemberJoinCallback created by the build_from_hash method' do
  40. 1 conference_member_join_callback_from_hash = Bandwidth::ConferenceMemberJoinCallback.build_from_hash({
  41. eventType: 'conferenceMemberJoin',
  42. eventTime: '2022-06-16T13:15:07.160Z',
  43. conferenceId: 'conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  44. name: 'my-conference-name',
  45. from: '+19195554321',
  46. to: '+19195551234',
  47. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  48. tag: 'custom tag'
  49. })
  50. 1 expect(conference_member_join_callback_from_hash).to be_instance_of(Bandwidth::ConferenceMemberJoinCallback)
  51. 1 expect(conference_member_join_callback_from_hash.event_type).to eq('conferenceMemberJoin')
  52. 1 expect(conference_member_join_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  53. 1 expect(conference_member_join_callback_from_hash.conference_id).to eq('conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  54. 1 expect(conference_member_join_callback_from_hash.name).to eq('my-conference-name')
  55. 1 expect(conference_member_join_callback_from_hash.from).to eq('+19195554321')
  56. 1 expect(conference_member_join_callback_from_hash.to).to eq('+19195551234')
  57. 1 expect(conference_member_join_callback_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  58. 1 expect(conference_member_join_callback_from_hash.tag).to eq('custom tag')
  59. end
  60. end
  61. 1 describe '#to_s' do
  62. 1 it 'returns a string representation of the object' do
  63. 1 expect(conference_member_join_callback_values.to_s).to eq('{:eventType=>"conferenceMemberJoin", :eventTime=>"2022-06-16T13:15:07.160Z", :conferenceId=>"conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :name=>"my-conference-name", :from=>"+19195554321", :to=>"+19195551234", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :tag=>"custom tag"}')
  64. end
  65. end
  66. 1 describe '#eq? #==' do
  67. 1 it 'returns true/false when comparing objects' do
  68. 1 expect(conference_member_join_callback_default.eql?(Bandwidth::ConferenceMemberJoinCallback.new)).to be true
  69. 1 expect(conference_member_join_callback_default.eql?(conference_member_join_callback_values)).to be false
  70. end
  71. end
  72. 1 describe '#to_body #to_hash' do
  73. 1 it 'returns a hash representation of the object' do
  74. 1 expect(conference_member_join_callback_values.to_body).to eq({
  75. eventType: 'conferenceMemberJoin',
  76. eventTime: '2022-06-16T13:15:07.160Z',
  77. conferenceId: 'conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  78. name: 'my-conference-name',
  79. from: '+19195554321',
  80. to: '+19195551234',
  81. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  82. tag: 'custom tag'
  83. })
  84. end
  85. end
  86. end

spec/unit/models/conference_member_spec.rb

100.0% lines covered

36 relevant lines. 36 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::ConferenceMember
  2. 1 describe Bandwidth::ConferenceMember do
  3. 2 let(:conference_member_default) { Bandwidth::ConferenceMember.new }
  4. 4 let(:conference_member_values) { Bandwidth::ConferenceMember.new({
  5. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  6. conference_id: 'conf-fe23a767-a75a5b77-23e8-4b5b-a973-1eb967d7d75c',
  7. member_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-1/members/c-1',
  8. mute: false,
  9. hold: false,
  10. call_ids_to_coach: ['c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d86']
  11. }) }
  12. 1 describe '#initialize' do
  13. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  14. 1 expect {
  15. 1 Bandwidth::ConferenceMember.new([])
  16. }.to raise_error(ArgumentError)
  17. end
  18. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  19. 1 expect {
  20. 1 Bandwidth::ConferenceMember.new({ invalid: true })
  21. }.to raise_error(ArgumentError)
  22. end
  23. end
  24. 1 describe '#acceptable_attributes' do
  25. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  26. 1 expect(Bandwidth::ConferenceMember.acceptable_attributes).to eq(Bandwidth::ConferenceMember.attribute_map.values)
  27. end
  28. end
  29. 1 describe '#openapi_nullable' do
  30. 1 it 'expects nullable attributes to be the set of nullable fields' do
  31. 1 expect(Bandwidth::ConferenceMember.openapi_nullable).to eq(Set.new([:'call_ids_to_coach']))
  32. end
  33. end
  34. 1 describe '#build_from_hash' do
  35. 1 it 'validates instance of ConferenceMember created by the build_from_hash method' do
  36. 1 conference_member_from_hash = Bandwidth::ConferenceMember.build_from_hash({
  37. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  38. conferenceId: 'conf-fe23a767-a75a5b77-23e8-4b5b-a973-1eb967d7d75c',
  39. memberUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-1/members/c-1',
  40. mute: false,
  41. hold: false,
  42. callIdsToCoach: ['c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d86']
  43. })
  44. 1 expect(conference_member_from_hash).to be_instance_of(Bandwidth::ConferenceMember)
  45. 1 expect(conference_member_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  46. 1 expect(conference_member_from_hash.conference_id).to eq('conf-fe23a767-a75a5b77-23e8-4b5b-a973-1eb967d7d75c')
  47. 1 expect(conference_member_from_hash.member_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-1/members/c-1')
  48. 1 expect(conference_member_from_hash.mute).to eq(false)
  49. 1 expect(conference_member_from_hash.hold).to eq(false)
  50. 1 expect(conference_member_from_hash.call_ids_to_coach).to eq(['c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d86'])
  51. end
  52. end
  53. 1 describe '#to_s' do
  54. 1 it 'returns a string representation of the object' do
  55. 1 expect(conference_member_values.to_s).to eq('{:callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :conferenceId=>"conf-fe23a767-a75a5b77-23e8-4b5b-a973-1eb967d7d75c", :memberUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-1/members/c-1", :mute=>false, :hold=>false, :callIdsToCoach=>["c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d86"]}')
  56. end
  57. end
  58. 1 describe '#eq? #==' do
  59. 1 it 'returns true/false when comparing objects' do
  60. 1 expect(conference_member_default.eql?(Bandwidth::ConferenceMember.new)).to be true
  61. 1 expect(conference_member_default.eql?(conference_member_values)).to be false
  62. end
  63. end
  64. 1 describe '#to_body #to_hash' do
  65. 1 it 'returns a hash representation of the object' do
  66. 1 expect(conference_member_values.to_body).to eq({
  67. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  68. conferenceId: 'conf-fe23a767-a75a5b77-23e8-4b5b-a973-1eb967d7d75c',
  69. memberUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-1/members/c-1',
  70. mute: false,
  71. hold: false,
  72. callIdsToCoach: ['c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d86']
  73. })
  74. end
  75. end
  76. end

spec/unit/models/conference_recording_available_callback_spec.rb

100.0% lines covered

44 relevant lines. 44 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::ConferenceRecordingAvailableCallback
  2. 1 describe Bandwidth::ConferenceRecordingAvailableCallback do
  3. 2 let(:conference_recording_available_callback_default) { Bandwidth::ConferenceRecordingAvailableCallback.new }
  4. 4 let(:conference_recording_available_callback_values) { Bandwidth::ConferenceRecordingAvailableCallback.new({
  5. event_type: 'conferenceRecordingAvailable',
  6. event_time: '2022-06-16T13:15:07.160Z',
  7. conference_id: 'conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  8. name: 'my-conference-name',
  9. account_id: '9900000',
  10. recording_id: 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  11. channels: 1,
  12. start_time: '2022-06-16T13:15:07.160Z',
  13. end_time: '2022-06-16T13:17:07.160Z',
  14. duration: 'PT2M',
  15. file_format: Bandwidth::FileFormatEnum::WAV,
  16. media_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/media',
  17. tag: 'custom tag',
  18. status: 'complete'
  19. }) }
  20. 1 describe '#initialize' do
  21. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  22. 1 expect {
  23. 1 Bandwidth::ConferenceRecordingAvailableCallback.new([])
  24. }.to raise_error(ArgumentError)
  25. end
  26. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  27. 1 expect {
  28. 1 Bandwidth::ConferenceRecordingAvailableCallback.new({ invalid: true })
  29. }.to raise_error(ArgumentError)
  30. end
  31. end
  32. 1 describe '#acceptable_attributes' do
  33. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  34. 1 expect(Bandwidth::ConferenceRecordingAvailableCallback.acceptable_attributes).to eq(Bandwidth::ConferenceRecordingAvailableCallback.attribute_map.values)
  35. end
  36. end
  37. 1 describe '#openapi_nullable' do
  38. 1 it 'expects nullable attributes to be the set of nullable fields' do
  39. 1 expect(Bandwidth::ConferenceRecordingAvailableCallback.openapi_nullable).to eq(Set.new([
  40. :'media_url',
  41. :'tag'
  42. ]))
  43. end
  44. end
  45. 1 describe '#build_from_hash' do
  46. 1 it 'validates instance of ConferenceRecordingAvailableCallback created by the build_from_hash method' do
  47. 1 conference_recording_available_callback_from_hash = Bandwidth::ConferenceRecordingAvailableCallback.build_from_hash({
  48. eventType: 'conferenceRecordingAvailable',
  49. eventTime: '2022-06-16T13:15:07.160Z',
  50. conferenceId: 'conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  51. name: 'my-conference-name',
  52. accountId: '9900000',
  53. recordingId: 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  54. channels: 1,
  55. startTime: '2022-06-16T13:15:07.160Z',
  56. endTime: '2022-06-16T13:17:07.160Z',
  57. duration: 'PT2M',
  58. fileFormat: Bandwidth::FileFormatEnum::WAV,
  59. mediaUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/media',
  60. tag: 'custom tag',
  61. status: 'complete'
  62. })
  63. 1 expect(conference_recording_available_callback_from_hash).to be_instance_of(Bandwidth::ConferenceRecordingAvailableCallback)
  64. 1 expect(conference_recording_available_callback_from_hash.event_type).to eq('conferenceRecordingAvailable')
  65. 1 expect(conference_recording_available_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  66. 1 expect(conference_recording_available_callback_from_hash.conference_id).to eq('conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  67. 1 expect(conference_recording_available_callback_from_hash.name).to eq('my-conference-name')
  68. 1 expect(conference_recording_available_callback_from_hash.account_id).to eq('9900000')
  69. 1 expect(conference_recording_available_callback_from_hash.recording_id).to eq('r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  70. 1 expect(conference_recording_available_callback_from_hash.channels).to eq(1)
  71. 1 expect(conference_recording_available_callback_from_hash.start_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  72. 1 expect(conference_recording_available_callback_from_hash.end_time).to eq(Time.parse('2022-06-16T13:17:07.160Z'))
  73. 1 expect(conference_recording_available_callback_from_hash.duration).to eq('PT2M')
  74. 1 expect(conference_recording_available_callback_from_hash.file_format).to eq(Bandwidth::FileFormatEnum::WAV)
  75. 1 expect(conference_recording_available_callback_from_hash.media_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/media')
  76. 1 expect(conference_recording_available_callback_from_hash.tag).to eq('custom tag')
  77. 1 expect(conference_recording_available_callback_from_hash.status).to eq('complete')
  78. end
  79. end
  80. 1 describe '#to_s' do
  81. 1 it 'returns a string representation of the object' do
  82. 1 expect(conference_recording_available_callback_values.to_s).to eq('{:eventType=>"conferenceRecordingAvailable", :eventTime=>"2022-06-16T13:15:07.160Z", :conferenceId=>"conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :name=>"my-conference-name", :accountId=>"9900000", :recordingId=>"r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :channels=>1, :startTime=>"2022-06-16T13:15:07.160Z", :endTime=>"2022-06-16T13:17:07.160Z", :duration=>"PT2M", :fileFormat=>"wav", :mediaUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/media", :tag=>"custom tag", :status=>"complete"}')
  83. end
  84. end
  85. 1 describe '#eq? #==' do
  86. 1 it 'returns true/false when comparing objects' do
  87. 1 expect(conference_recording_available_callback_default.eql?(Bandwidth::ConferenceRecordingAvailableCallback.new)).to be true
  88. 1 expect(conference_recording_available_callback_default.eql?(conference_recording_available_callback_values)).to be false
  89. end
  90. end
  91. 1 describe '#to_body #to_hash' do
  92. 1 it 'returns a hash representation of the object' do
  93. 1 expect(conference_recording_available_callback_values.to_body).to eq({
  94. eventType: 'conferenceRecordingAvailable',
  95. eventTime: '2022-06-16T13:15:07.160Z',
  96. conferenceId: 'conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  97. name: 'my-conference-name',
  98. accountId: '9900000',
  99. recordingId: 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  100. channels: 1,
  101. startTime: '2022-06-16T13:15:07.160Z',
  102. endTime: '2022-06-16T13:17:07.160Z',
  103. duration: 'PT2M',
  104. fileFormat: Bandwidth::FileFormatEnum::WAV,
  105. mediaUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/media',
  106. tag: 'custom tag',
  107. status: 'complete'
  108. })
  109. end
  110. end
  111. end

spec/unit/models/conference_recording_metadata_spec.rb

100.0% lines covered

42 relevant lines. 42 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::ConferenceRecordingMetadata
  2. 1 describe Bandwidth::ConferenceRecordingMetadata do
  3. 2 let(:conference_recording_metadata_default) { Bandwidth::ConferenceRecordingMetadata.new }
  4. 4 let(:conference_recording_metadata_values) { Bandwidth::ConferenceRecordingMetadata.new({
  5. account_id: '9900000',
  6. conference_id: 'conf-fe23a767-a75a5b77-23e8-4b5b-a973-1eb967d7d75c',
  7. name: 'weekly-stand-up',
  8. recording_id: 'r-fbe05094-9fd2b71d-a4e6-4f43-8c3e-5b04b1d8a4b4',
  9. duration: 'PT13.67S',
  10. channels: 1,
  11. start_time: '2022-06-16T13:15:07.160Z',
  12. end_time: '2022-06-16T13:15:20.830Z',
  13. file_format: Bandwidth::FileFormatEnum::WAV,
  14. status: 'complete',
  15. media_url: 'https://example.com/recording.wav',
  16. recording_name: 'sample-recording'
  17. }) }
  18. 1 describe '#initialize' do
  19. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  20. 1 expect {
  21. 1 Bandwidth::ConferenceRecordingMetadata.new([])
  22. }.to raise_error(ArgumentError)
  23. end
  24. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  25. 1 expect {
  26. 1 Bandwidth::ConferenceRecordingMetadata.new({ invalid: true })
  27. }.to raise_error(ArgumentError)
  28. end
  29. end
  30. 1 describe '#acceptable_attributes' do
  31. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  32. 1 expect(Bandwidth::ConferenceRecordingMetadata.acceptable_attributes).to eq(Bandwidth::ConferenceRecordingMetadata.attribute_map.values)
  33. end
  34. end
  35. 1 describe '#openapi_nullable' do
  36. 1 it 'expects nullable attributes to be the set of nullable fields' do
  37. 1 expect(Bandwidth::ConferenceRecordingMetadata.openapi_nullable).to eq(Set.new([:'media_url']))
  38. end
  39. end
  40. 1 describe '#build_from_hash' do
  41. 1 it 'validates instance of ConferenceRecordingMetadata created by the build_from_hash method' do
  42. 1 conference_recording_metadata_from_hash = Bandwidth::ConferenceRecordingMetadata.build_from_hash({
  43. accountId: '9900000',
  44. conferenceId: 'conf-fe23a767-a75a5b77-23e8-4b5b-a973-1eb967d7d75c',
  45. name: 'weekly-stand-up',
  46. recordingId: 'r-fbe05094-9fd2b71d-a4e6-4f43-8c3e-5b04b1d8a4b4',
  47. duration: 'PT13.67S',
  48. channels: 1,
  49. startTime: '2022-06-16T13:15:07.160Z',
  50. endTime: '2022-06-16T13:15:20.830Z',
  51. fileFormat: 'wav',
  52. status: 'complete',
  53. mediaUrl: 'https://example.com/recording.wav',
  54. recordingName: 'sample-recording'
  55. })
  56. 1 expect(conference_recording_metadata_from_hash).to be_instance_of(Bandwidth::ConferenceRecordingMetadata)
  57. 1 expect(conference_recording_metadata_from_hash.account_id).to eq('9900000')
  58. 1 expect(conference_recording_metadata_from_hash.conference_id).to eq('conf-fe23a767-a75a5b77-23e8-4b5b-a973-1eb967d7d75c')
  59. 1 expect(conference_recording_metadata_from_hash.name).to eq('weekly-stand-up')
  60. 1 expect(conference_recording_metadata_from_hash.recording_id).to eq('r-fbe05094-9fd2b71d-a4e6-4f43-8c3e-5b04b1d8a4b4')
  61. 1 expect(conference_recording_metadata_from_hash.duration).to eq('PT13.67S')
  62. 1 expect(conference_recording_metadata_from_hash.channels).to eq(1)
  63. 1 expect(conference_recording_metadata_from_hash.start_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  64. 1 expect(conference_recording_metadata_from_hash.end_time).to eq(Time.parse('2022-06-16T13:15:20.830Z'))
  65. 1 expect(conference_recording_metadata_from_hash.file_format).to eq(Bandwidth::FileFormatEnum::WAV)
  66. 1 expect(conference_recording_metadata_from_hash.status).to eq('complete')
  67. 1 expect(conference_recording_metadata_from_hash.media_url).to eq('https://example.com/recording.wav')
  68. 1 expect(conference_recording_metadata_from_hash.recording_name).to eq('sample-recording')
  69. end
  70. end
  71. 1 describe '#to_s' do
  72. 1 it 'returns a string representation of the object' do
  73. 1 expect(conference_recording_metadata_values.to_s).to eq('{:accountId=>"9900000", :conferenceId=>"conf-fe23a767-a75a5b77-23e8-4b5b-a973-1eb967d7d75c", :name=>"weekly-stand-up", :recordingId=>"r-fbe05094-9fd2b71d-a4e6-4f43-8c3e-5b04b1d8a4b4", :duration=>"PT13.67S", :channels=>1, :startTime=>"2022-06-16T13:15:07.160Z", :endTime=>"2022-06-16T13:15:20.830Z", :fileFormat=>"wav", :status=>"complete", :mediaUrl=>"https://example.com/recording.wav", :recordingName=>"sample-recording"}')
  74. end
  75. end
  76. 1 describe '#eq? #==' do
  77. 1 it 'returns true/false when comparing objects' do
  78. 1 expect(conference_recording_metadata_default.eql?(Bandwidth::ConferenceRecordingMetadata.new)).to be true
  79. 1 expect(conference_recording_metadata_default.eql?(conference_recording_metadata_values)).to be false
  80. end
  81. end
  82. 1 describe '#to_body #to_hash' do
  83. 1 it 'returns a hash representation of the object' do
  84. 1 expect(conference_recording_metadata_values.to_body).to eq({
  85. accountId: '9900000',
  86. conferenceId: 'conf-fe23a767-a75a5b77-23e8-4b5b-a973-1eb967d7d75c',
  87. name: 'weekly-stand-up',
  88. recordingId: 'r-fbe05094-9fd2b71d-a4e6-4f43-8c3e-5b04b1d8a4b4',
  89. duration: 'PT13.67S',
  90. channels: 1,
  91. startTime: '2022-06-16T13:15:07.160Z',
  92. endTime: '2022-06-16T13:15:20.830Z',
  93. fileFormat: Bandwidth::FileFormatEnum::WAV,
  94. status: 'complete',
  95. mediaUrl: 'https://example.com/recording.wav',
  96. recordingName: 'sample-recording'
  97. })
  98. end
  99. end
  100. end

spec/unit/models/conference_redirect_callback_spec.rb

100.0% lines covered

35 relevant lines. 35 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::ConferenceRedirectCallback
  2. 1 describe Bandwidth::ConferenceRedirectCallback do
  3. 2 let(:conference_redirect_callback_default) { Bandwidth::ConferenceRedirectCallback.new }
  4. 4 let(:conference_redirect_callback_values) { Bandwidth::ConferenceRedirectCallback.new({
  5. event_type: 'conferenceRedirect',
  6. event_time: '2022-06-16T13:15:07.160Z',
  7. conference_id: 'conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  8. name: 'my-conference-name',
  9. tag: 'custom tag'
  10. }) }
  11. 1 describe '#initialize' do
  12. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  13. 1 expect {
  14. 1 Bandwidth::ConferenceRedirectCallback.new([])
  15. }.to raise_error(ArgumentError)
  16. end
  17. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  18. 1 expect {
  19. 1 Bandwidth::ConferenceRedirectCallback.new({ invalid: true })
  20. }.to raise_error(ArgumentError)
  21. end
  22. end
  23. 1 describe '#acceptable_attributes' do
  24. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  25. 1 expect(Bandwidth::ConferenceRedirectCallback.acceptable_attributes).to eq(Bandwidth::ConferenceRedirectCallback.attribute_map.values)
  26. end
  27. end
  28. 1 describe '#openapi_nullable' do
  29. 1 it 'expects nullable attributes to be the set of nullable fields' do
  30. 1 expect(Bandwidth::ConferenceRedirectCallback.openapi_nullable).to eq(Set.new([
  31. :'tag'
  32. ]))
  33. end
  34. end
  35. 1 describe '#build_from_hash' do
  36. 1 it 'validates instance of ConferenceRedirectCallback created by the build_from_hash method' do
  37. 1 conference_redirect_callback_from_hash = Bandwidth::ConferenceRedirectCallback.build_from_hash({
  38. eventType: 'conferenceRedirect',
  39. eventTime: '2022-06-16T13:15:07.160Z',
  40. conferenceId: 'conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  41. name: 'my-conference-name',
  42. tag: 'custom tag'
  43. })
  44. 1 expect(conference_redirect_callback_from_hash).to be_instance_of(Bandwidth::ConferenceRedirectCallback)
  45. 1 expect(conference_redirect_callback_from_hash.event_type).to eq('conferenceRedirect')
  46. 1 expect(conference_redirect_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  47. 1 expect(conference_redirect_callback_from_hash.conference_id).to eq('conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  48. 1 expect(conference_redirect_callback_from_hash.name).to eq('my-conference-name')
  49. 1 expect(conference_redirect_callback_from_hash.tag).to eq('custom tag')
  50. end
  51. end
  52. 1 describe '#to_s' do
  53. 1 it 'returns a string representation of the object' do
  54. 1 expect(conference_redirect_callback_values.to_s).to eq('{:eventType=>"conferenceRedirect", :eventTime=>"2022-06-16T13:15:07.160Z", :conferenceId=>"conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :name=>"my-conference-name", :tag=>"custom tag"}')
  55. end
  56. end
  57. 1 describe '#eq? #==' do
  58. 1 it 'returns true/false when comparing objects' do
  59. 1 expect(conference_redirect_callback_default.eql?(Bandwidth::ConferenceRedirectCallback.new)).to be true
  60. 1 expect(conference_redirect_callback_default.eql?(conference_redirect_callback_values)).to be false
  61. end
  62. end
  63. 1 describe '#to_body #to_hash' do
  64. 1 it 'returns a hash representation of the object' do
  65. 1 expect(conference_redirect_callback_values.to_body).to eq({
  66. eventType: 'conferenceRedirect',
  67. eventTime: '2022-06-16T13:15:07.160Z',
  68. conferenceId: 'conf-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  69. name: 'my-conference-name',
  70. tag: 'custom tag'
  71. })
  72. end
  73. end
  74. end

spec/unit/models/conference_spec.rb

100.0% lines covered

38 relevant lines. 38 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Conference
  2. 1 describe Bandwidth::Conference do
  3. 2 let(:conference_default) { Bandwidth::Conference.new }
  4. 4 let(:conference_values) { Bandwidth::Conference.new({
  5. id: 'conf-fe23a767-a75a5b77-23e8-4b5b-a973-1eb967d7d75c',
  6. name: 'weekly-stand-up',
  7. created_time: '2022-06-16T13:15:07.160Z',
  8. completed_time: '2022-06-16T13:45:07.160Z',
  9. conference_event_url: 'https://example.com/conference-event',
  10. conference_event_method: Bandwidth::CallbackMethodEnum::POST,
  11. tag: 'custom tag',
  12. active_members: [Bandwidth::ConferenceMember.new({ call_id: 'c-1', conference_id: 'conf-1' })]
  13. }) }
  14. 1 describe '#initialize' do
  15. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::Conference.new([])
  18. }.to raise_error(ArgumentError)
  19. end
  20. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  21. 1 expect {
  22. 1 Bandwidth::Conference.new({ invalid: true })
  23. }.to raise_error(ArgumentError)
  24. end
  25. end
  26. 1 describe '#acceptable_attributes' do
  27. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  28. 1 expect(Bandwidth::Conference.acceptable_attributes).to eq(Bandwidth::Conference.attribute_map.values)
  29. end
  30. end
  31. 1 describe '#openapi_nullable' do
  32. 1 it 'expects nullable attributes to be the set of nullable fields' do
  33. 1 expect(Bandwidth::Conference.openapi_nullable).to eq(Set.new([
  34. :'completed_time',
  35. :'conference_event_url',
  36. :'conference_event_method',
  37. :'tag',
  38. :'active_members'
  39. ]))
  40. end
  41. end
  42. 1 describe '#build_from_hash' do
  43. 1 it 'validates instance of Conference created by the build_from_hash method' do
  44. 1 conference_from_hash = Bandwidth::Conference.build_from_hash({
  45. id: 'conf-fe23a767-a75a5b77-23e8-4b5b-a973-1eb967d7d75c',
  46. name: 'weekly-stand-up',
  47. createdTime: '2022-06-16T13:15:07.160Z',
  48. completedTime: '2022-06-16T13:45:07.160Z',
  49. conferenceEventUrl: 'https://example.com/conference-event',
  50. conferenceEventMethod: 'POST',
  51. tag: 'custom tag',
  52. activeMembers: [{ callId: 'c-1', conferenceId: 'conf-1' }]
  53. })
  54. 1 expect(conference_from_hash).to be_instance_of(Bandwidth::Conference)
  55. 1 expect(conference_from_hash.id).to eq('conf-fe23a767-a75a5b77-23e8-4b5b-a973-1eb967d7d75c')
  56. 1 expect(conference_from_hash.name).to eq('weekly-stand-up')
  57. 1 expect(conference_from_hash.created_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  58. 1 expect(conference_from_hash.completed_time).to eq(Time.parse('2022-06-16T13:45:07.160Z'))
  59. 1 expect(conference_from_hash.conference_event_url).to eq('https://example.com/conference-event')
  60. 1 expect(conference_from_hash.conference_event_method).to eq(Bandwidth::CallbackMethodEnum::POST)
  61. 1 expect(conference_from_hash.tag).to eq('custom tag')
  62. 1 expect(conference_from_hash.active_members.first).to be_instance_of(Bandwidth::ConferenceMember)
  63. end
  64. end
  65. 1 describe '#to_s' do
  66. 1 it 'returns a string representation of the object' do
  67. 1 expect(conference_values.to_s).to eq('{:id=>"conf-fe23a767-a75a5b77-23e8-4b5b-a973-1eb967d7d75c", :name=>"weekly-stand-up", :createdTime=>"2022-06-16T13:15:07.160Z", :completedTime=>"2022-06-16T13:45:07.160Z", :conferenceEventUrl=>"https://example.com/conference-event", :conferenceEventMethod=>"POST", :tag=>"custom tag", :activeMembers=>[{:callId=>"c-1", :conferenceId=>"conf-1"}]}')
  68. end
  69. end
  70. 1 describe '#eq? #==' do
  71. 1 it 'returns true/false when comparing objects' do
  72. 1 expect(conference_default.eql?(Bandwidth::Conference.new)).to be true
  73. 1 expect(conference_default.eql?(conference_values)).to be false
  74. end
  75. end
  76. 1 describe '#to_body #to_hash' do
  77. 1 it 'returns a hash representation of the object' do
  78. 1 expect(conference_values.to_body).to eq({
  79. id: 'conf-fe23a767-a75a5b77-23e8-4b5b-a973-1eb967d7d75c',
  80. name: 'weekly-stand-up',
  81. createdTime: '2022-06-16T13:15:07.160Z',
  82. completedTime: '2022-06-16T13:45:07.160Z',
  83. conferenceEventUrl: 'https://example.com/conference-event',
  84. conferenceEventMethod: Bandwidth::CallbackMethodEnum::POST,
  85. tag: 'custom tag',
  86. activeMembers: [{ callId: 'c-1', conferenceId: 'conf-1' }]
  87. })
  88. end
  89. end
  90. end

spec/unit/models/conference_state_enum_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::ConferenceStateEnum
  2. 1 describe Bandwidth::ConferenceStateEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines ACTIVE' do
  5. 1 expect(Bandwidth::ConferenceStateEnum::ACTIVE).to eq('active')
  6. end
  7. 1 it 'defines COMPLETED' do
  8. 1 expect(Bandwidth::ConferenceStateEnum::COMPLETED).to eq('completed')
  9. end
  10. end
  11. 1 describe '.all_vars' do
  12. 1 it 'returns every valid enum value' do
  13. 1 expect(Bandwidth::ConferenceStateEnum.all_vars).to eq([
  14. 'active',
  15. 'completed'
  16. ])
  17. end
  18. end
  19. 1 describe '.build_from_hash' do
  20. 1 it 'returns the value when it matches a valid enum value' do
  21. 1 expect(Bandwidth::ConferenceStateEnum.build_from_hash('active')).to eq('active')
  22. 1 expect(Bandwidth::ConferenceStateEnum.build_from_hash('completed')).to eq('completed')
  23. end
  24. 1 it 'raises an error for an invalid enum value' do
  25. 1 expect {
  26. 1 Bandwidth::ConferenceStateEnum.build_from_hash('invalid')
  27. }.to raise_error(RuntimeError)
  28. end
  29. end
  30. end

spec/unit/models/contact_spec.rb

100.0% lines covered

64 relevant lines. 64 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Contact
  2. 1 describe Bandwidth::Contact do
  3. 2 let(:contact_default) { Bandwidth::Contact.new({
  4. first_name: 'Baseline',
  5. last_name: 'User',
  6. email: 'baseline@example.com',
  7. phone_number: '+19195550100'
  8. }) }
  9. 4 let(:contact_values) { Bandwidth::Contact.new({
  10. first_name: 'John',
  11. last_name: 'Doe',
  12. email: 'john.doe@example.com',
  13. phone_number: '+19195551234'
  14. }) }
  15. 1 describe '#initialize' do
  16. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  17. 1 expect {
  18. 1 Bandwidth::Contact.new([])
  19. }.to raise_error(ArgumentError)
  20. end
  21. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  22. 1 expect {
  23. 1 Bandwidth::Contact.new({ invalid: true })
  24. }.to raise_error(ArgumentError)
  25. end
  26. end
  27. 1 describe '#acceptable_attributes' do
  28. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  29. 1 expect(Bandwidth::Contact.acceptable_attributes).to eq(Bandwidth::Contact.attribute_map.values)
  30. end
  31. end
  32. 1 describe '#openapi_nullable' do
  33. 1 it 'expects nullable attributes to be an empty set' do
  34. 1 expect(Bandwidth::Contact.openapi_nullable).to eq(Set.new([]))
  35. end
  36. end
  37. 1 describe '#build_from_hash' do
  38. 1 it 'validates instance of Contact created by the build_from_hash method' do
  39. 1 contact_from_hash = Bandwidth::Contact.build_from_hash({
  40. firstName: 'John',
  41. lastName: 'Doe',
  42. email: 'john.doe@example.com',
  43. phoneNumber: '+19195551234'
  44. })
  45. 1 expect(contact_from_hash).to be_instance_of(Bandwidth::Contact)
  46. 1 expect(contact_from_hash.first_name).to eq('John')
  47. 1 expect(contact_from_hash.last_name).to eq('Doe')
  48. 1 expect(contact_from_hash.email).to eq('john.doe@example.com')
  49. 1 expect(contact_from_hash.phone_number).to eq('+19195551234')
  50. end
  51. end
  52. 1 describe '#to_s' do
  53. 1 it 'returns a string representation of the object' do
  54. 1 expect(contact_values.to_s).to eq('{:firstName=>"John", :lastName=>"Doe", :email=>"john.doe@example.com", :phoneNumber=>"+19195551234"}')
  55. end
  56. end
  57. 1 describe '#eq? #==' do
  58. 1 it 'returns true/false when comparing objects' do
  59. 1 contact_equal = Bandwidth::Contact.new({
  60. first_name: 'Baseline',
  61. last_name: 'User',
  62. email: 'baseline@example.com',
  63. phone_number: '+19195550100'
  64. })
  65. 1 expect(contact_default.eql?(contact_equal)).to be true
  66. 1 expect(contact_default.eql?(contact_values)).to be false
  67. end
  68. end
  69. 1 describe '#to_body #to_hash' do
  70. 1 it 'returns a hash representation of the object' do
  71. 1 expect(contact_values.to_body).to eq({
  72. firstName: 'John',
  73. lastName: 'Doe',
  74. email: 'john.doe@example.com',
  75. phoneNumber: '+19195551234'
  76. })
  77. end
  78. end
  79. 1 describe 'custom attribute writers' do
  80. 1 it '#first_name=' do
  81. 1 expect {
  82. 1 Bandwidth::Contact.new({ first_name: nil, last_name: 'Doe', email: 'a@b.com', phone_number: '+19195551234' })
  83. }.to raise_error(ArgumentError, 'first_name cannot be nil')
  84. 1 expect {
  85. 1 Bandwidth::Contact.new({ first_name: 'a' * 501, last_name: 'Doe', email: 'a@b.com', phone_number: '+19195551234' })
  86. }.to raise_error(ArgumentError, 'invalid value for "first_name", the character length must be smaller than or equal to 500.')
  87. 1 expect {
  88. 1 Bandwidth::Contact.new({ first_name: '', last_name: 'Doe', email: 'a@b.com', phone_number: '+19195551234' })
  89. }.to raise_error(ArgumentError, 'invalid value for "first_name", the character length must be greater than or equal to 1.')
  90. end
  91. 1 it '#last_name=' do
  92. 1 expect {
  93. 1 Bandwidth::Contact.new({ first_name: 'John', last_name: nil, email: 'a@b.com', phone_number: '+19195551234' })
  94. }.to raise_error(ArgumentError, 'last_name cannot be nil')
  95. 1 expect {
  96. 1 Bandwidth::Contact.new({ first_name: 'John', last_name: 'a' * 501, email: 'a@b.com', phone_number: '+19195551234' })
  97. }.to raise_error(ArgumentError, 'invalid value for "last_name", the character length must be smaller than or equal to 500.')
  98. 1 expect {
  99. 1 Bandwidth::Contact.new({ first_name: 'John', last_name: '', email: 'a@b.com', phone_number: '+19195551234' })
  100. }.to raise_error(ArgumentError, 'invalid value for "last_name", the character length must be greater than or equal to 1.')
  101. end
  102. 1 it '#email=' do
  103. 1 expect {
  104. 1 Bandwidth::Contact.new({ first_name: 'John', last_name: 'Doe', email: nil, phone_number: '+19195551234' })
  105. }.to raise_error(ArgumentError, 'email cannot be nil')
  106. 1 expect {
  107. 1 Bandwidth::Contact.new({ first_name: 'John', last_name: 'Doe', email: ('a' * 495) + '@b.com', phone_number: '+19195551234' })
  108. }.to raise_error(ArgumentError, 'invalid value for "email", the character length must be smaller than or equal to 500.')
  109. 1 expect {
  110. 1 Bandwidth::Contact.new({ first_name: 'John', last_name: 'Doe', email: 'not-an-email', phone_number: '+19195551234' })
  111. }.to raise_error(ArgumentError, /invalid value for "email", must conform to the pattern/)
  112. end
  113. 1 it '#phone_number=' do
  114. 1 expect {
  115. 1 Bandwidth::Contact.new({ first_name: 'John', last_name: 'Doe', email: 'a@b.com', phone_number: nil })
  116. }.to raise_error(ArgumentError, 'phone_number cannot be nil')
  117. 1 expect {
  118. 1 Bandwidth::Contact.new({ first_name: 'John', last_name: 'Doe', email: 'a@b.com', phone_number: 'a' * 501 })
  119. }.to raise_error(ArgumentError, 'invalid value for "phone_number", the character length must be smaller than or equal to 500.')
  120. 1 expect {
  121. 1 Bandwidth::Contact.new({ first_name: 'John', last_name: 'Doe', email: 'a@b.com', phone_number: '' })
  122. }.to raise_error(ArgumentError, 'invalid value for "phone_number", the character length must be greater than or equal to 1.')
  123. end
  124. end
  125. end

spec/unit/models/create_async_bulk_lookup_response_data_spec.rb

100.0% lines covered

32 relevant lines. 32 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CreateAsyncBulkLookupResponseData
  2. 1 describe Bandwidth::CreateAsyncBulkLookupResponseData do
  3. 2 let(:create_async_bulk_lookup_response_data_default) { Bandwidth::CreateAsyncBulkLookupResponseData.new }
  4. 4 let(:create_async_bulk_lookup_response_data_values) { Bandwidth::CreateAsyncBulkLookupResponseData.new({
  5. request_id: '00b97c1b-d8b4-4a32-ad14-7d09ce04acb6',
  6. status: 'IN_PROGRESS'
  7. }) }
  8. 1 describe '#initialize' do
  9. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  10. 1 expect {
  11. 1 Bandwidth::CreateAsyncBulkLookupResponseData.new([])
  12. }.to raise_error(ArgumentError)
  13. end
  14. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  15. 1 expect {
  16. 1 Bandwidth::CreateAsyncBulkLookupResponseData.new({ invalid: true })
  17. }.to raise_error(ArgumentError)
  18. end
  19. end
  20. 1 describe '#acceptable_attributes' do
  21. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  22. 1 expect(Bandwidth::CreateAsyncBulkLookupResponseData.acceptable_attributes).to eq(Bandwidth::CreateAsyncBulkLookupResponseData.attribute_map.values)
  23. end
  24. end
  25. 1 describe '#openapi_nullable' do
  26. 1 it 'expects nullable attributes to be an empty set' do
  27. 1 expect(Bandwidth::CreateAsyncBulkLookupResponseData.openapi_nullable).to eq(Set.new([]))
  28. end
  29. end
  30. 1 describe '#build_from_hash' do
  31. 1 it 'validates instance of CreateAsyncBulkLookupResponseData created by the build_from_hash method' do
  32. 1 create_async_bulk_lookup_response_data_from_hash = Bandwidth::CreateAsyncBulkLookupResponseData.build_from_hash({
  33. requestId: '00b97c1b-d8b4-4a32-ad14-7d09ce04acb6',
  34. status: 'IN_PROGRESS'
  35. })
  36. 1 expect(create_async_bulk_lookup_response_data_from_hash).to be_instance_of(Bandwidth::CreateAsyncBulkLookupResponseData)
  37. 1 expect(create_async_bulk_lookup_response_data_from_hash.request_id).to eq('00b97c1b-d8b4-4a32-ad14-7d09ce04acb6')
  38. 1 expect(create_async_bulk_lookup_response_data_from_hash.status).to eq('IN_PROGRESS')
  39. end
  40. end
  41. 1 describe '#to_s' do
  42. 1 it 'returns a string representation of the object' do
  43. 1 expect(create_async_bulk_lookup_response_data_values.to_s).to eq('{:requestId=>"00b97c1b-d8b4-4a32-ad14-7d09ce04acb6", :status=>"IN_PROGRESS"}')
  44. end
  45. end
  46. 1 describe '#eq? #==' do
  47. 1 it 'returns true/false when comparing objects' do
  48. 1 expect(create_async_bulk_lookup_response_data_default.eql?(Bandwidth::CreateAsyncBulkLookupResponseData.new)).to be true
  49. 1 expect(create_async_bulk_lookup_response_data_default.eql?(create_async_bulk_lookup_response_data_values)).to be false
  50. end
  51. end
  52. 1 describe '#to_body #to_hash' do
  53. 1 it 'returns a hash representation of the object' do
  54. 1 expect(create_async_bulk_lookup_response_data_values.to_body).to eq({
  55. requestId: '00b97c1b-d8b4-4a32-ad14-7d09ce04acb6',
  56. status: 'IN_PROGRESS'
  57. })
  58. end
  59. end
  60. end

spec/unit/models/create_async_bulk_lookup_response_spec.rb

100.0% lines covered

33 relevant lines. 33 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CreateAsyncBulkLookupResponse
  2. 1 describe Bandwidth::CreateAsyncBulkLookupResponse do
  3. 2 let(:create_async_bulk_lookup_response_default) { Bandwidth::CreateAsyncBulkLookupResponse.new }
  4. 4 let(:create_async_bulk_lookup_response_values) { Bandwidth::CreateAsyncBulkLookupResponse.new({
  5. links: [Bandwidth::LinkSchema.new({ href: 'https://example.com', rel: 'self', method: 'GET' })],
  6. data: Bandwidth::CreateAsyncBulkLookupResponseData.new({ request_id: '00b97c1b-d8b4-4a32-ad14-7d09ce04acb6', status: 'IN_PROGRESS' }),
  7. errors: [Bandwidth::LookupErrorSchema.new({ code: 'E1', description: 'bad', type: 'validation' })]
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::CreateAsyncBulkLookupResponse.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::CreateAsyncBulkLookupResponse.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::CreateAsyncBulkLookupResponse.acceptable_attributes).to eq(Bandwidth::CreateAsyncBulkLookupResponse.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be an empty set' do
  28. 1 expect(Bandwidth::CreateAsyncBulkLookupResponse.openapi_nullable).to eq(Set.new([]))
  29. end
  30. end
  31. 1 describe '#build_from_hash' do
  32. 1 it 'validates instance of CreateAsyncBulkLookupResponse created by the build_from_hash method' do
  33. 1 create_async_bulk_lookup_response_from_hash = Bandwidth::CreateAsyncBulkLookupResponse.build_from_hash({
  34. links: [{ href: 'https://example.com', rel: 'self', method: 'GET' }],
  35. data: { requestId: '00b97c1b-d8b4-4a32-ad14-7d09ce04acb6', status: 'IN_PROGRESS' },
  36. errors: [{ code: 'E1', description: 'bad', type: 'validation' }]
  37. })
  38. 1 expect(create_async_bulk_lookup_response_from_hash).to be_instance_of(Bandwidth::CreateAsyncBulkLookupResponse)
  39. 1 expect(create_async_bulk_lookup_response_from_hash.links.first).to be_instance_of(Bandwidth::LinkSchema)
  40. 1 expect(create_async_bulk_lookup_response_from_hash.data).to be_instance_of(Bandwidth::CreateAsyncBulkLookupResponseData)
  41. 1 expect(create_async_bulk_lookup_response_from_hash.errors.first).to be_instance_of(Bandwidth::LookupErrorSchema)
  42. end
  43. end
  44. 1 describe '#to_s' do
  45. 1 it 'returns a string representation of the object' do
  46. 1 expect(create_async_bulk_lookup_response_values.to_s).to eq('{:links=>[{:href=>"https://example.com", :rel=>"self", :method=>"GET"}], :data=>{:requestId=>"00b97c1b-d8b4-4a32-ad14-7d09ce04acb6", :status=>"IN_PROGRESS"}, :errors=>[{:code=>"E1", :description=>"bad", :type=>"validation"}]}')
  47. end
  48. end
  49. 1 describe '#eq? #==' do
  50. 1 it 'returns true/false when comparing objects' do
  51. 1 expect(create_async_bulk_lookup_response_default.eql?(Bandwidth::CreateAsyncBulkLookupResponse.new)).to be true
  52. 1 expect(create_async_bulk_lookup_response_default.eql?(create_async_bulk_lookup_response_values)).to be false
  53. end
  54. end
  55. 1 describe '#to_body #to_hash' do
  56. 1 it 'returns a hash representation of the object' do
  57. 1 expect(create_async_bulk_lookup_response_values.to_body).to eq({
  58. links: [{ href: 'https://example.com', rel: 'self', method: 'GET' }],
  59. data: { requestId: '00b97c1b-d8b4-4a32-ad14-7d09ce04acb6', status: 'IN_PROGRESS' },
  60. errors: [{ code: 'E1', description: 'bad', type: 'validation' }]
  61. })
  62. end
  63. end
  64. end

spec/unit/models/create_call_response_spec.rb

100.0% lines covered

86 relevant lines. 86 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CreateCallResponse
  2. 1 describe Bandwidth::CreateCallResponse do
  3. 2 let(:create_call_response_default) { Bandwidth::CreateCallResponse.new({
  4. application_id: 'baseline-app',
  5. account_id: '9900000',
  6. call_id: 'baseline-call',
  7. to: '+19195550100',
  8. from: '+19195550101',
  9. call_url: 'https://example.com/calls/baseline',
  10. answer_url: 'https://example.com/answer/baseline'
  11. }) }
  12. 4 let(:create_call_response_values) { Bandwidth::CreateCallResponse.new({
  13. application_id: '04e88489-df02-4e34-a0ee-27a91849555f',
  14. account_id: '9900000',
  15. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  16. to: '+19195551234',
  17. from: '+19195554321',
  18. enqueued_time: '2022-06-16T13:15:07.160Z',
  19. call_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-1',
  20. call_timeout: 30.0,
  21. callback_timeout: 15.0,
  22. tag: 'custom tag',
  23. answer_method: Bandwidth::CallbackMethodEnum::POST,
  24. answer_url: 'https://example.com/answer',
  25. answer_fallback_method: Bandwidth::CallbackMethodEnum::POST,
  26. answer_fallback_url: 'https://example.com/answer-fallback',
  27. disconnect_method: Bandwidth::CallbackMethodEnum::POST,
  28. disconnect_url: 'https://example.com/disconnect',
  29. username: 'user',
  30. password: 'pass',
  31. fallback_username: 'fallback_user',
  32. fallback_password: 'fallback_pass',
  33. priority: 5
  34. }) }
  35. 1 describe '#initialize' do
  36. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  37. 1 expect {
  38. 1 Bandwidth::CreateCallResponse.new([])
  39. }.to raise_error(ArgumentError)
  40. end
  41. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  42. 1 expect {
  43. 1 Bandwidth::CreateCallResponse.new({ invalid: true })
  44. }.to raise_error(ArgumentError)
  45. end
  46. end
  47. 1 describe '#acceptable_attributes' do
  48. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  49. 1 expect(Bandwidth::CreateCallResponse.acceptable_attributes).to eq(Bandwidth::CreateCallResponse.attribute_map.values)
  50. end
  51. end
  52. 1 describe '#openapi_nullable' do
  53. 1 it 'expects nullable attributes to be the set of nullable fields' do
  54. 1 expect(Bandwidth::CreateCallResponse.openapi_nullable).to eq(Set.new([
  55. :'enqueued_time',
  56. :'tag',
  57. :'answer_method',
  58. :'answer_fallback_method',
  59. :'answer_fallback_url',
  60. :'disconnect_method',
  61. :'disconnect_url',
  62. :'username',
  63. :'password',
  64. :'fallback_username',
  65. :'fallback_password',
  66. :'priority'
  67. ]))
  68. end
  69. end
  70. 1 describe '#build_from_hash' do
  71. 1 it 'validates instance of CreateCallResponse created by the build_from_hash method' do
  72. 1 create_call_response_from_hash = Bandwidth::CreateCallResponse.build_from_hash({
  73. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  74. accountId: '9900000',
  75. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  76. to: '+19195551234',
  77. from: '+19195554321',
  78. enqueuedTime: '2022-06-16T13:15:07.160Z',
  79. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-1',
  80. callTimeout: 30.0,
  81. callbackTimeout: 15.0,
  82. tag: 'custom tag',
  83. answerMethod: 'POST',
  84. answerUrl: 'https://example.com/answer',
  85. answerFallbackMethod: 'POST',
  86. answerFallbackUrl: 'https://example.com/answer-fallback',
  87. disconnectMethod: 'POST',
  88. disconnectUrl: 'https://example.com/disconnect',
  89. username: 'user',
  90. password: 'pass',
  91. fallbackUsername: 'fallback_user',
  92. fallbackPassword: 'fallback_pass',
  93. priority: 5
  94. })
  95. 1 expect(create_call_response_from_hash).to be_instance_of(Bandwidth::CreateCallResponse)
  96. 1 expect(create_call_response_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f')
  97. 1 expect(create_call_response_from_hash.account_id).to eq('9900000')
  98. 1 expect(create_call_response_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  99. 1 expect(create_call_response_from_hash.to).to eq('+19195551234')
  100. 1 expect(create_call_response_from_hash.from).to eq('+19195554321')
  101. 1 expect(create_call_response_from_hash.enqueued_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  102. 1 expect(create_call_response_from_hash.call_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-1')
  103. 1 expect(create_call_response_from_hash.call_timeout).to eq(30.0)
  104. 1 expect(create_call_response_from_hash.callback_timeout).to eq(15.0)
  105. 1 expect(create_call_response_from_hash.tag).to eq('custom tag')
  106. 1 expect(create_call_response_from_hash.answer_method).to eq(Bandwidth::CallbackMethodEnum::POST)
  107. 1 expect(create_call_response_from_hash.answer_url).to eq('https://example.com/answer')
  108. 1 expect(create_call_response_from_hash.answer_fallback_method).to eq(Bandwidth::CallbackMethodEnum::POST)
  109. 1 expect(create_call_response_from_hash.answer_fallback_url).to eq('https://example.com/answer-fallback')
  110. 1 expect(create_call_response_from_hash.disconnect_method).to eq(Bandwidth::CallbackMethodEnum::POST)
  111. 1 expect(create_call_response_from_hash.disconnect_url).to eq('https://example.com/disconnect')
  112. 1 expect(create_call_response_from_hash.username).to eq('user')
  113. 1 expect(create_call_response_from_hash.password).to eq('pass')
  114. 1 expect(create_call_response_from_hash.fallback_username).to eq('fallback_user')
  115. 1 expect(create_call_response_from_hash.fallback_password).to eq('fallback_pass')
  116. 1 expect(create_call_response_from_hash.priority).to eq(5)
  117. end
  118. end
  119. 1 describe '#to_s' do
  120. 1 it 'returns a string representation of the object' do
  121. 1 expect(create_call_response_values.to_s).to eq('{:applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :accountId=>"9900000", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :to=>"+19195551234", :from=>"+19195554321", :enqueuedTime=>"2022-06-16T13:15:07.160Z", :callUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-1", :callTimeout=>30.0, :callbackTimeout=>15.0, :tag=>"custom tag", :answerMethod=>"POST", :answerUrl=>"https://example.com/answer", :answerFallbackMethod=>"POST", :answerFallbackUrl=>"https://example.com/answer-fallback", :disconnectMethod=>"POST", :disconnectUrl=>"https://example.com/disconnect", :username=>"user", :password=>"pass", :fallbackUsername=>"fallback_user", :fallbackPassword=>"fallback_pass", :priority=>5}')
  122. end
  123. end
  124. 1 describe '#eq? #==' do
  125. 1 it 'returns true/false when comparing objects' do
  126. 1 create_call_response_equal = Bandwidth::CreateCallResponse.new({
  127. application_id: 'baseline-app',
  128. account_id: '9900000',
  129. call_id: 'baseline-call',
  130. to: '+19195550100',
  131. from: '+19195550101',
  132. call_url: 'https://example.com/calls/baseline',
  133. answer_url: 'https://example.com/answer/baseline'
  134. })
  135. 1 expect(create_call_response_default.eql?(create_call_response_equal)).to be true
  136. 1 expect(create_call_response_default.eql?(create_call_response_values)).to be false
  137. end
  138. end
  139. 1 describe '#to_body #to_hash' do
  140. 1 it 'returns a hash representation of the object' do
  141. 1 expect(create_call_response_values.to_body).to eq({
  142. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  143. accountId: '9900000',
  144. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  145. to: '+19195551234',
  146. from: '+19195554321',
  147. enqueuedTime: '2022-06-16T13:15:07.160Z',
  148. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-1',
  149. callTimeout: 30.0,
  150. callbackTimeout: 15.0,
  151. tag: 'custom tag',
  152. answerMethod: Bandwidth::CallbackMethodEnum::POST,
  153. answerUrl: 'https://example.com/answer',
  154. answerFallbackMethod: Bandwidth::CallbackMethodEnum::POST,
  155. answerFallbackUrl: 'https://example.com/answer-fallback',
  156. disconnectMethod: Bandwidth::CallbackMethodEnum::POST,
  157. disconnectUrl: 'https://example.com/disconnect',
  158. username: 'user',
  159. password: 'pass',
  160. fallbackUsername: 'fallback_user',
  161. fallbackPassword: 'fallback_pass',
  162. priority: 5
  163. })
  164. end
  165. end
  166. 1 describe 'custom attribute writers' do
  167. 1 it '#application_id=' do
  168. 1 expect {
  169. 1 Bandwidth::CreateCallResponse.new({ application_id: nil, account_id: 'a', call_id: 'a', to: 'a', from: 'a', call_url: 'a', answer_url: 'a' })
  170. }.to raise_error(ArgumentError, 'application_id cannot be nil')
  171. end
  172. 1 it '#account_id=' do
  173. 1 expect {
  174. 1 Bandwidth::CreateCallResponse.new({ application_id: 'a', account_id: nil, call_id: 'a', to: 'a', from: 'a', call_url: 'a', answer_url: 'a' })
  175. }.to raise_error(ArgumentError, 'account_id cannot be nil')
  176. end
  177. 1 it '#call_id=' do
  178. 1 expect {
  179. 1 Bandwidth::CreateCallResponse.new({ application_id: 'a', account_id: 'a', call_id: nil, to: 'a', from: 'a', call_url: 'a', answer_url: 'a' })
  180. }.to raise_error(ArgumentError, 'call_id cannot be nil')
  181. end
  182. 1 it '#to=' do
  183. 1 expect {
  184. 1 Bandwidth::CreateCallResponse.new({ application_id: 'a', account_id: 'a', call_id: 'a', to: nil, from: 'a', call_url: 'a', answer_url: 'a' })
  185. }.to raise_error(ArgumentError, 'to cannot be nil')
  186. end
  187. 1 it '#from=' do
  188. 1 expect {
  189. 1 Bandwidth::CreateCallResponse.new({ application_id: 'a', account_id: 'a', call_id: 'a', to: 'a', from: nil, call_url: 'a', answer_url: 'a' })
  190. }.to raise_error(ArgumentError, 'from cannot be nil')
  191. end
  192. 1 it '#call_url=' do
  193. 1 expect {
  194. 1 Bandwidth::CreateCallResponse.new({ application_id: 'a', account_id: 'a', call_id: 'a', to: 'a', from: 'a', call_url: nil, answer_url: 'a' })
  195. }.to raise_error(ArgumentError, 'call_url cannot be nil')
  196. end
  197. 1 it '#answer_url=' do
  198. 1 expect {
  199. 1 Bandwidth::CreateCallResponse.new({ application_id: 'a', account_id: 'a', call_id: 'a', to: 'a', from: 'a', call_url: 'a', answer_url: nil })
  200. }.to raise_error(ArgumentError, 'answer_url cannot be nil')
  201. end
  202. 1 it '#username=' do
  203. 1 expect {
  204. 1 Bandwidth::CreateCallResponse.new({ application_id: 'a', account_id: 'a', call_id: 'a', to: 'a', from: 'a', call_url: 'a', answer_url: 'a', username: 'a' * 1025 })
  205. }.to raise_error(ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 1024.')
  206. end
  207. 1 it '#password=' do
  208. 1 expect {
  209. 1 Bandwidth::CreateCallResponse.new({ application_id: 'a', account_id: 'a', call_id: 'a', to: 'a', from: 'a', call_url: 'a', answer_url: 'a', password: 'a' * 1025 })
  210. }.to raise_error(ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 1024.')
  211. end
  212. 1 it '#fallback_username=' do
  213. 1 expect {
  214. 1 Bandwidth::CreateCallResponse.new({ application_id: 'a', account_id: 'a', call_id: 'a', to: 'a', from: 'a', call_url: 'a', answer_url: 'a', fallback_username: 'a' * 1025 })
  215. }.to raise_error(ArgumentError, 'invalid value for "fallback_username", the character length must be smaller than or equal to 1024.')
  216. end
  217. 1 it '#fallback_password=' do
  218. 1 expect {
  219. 1 Bandwidth::CreateCallResponse.new({ application_id: 'a', account_id: 'a', call_id: 'a', to: 'a', from: 'a', call_url: 'a', answer_url: 'a', fallback_password: 'a' * 1025 })
  220. }.to raise_error(ArgumentError, 'invalid value for "fallback_password", the character length must be smaller than or equal to 1024.')
  221. end
  222. end
  223. end

spec/unit/models/create_call_spec.rb

100.0% lines covered

105 relevant lines. 105 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CreateCall
  2. 1 describe Bandwidth::CreateCall do
  3. 2 let(:create_call_default) { Bandwidth::CreateCall.new({
  4. to: '+19195550100',
  5. from: '+19195550101',
  6. application_id: 'baseline-app',
  7. answer_url: 'https://example.com/answer/baseline'
  8. }) }
  9. 4 let(:create_call_values) { Bandwidth::CreateCall.new({
  10. to: '+19195551234',
  11. from: '+19195554321',
  12. privacy: false,
  13. display_name: 'Caller Name',
  14. uui: 'eyJ0eXAiOiJKV1Q;encoding=jwt',
  15. application_id: '04e88489-df02-4e34-a0ee-27a91849555f',
  16. answer_url: 'https://example.com/answer',
  17. answer_method: Bandwidth::CallbackMethodEnum::POST,
  18. username: 'user',
  19. password: 'pass',
  20. answer_fallback_url: 'https://example.com/answer-fallback',
  21. answer_fallback_method: Bandwidth::CallbackMethodEnum::POST,
  22. fallback_username: 'fallback_user',
  23. fallback_password: 'fallback_pass',
  24. disconnect_url: 'https://example.com/disconnect',
  25. disconnect_method: Bandwidth::CallbackMethodEnum::POST,
  26. call_timeout: 30,
  27. callback_timeout: 15,
  28. machine_detection: {},
  29. priority: 5,
  30. tag: 'custom tag'
  31. }) }
  32. 1 describe '#initialize' do
  33. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  34. 1 expect {
  35. 1 Bandwidth::CreateCall.new([])
  36. }.to raise_error(ArgumentError)
  37. end
  38. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  39. 1 expect {
  40. 1 Bandwidth::CreateCall.new({ invalid: true })
  41. }.to raise_error(ArgumentError)
  42. end
  43. end
  44. 1 describe '#acceptable_attributes' do
  45. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  46. 1 expect(Bandwidth::CreateCall.acceptable_attributes).to eq(Bandwidth::CreateCall.attribute_map.values)
  47. end
  48. end
  49. 1 describe '#openapi_nullable' do
  50. 1 it 'expects nullable attributes to be the set of nullable fields' do
  51. 1 expect(Bandwidth::CreateCall.openapi_nullable).to eq(Set.new([
  52. :'privacy',
  53. :'display_name',
  54. :'uui',
  55. :'answer_method',
  56. :'username',
  57. :'password',
  58. :'answer_fallback_url',
  59. :'answer_fallback_method',
  60. :'fallback_username',
  61. :'fallback_password',
  62. :'disconnect_url',
  63. :'disconnect_method',
  64. :'call_timeout',
  65. :'callback_timeout',
  66. :'priority',
  67. :'tag'
  68. ]))
  69. end
  70. end
  71. 1 describe '#build_from_hash' do
  72. 1 it 'validates instance of CreateCall created by the build_from_hash method' do
  73. 1 create_call_from_hash = Bandwidth::CreateCall.build_from_hash({
  74. to: '+19195551234',
  75. from: '+19195554321',
  76. privacy: false,
  77. displayName: 'Caller Name',
  78. uui: 'eyJ0eXAiOiJKV1Q;encoding=jwt',
  79. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  80. answerUrl: 'https://example.com/answer',
  81. answerMethod: 'POST',
  82. username: 'user',
  83. password: 'pass',
  84. answerFallbackUrl: 'https://example.com/answer-fallback',
  85. answerFallbackMethod: 'POST',
  86. fallbackUsername: 'fallback_user',
  87. fallbackPassword: 'fallback_pass',
  88. disconnectUrl: 'https://example.com/disconnect',
  89. disconnectMethod: 'POST',
  90. callTimeout: 30,
  91. callbackTimeout: 15,
  92. priority: 5,
  93. tag: 'custom tag'
  94. })
  95. 1 expect(create_call_from_hash).to be_instance_of(Bandwidth::CreateCall)
  96. 1 expect(create_call_from_hash.to).to eq('+19195551234')
  97. 1 expect(create_call_from_hash.from).to eq('+19195554321')
  98. 1 expect(create_call_from_hash.privacy).to eq(false)
  99. 1 expect(create_call_from_hash.display_name).to eq('Caller Name')
  100. 1 expect(create_call_from_hash.uui).to eq('eyJ0eXAiOiJKV1Q;encoding=jwt')
  101. 1 expect(create_call_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f')
  102. 1 expect(create_call_from_hash.answer_url).to eq('https://example.com/answer')
  103. 1 expect(create_call_from_hash.answer_method).to eq(Bandwidth::CallbackMethodEnum::POST)
  104. 1 expect(create_call_from_hash.username).to eq('user')
  105. 1 expect(create_call_from_hash.password).to eq('pass')
  106. 1 expect(create_call_from_hash.answer_fallback_url).to eq('https://example.com/answer-fallback')
  107. 1 expect(create_call_from_hash.answer_fallback_method).to eq(Bandwidth::CallbackMethodEnum::POST)
  108. 1 expect(create_call_from_hash.fallback_username).to eq('fallback_user')
  109. 1 expect(create_call_from_hash.fallback_password).to eq('fallback_pass')
  110. 1 expect(create_call_from_hash.disconnect_url).to eq('https://example.com/disconnect')
  111. 1 expect(create_call_from_hash.disconnect_method).to eq(Bandwidth::CallbackMethodEnum::POST)
  112. 1 expect(create_call_from_hash.call_timeout).to eq(30)
  113. 1 expect(create_call_from_hash.callback_timeout).to eq(15)
  114. 1 expect(create_call_from_hash.priority).to eq(5)
  115. 1 expect(create_call_from_hash.tag).to eq('custom tag')
  116. end
  117. end
  118. 1 describe '#to_s' do
  119. 1 it 'returns a string representation of the object' do
  120. 1 expect(create_call_values.to_s).to eq('{:to=>"+19195551234", :from=>"+19195554321", :privacy=>false, :displayName=>"Caller Name", :uui=>"eyJ0eXAiOiJKV1Q;encoding=jwt", :applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :answerUrl=>"https://example.com/answer", :answerMethod=>"POST", :username=>"user", :password=>"pass", :answerFallbackUrl=>"https://example.com/answer-fallback", :answerFallbackMethod=>"POST", :fallbackUsername=>"fallback_user", :fallbackPassword=>"fallback_pass", :disconnectUrl=>"https://example.com/disconnect", :disconnectMethod=>"POST", :callTimeout=>30, :callbackTimeout=>15, :machineDetection=>{}, :priority=>5, :tag=>"custom tag"}')
  121. end
  122. end
  123. 1 describe '#eq? #==' do
  124. 1 it 'returns true/false when comparing objects' do
  125. 1 create_call_equal = Bandwidth::CreateCall.new({
  126. to: '+19195550100',
  127. from: '+19195550101',
  128. application_id: 'baseline-app',
  129. answer_url: 'https://example.com/answer/baseline'
  130. })
  131. 1 expect(create_call_default.eql?(create_call_equal)).to be true
  132. 1 expect(create_call_default.eql?(create_call_values)).to be false
  133. end
  134. end
  135. 1 describe '#to_body #to_hash' do
  136. 1 it 'returns a hash representation of the object' do
  137. 1 expect(create_call_values.to_body).to eq({
  138. to: '+19195551234',
  139. from: '+19195554321',
  140. privacy: false,
  141. displayName: 'Caller Name',
  142. uui: 'eyJ0eXAiOiJKV1Q;encoding=jwt',
  143. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  144. answerUrl: 'https://example.com/answer',
  145. answerMethod: Bandwidth::CallbackMethodEnum::POST,
  146. username: 'user',
  147. password: 'pass',
  148. answerFallbackUrl: 'https://example.com/answer-fallback',
  149. answerFallbackMethod: Bandwidth::CallbackMethodEnum::POST,
  150. fallbackUsername: 'fallback_user',
  151. fallbackPassword: 'fallback_pass',
  152. disconnectUrl: 'https://example.com/disconnect',
  153. disconnectMethod: Bandwidth::CallbackMethodEnum::POST,
  154. callTimeout: 30,
  155. callbackTimeout: 15,
  156. machineDetection: {},
  157. priority: 5,
  158. tag: 'custom tag'
  159. })
  160. end
  161. end
  162. 1 describe 'custom attribute writers' do
  163. 1 it '#to=' do
  164. 1 expect {
  165. 1 Bandwidth::CreateCall.new({ to: nil, from: 'a', application_id: 'a', answer_url: 'a' })
  166. }.to raise_error(ArgumentError, 'to cannot be nil')
  167. end
  168. 1 it '#from=' do
  169. 1 expect {
  170. 1 Bandwidth::CreateCall.new({ to: 'a', from: nil, application_id: 'a', answer_url: 'a' })
  171. }.to raise_error(ArgumentError, 'from cannot be nil')
  172. end
  173. 1 it '#display_name=' do
  174. 1 expect {
  175. 1 Bandwidth::CreateCall.new({ to: 'a', from: 'a', display_name: 'a' * 257, application_id: 'a', answer_url: 'a' })
  176. }.to raise_error(ArgumentError, 'invalid value for "display_name", the character length must be smaller than or equal to 256.')
  177. end
  178. 1 it '#application_id=' do
  179. 1 expect {
  180. 1 Bandwidth::CreateCall.new({ to: 'a', from: 'a', application_id: nil, answer_url: 'a' })
  181. }.to raise_error(ArgumentError, 'application_id cannot be nil')
  182. end
  183. 1 it '#answer_url=' do
  184. 1 expect {
  185. 1 Bandwidth::CreateCall.new({ to: 'a', from: 'a', application_id: 'a', answer_url: nil })
  186. }.to raise_error(ArgumentError, 'answer_url cannot be nil')
  187. 1 expect {
  188. 1 Bandwidth::CreateCall.new({ to: 'a', from: 'a', application_id: 'a', answer_url: 'a' * 2049 })
  189. }.to raise_error(ArgumentError, 'invalid value for "answer_url", the character length must be smaller than or equal to 2048.')
  190. end
  191. 1 it '#username=' do
  192. 1 expect {
  193. 1 Bandwidth::CreateCall.new({ to: 'a', from: 'a', application_id: 'a', answer_url: 'a', username: 'a' * 1025 })
  194. }.to raise_error(ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 1024.')
  195. end
  196. 1 it '#password=' do
  197. 1 expect {
  198. 1 Bandwidth::CreateCall.new({ to: 'a', from: 'a', application_id: 'a', answer_url: 'a', password: 'a' * 1025 })
  199. }.to raise_error(ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 1024.')
  200. end
  201. 1 it '#answer_fallback_url=' do
  202. 1 expect {
  203. 1 Bandwidth::CreateCall.new({ to: 'a', from: 'a', application_id: 'a', answer_url: 'a', answer_fallback_url: 'a' * 2049 })
  204. }.to raise_error(ArgumentError, 'invalid value for "answer_fallback_url", the character length must be smaller than or equal to 2048.')
  205. end
  206. 1 it '#fallback_username=' do
  207. 1 expect {
  208. 1 Bandwidth::CreateCall.new({ to: 'a', from: 'a', application_id: 'a', answer_url: 'a', fallback_username: 'a' * 1025 })
  209. }.to raise_error(ArgumentError, 'invalid value for "fallback_username", the character length must be smaller than or equal to 1024.')
  210. end
  211. 1 it '#fallback_password=' do
  212. 1 expect {
  213. 1 Bandwidth::CreateCall.new({ to: 'a', from: 'a', application_id: 'a', answer_url: 'a', fallback_password: 'a' * 1025 })
  214. }.to raise_error(ArgumentError, 'invalid value for "fallback_password", the character length must be smaller than or equal to 1024.')
  215. end
  216. 1 it '#disconnect_url=' do
  217. 1 expect {
  218. 1 Bandwidth::CreateCall.new({ to: 'a', from: 'a', application_id: 'a', answer_url: 'a', disconnect_url: 'a' * 2049 })
  219. }.to raise_error(ArgumentError, 'invalid value for "disconnect_url", the character length must be smaller than or equal to 2048.')
  220. end
  221. 1 it '#call_timeout=' do
  222. 1 expect {
  223. 1 Bandwidth::CreateCall.new({ to: 'a', from: 'a', application_id: 'a', answer_url: 'a', call_timeout: 301 })
  224. }.to raise_error(ArgumentError, 'invalid value for "call_timeout", must be smaller than or equal to 300.')
  225. 1 expect {
  226. 1 Bandwidth::CreateCall.new({ to: 'a', from: 'a', application_id: 'a', answer_url: 'a', call_timeout: 0 })
  227. }.to raise_error(ArgumentError, 'invalid value for "call_timeout", must be greater than or equal to 1.')
  228. end
  229. 1 it '#callback_timeout=' do
  230. 1 expect {
  231. 1 Bandwidth::CreateCall.new({ to: 'a', from: 'a', application_id: 'a', answer_url: 'a', callback_timeout: 26 })
  232. }.to raise_error(ArgumentError, 'invalid value for "callback_timeout", must be smaller than or equal to 25.')
  233. 1 expect {
  234. 1 Bandwidth::CreateCall.new({ to: 'a', from: 'a', application_id: 'a', answer_url: 'a', callback_timeout: 0 })
  235. }.to raise_error(ArgumentError, 'invalid value for "callback_timeout", must be greater than or equal to 1.')
  236. end
  237. 1 it '#priority=' do
  238. 1 expect {
  239. 1 Bandwidth::CreateCall.new({ to: 'a', from: 'a', application_id: 'a', answer_url: 'a', priority: 6 })
  240. }.to raise_error(ArgumentError, 'invalid value for "priority", must be smaller than or equal to 5.')
  241. 1 expect {
  242. 1 Bandwidth::CreateCall.new({ to: 'a', from: 'a', application_id: 'a', answer_url: 'a', priority: 0 })
  243. }.to raise_error(ArgumentError, 'invalid value for "priority", must be greater than or equal to 1.')
  244. end
  245. 1 it '#tag=' do
  246. 1 expect {
  247. 1 Bandwidth::CreateCall.new({ to: 'a', from: 'a', application_id: 'a', answer_url: 'a', tag: 'a' * 4097 })
  248. }.to raise_error(ArgumentError, 'invalid value for "tag", the character length must be smaller than or equal to 4096.')
  249. end
  250. end
  251. end

spec/unit/models/create_endpoint_request_base_spec.rb

100.0% lines covered

46 relevant lines. 46 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CreateEndpointRequestBase
  2. 1 describe Bandwidth::CreateEndpointRequestBase do
  3. 2 let(:create_endpoint_request_base_default) { Bandwidth::CreateEndpointRequestBase.new({
  4. type: 'WEBRTC',
  5. direction: 'INBOUND'
  6. }) }
  7. 4 let(:create_endpoint_request_base_values) { Bandwidth::CreateEndpointRequestBase.new({
  8. type: Bandwidth::EndpointTypeEnum::WEBRTC,
  9. direction: Bandwidth::EndpointDirectionEnum::BIDIRECTIONAL,
  10. event_callback_url: 'https://example.com/event-callback',
  11. event_fallback_url: 'https://example.com/event-fallback',
  12. tag: 'custom tag'
  13. }) }
  14. 1 describe '#initialize' do
  15. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::CreateEndpointRequestBase.new([])
  18. }.to raise_error(ArgumentError)
  19. end
  20. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  21. 1 expect {
  22. 1 Bandwidth::CreateEndpointRequestBase.new({ invalid: true })
  23. }.to raise_error(ArgumentError)
  24. end
  25. end
  26. 1 describe '#acceptable_attributes' do
  27. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  28. 1 expect(Bandwidth::CreateEndpointRequestBase.acceptable_attributes).to eq(Bandwidth::CreateEndpointRequestBase.attribute_map.values)
  29. end
  30. end
  31. 1 describe '#openapi_nullable' do
  32. 1 it 'expects nullable attributes to be an empty set' do
  33. 1 expect(Bandwidth::CreateEndpointRequestBase.openapi_nullable).to eq(Set.new([]))
  34. end
  35. end
  36. 1 describe '#build_from_hash' do
  37. 1 it 'validates instance of CreateEndpointRequestBase created by the build_from_hash method' do
  38. 1 create_endpoint_request_base_from_hash = Bandwidth::CreateEndpointRequestBase.build_from_hash({
  39. type: 'WEBRTC',
  40. direction: 'BIDIRECTIONAL',
  41. eventCallbackUrl: 'https://example.com/event-callback',
  42. eventFallbackUrl: 'https://example.com/event-fallback',
  43. tag: 'custom tag'
  44. })
  45. 1 expect(create_endpoint_request_base_from_hash).to be_instance_of(Bandwidth::CreateEndpointRequestBase)
  46. 1 expect(create_endpoint_request_base_from_hash.type).to eq(Bandwidth::EndpointTypeEnum::WEBRTC)
  47. 1 expect(create_endpoint_request_base_from_hash.direction).to eq(Bandwidth::EndpointDirectionEnum::BIDIRECTIONAL)
  48. 1 expect(create_endpoint_request_base_from_hash.event_callback_url).to eq('https://example.com/event-callback')
  49. 1 expect(create_endpoint_request_base_from_hash.event_fallback_url).to eq('https://example.com/event-fallback')
  50. 1 expect(create_endpoint_request_base_from_hash.tag).to eq('custom tag')
  51. end
  52. end
  53. 1 describe '#to_s' do
  54. 1 it 'returns a string representation of the object' do
  55. 1 expect(create_endpoint_request_base_values.to_s).to eq('{:type=>"WEBRTC", :direction=>"BIDIRECTIONAL", :eventCallbackUrl=>"https://example.com/event-callback", :eventFallbackUrl=>"https://example.com/event-fallback", :tag=>"custom tag"}')
  56. end
  57. end
  58. 1 describe '#eq? #==' do
  59. 1 it 'returns true/false when comparing objects' do
  60. 1 create_endpoint_request_base_equal = Bandwidth::CreateEndpointRequestBase.new({
  61. type: 'WEBRTC',
  62. direction: 'INBOUND'
  63. })
  64. 1 expect(create_endpoint_request_base_default.eql?(create_endpoint_request_base_equal)).to be true
  65. 1 expect(create_endpoint_request_base_default.eql?(create_endpoint_request_base_values)).to be false
  66. end
  67. end
  68. 1 describe '#to_body #to_hash' do
  69. 1 it 'returns a hash representation of the object' do
  70. 1 expect(create_endpoint_request_base_values.to_body).to eq({
  71. type: Bandwidth::EndpointTypeEnum::WEBRTC,
  72. direction: Bandwidth::EndpointDirectionEnum::BIDIRECTIONAL,
  73. eventCallbackUrl: 'https://example.com/event-callback',
  74. eventFallbackUrl: 'https://example.com/event-fallback',
  75. tag: 'custom tag'
  76. })
  77. end
  78. end
  79. 1 describe 'custom attribute writers' do
  80. 1 it '#type=' do
  81. 1 expect {
  82. 1 Bandwidth::CreateEndpointRequestBase.new({ type: nil, direction: 'INBOUND' })
  83. }.to raise_error(ArgumentError, 'type cannot be nil')
  84. end
  85. 1 it '#direction=' do
  86. 1 expect {
  87. 1 Bandwidth::CreateEndpointRequestBase.new({ type: 'WEBRTC', direction: nil })
  88. }.to raise_error(ArgumentError, 'direction cannot be nil')
  89. end
  90. 1 it '#tag=' do
  91. 1 expect {
  92. 1 Bandwidth::CreateEndpointRequestBase.new({ type: 'WEBRTC', direction: 'INBOUND', tag: nil })
  93. }.to raise_error(ArgumentError, 'tag cannot be nil')
  94. end
  95. end
  96. end

spec/unit/models/create_endpoint_response_data_spec.rb

100.0% lines covered

61 relevant lines. 61 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CreateEndpointResponseData
  2. 1 describe Bandwidth::CreateEndpointResponseData do
  3. 2 let(:create_endpoint_response_data_default) { Bandwidth::CreateEndpointResponseData.new({
  4. endpoint_id: 'baseline-endpoint',
  5. type: 'WEBRTC',
  6. status: 'CONNECTED',
  7. creation_timestamp: '2022-06-16T13:15:07.160Z',
  8. expiration_timestamp: '2022-06-17T13:15:07.160Z',
  9. token: 'baseline-token'
  10. }) }
  11. 4 let(:create_endpoint_response_data_values) { Bandwidth::CreateEndpointResponseData.new({
  12. endpoint_id: 'ep-abc-123',
  13. type: Bandwidth::EndpointTypeEnum::WEBRTC,
  14. status: Bandwidth::EndpointStatusEnum::CONNECTED,
  15. creation_timestamp: '2022-06-16T13:15:07.160Z',
  16. expiration_timestamp: '2022-06-17T13:15:07.160Z',
  17. tag: 'custom tag',
  18. devices: [Bandwidth::Device.new({ device_id: 'd-1', status: 'CONNECTED', creation_timestamp: '2022-06-16T13:15:08.000Z' })],
  19. token: 'eyJhbGciOiJIUzI1NiJ9'
  20. }) }
  21. 1 describe '#initialize' do
  22. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  23. 1 expect {
  24. 1 Bandwidth::CreateEndpointResponseData.new([])
  25. }.to raise_error(ArgumentError)
  26. end
  27. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  28. 1 expect {
  29. 1 Bandwidth::CreateEndpointResponseData.new({ invalid: true })
  30. }.to raise_error(ArgumentError)
  31. end
  32. end
  33. 1 describe '#acceptable_attributes' do
  34. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  35. 1 expect(Bandwidth::CreateEndpointResponseData.acceptable_attributes).to eq(Bandwidth::CreateEndpointResponseData.attribute_map.values)
  36. end
  37. end
  38. 1 describe '#openapi_nullable' do
  39. 1 it 'expects nullable attributes to be an empty set' do
  40. 1 expect(Bandwidth::CreateEndpointResponseData.openapi_nullable).to eq(Set.new([]))
  41. end
  42. end
  43. 1 describe '#build_from_hash' do
  44. 1 it 'validates instance of CreateEndpointResponseData created by the build_from_hash method' do
  45. 1 create_endpoint_response_data_from_hash = Bandwidth::CreateEndpointResponseData.build_from_hash({
  46. endpointId: 'ep-abc-123',
  47. type: 'WEBRTC',
  48. status: 'CONNECTED',
  49. creationTimestamp: '2022-06-16T13:15:07.160Z',
  50. expirationTimestamp: '2022-06-17T13:15:07.160Z',
  51. tag: 'custom tag',
  52. devices: [{ deviceId: 'd-1', status: 'CONNECTED', creationTimestamp: '2022-06-16T13:15:08.000Z' }],
  53. token: 'eyJhbGciOiJIUzI1NiJ9'
  54. })
  55. 1 expect(create_endpoint_response_data_from_hash).to be_instance_of(Bandwidth::CreateEndpointResponseData)
  56. 1 expect(create_endpoint_response_data_from_hash.endpoint_id).to eq('ep-abc-123')
  57. 1 expect(create_endpoint_response_data_from_hash.type).to eq(Bandwidth::EndpointTypeEnum::WEBRTC)
  58. 1 expect(create_endpoint_response_data_from_hash.status).to eq(Bandwidth::EndpointStatusEnum::CONNECTED)
  59. 1 expect(create_endpoint_response_data_from_hash.creation_timestamp).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  60. 1 expect(create_endpoint_response_data_from_hash.expiration_timestamp).to eq(Time.parse('2022-06-17T13:15:07.160Z'))
  61. 1 expect(create_endpoint_response_data_from_hash.tag).to eq('custom tag')
  62. 1 expect(create_endpoint_response_data_from_hash.devices.first).to be_instance_of(Bandwidth::Device)
  63. 1 expect(create_endpoint_response_data_from_hash.token).to eq('eyJhbGciOiJIUzI1NiJ9')
  64. end
  65. end
  66. 1 describe '#to_s' do
  67. 1 it 'returns a string representation of the object' do
  68. 1 expect(create_endpoint_response_data_values.to_s).to eq('{:endpointId=>"ep-abc-123", :type=>"WEBRTC", :status=>"CONNECTED", :creationTimestamp=>"2022-06-16T13:15:07.160Z", :expirationTimestamp=>"2022-06-17T13:15:07.160Z", :tag=>"custom tag", :devices=>[{:deviceId=>"d-1", :status=>"CONNECTED", :creationTimestamp=>"2022-06-16T13:15:08.000Z"}], :token=>"eyJhbGciOiJIUzI1NiJ9"}')
  69. end
  70. end
  71. 1 describe '#eq? #==' do
  72. 1 it 'returns true/false when comparing objects' do
  73. 1 create_endpoint_response_data_equal = Bandwidth::CreateEndpointResponseData.new({
  74. endpoint_id: 'baseline-endpoint',
  75. type: 'WEBRTC',
  76. status: 'CONNECTED',
  77. creation_timestamp: '2022-06-16T13:15:07.160Z',
  78. expiration_timestamp: '2022-06-17T13:15:07.160Z',
  79. token: 'baseline-token'
  80. })
  81. 1 expect(create_endpoint_response_data_default.eql?(create_endpoint_response_data_equal)).to be true
  82. 1 expect(create_endpoint_response_data_default.eql?(create_endpoint_response_data_values)).to be false
  83. end
  84. end
  85. 1 describe '#to_body #to_hash' do
  86. 1 it 'returns a hash representation of the object' do
  87. 1 expect(create_endpoint_response_data_values.to_body).to eq({
  88. endpointId: 'ep-abc-123',
  89. type: Bandwidth::EndpointTypeEnum::WEBRTC,
  90. status: Bandwidth::EndpointStatusEnum::CONNECTED,
  91. creationTimestamp: '2022-06-16T13:15:07.160Z',
  92. expirationTimestamp: '2022-06-17T13:15:07.160Z',
  93. tag: 'custom tag',
  94. devices: [{ deviceId: 'd-1', status: 'CONNECTED', creationTimestamp: '2022-06-16T13:15:08.000Z' }],
  95. token: 'eyJhbGciOiJIUzI1NiJ9'
  96. })
  97. end
  98. end
  99. 1 describe 'custom attribute writers' do
  100. 1 it '#endpoint_id=' do
  101. 1 expect {
  102. 1 Bandwidth::CreateEndpointResponseData.new({ endpoint_id: nil, type: 'WEBRTC', status: 'CONNECTED', creation_timestamp: 'a', expiration_timestamp: 'a', token: 'a' })
  103. }.to raise_error(ArgumentError, 'endpoint_id cannot be nil')
  104. end
  105. 1 it '#type=' do
  106. 1 expect {
  107. 1 Bandwidth::CreateEndpointResponseData.new({ endpoint_id: 'a', type: nil, status: 'CONNECTED', creation_timestamp: 'a', expiration_timestamp: 'a', token: 'a' })
  108. }.to raise_error(ArgumentError, 'type cannot be nil')
  109. end
  110. 1 it '#status=' do
  111. 1 expect {
  112. 1 Bandwidth::CreateEndpointResponseData.new({ endpoint_id: 'a', type: 'WEBRTC', status: nil, creation_timestamp: 'a', expiration_timestamp: 'a', token: 'a' })
  113. }.to raise_error(ArgumentError, 'status cannot be nil')
  114. end
  115. 1 it '#creation_timestamp=' do
  116. 1 expect {
  117. 1 Bandwidth::CreateEndpointResponseData.new({ endpoint_id: 'a', type: 'WEBRTC', status: 'CONNECTED', creation_timestamp: nil, expiration_timestamp: 'a', token: 'a' })
  118. }.to raise_error(ArgumentError, 'creation_timestamp cannot be nil')
  119. end
  120. 1 it '#expiration_timestamp=' do
  121. 1 expect {
  122. 1 Bandwidth::CreateEndpointResponseData.new({ endpoint_id: 'a', type: 'WEBRTC', status: 'CONNECTED', creation_timestamp: 'a', expiration_timestamp: nil, token: 'a' })
  123. }.to raise_error(ArgumentError, 'expiration_timestamp cannot be nil')
  124. end
  125. 1 it '#tag=' do
  126. 1 expect {
  127. 1 Bandwidth::CreateEndpointResponseData.new({ endpoint_id: 'a', type: 'WEBRTC', status: 'CONNECTED', creation_timestamp: 'a', expiration_timestamp: 'a', token: 'a', tag: nil })
  128. }.to raise_error(ArgumentError, 'tag cannot be nil')
  129. end
  130. 1 it '#token=' do
  131. 1 expect {
  132. 1 Bandwidth::CreateEndpointResponseData.new({ endpoint_id: 'a', type: 'WEBRTC', status: 'CONNECTED', creation_timestamp: 'a', expiration_timestamp: 'a', token: nil })
  133. }.to raise_error(ArgumentError, 'token cannot be nil')
  134. end
  135. end
  136. end

spec/unit/models/create_endpoint_response_spec.rb

100.0% lines covered

44 relevant lines. 44 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CreateEndpointResponse
  2. 1 describe Bandwidth::CreateEndpointResponse do
  3. 2 let(:create_endpoint_response_default) { Bandwidth::CreateEndpointResponse.new({
  4. links: [],
  5. data: {},
  6. errors: []
  7. }) }
  8. 7 let(:create_endpoint_response_values) { Bandwidth::CreateEndpointResponse.new({
  9. links: [Bandwidth::BrtcLink.new({ href: 'https://example.com', rel: 'self', method: 'GET' })],
  10. data: Bandwidth::CreateEndpointResponseData.new({
  11. endpoint_id: 'ep-abc-123',
  12. type: 'WEBRTC',
  13. status: 'CONNECTED',
  14. creation_timestamp: '2022-06-16T13:15:07.160Z',
  15. expiration_timestamp: '2022-06-17T13:15:07.160Z',
  16. token: 'eyJhbGciOiJIUzI1NiJ9'
  17. }),
  18. errors: [Bandwidth::BrtcError.new({ type: 'validation', description: 'bad input' })]
  19. }) }
  20. 1 describe '#initialize' do
  21. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  22. 1 expect {
  23. 1 Bandwidth::CreateEndpointResponse.new([])
  24. }.to raise_error(ArgumentError)
  25. end
  26. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  27. 1 expect {
  28. 1 Bandwidth::CreateEndpointResponse.new({ invalid: true })
  29. }.to raise_error(ArgumentError)
  30. end
  31. end
  32. 1 describe '#acceptable_attributes' do
  33. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  34. 1 expect(Bandwidth::CreateEndpointResponse.acceptable_attributes).to eq(Bandwidth::CreateEndpointResponse.attribute_map.values)
  35. end
  36. end
  37. 1 describe '#openapi_nullable' do
  38. 1 it 'expects nullable attributes to be an empty set' do
  39. 1 expect(Bandwidth::CreateEndpointResponse.openapi_nullable).to eq(Set.new([]))
  40. end
  41. end
  42. 1 describe '#build_from_hash' do
  43. 1 it 'validates instance of CreateEndpointResponse created by the build_from_hash method' do
  44. 1 create_endpoint_response_from_hash = Bandwidth::CreateEndpointResponse.build_from_hash({
  45. links: [{ href: 'https://example.com', rel: 'self', method: 'GET' }],
  46. data: {
  47. endpointId: 'ep-abc-123',
  48. type: 'WEBRTC',
  49. status: 'CONNECTED',
  50. creationTimestamp: '2022-06-16T13:15:07.160Z',
  51. expirationTimestamp: '2022-06-17T13:15:07.160Z',
  52. token: 'eyJhbGciOiJIUzI1NiJ9'
  53. },
  54. errors: [{ type: 'validation', description: 'bad input' }]
  55. })
  56. 1 expect(create_endpoint_response_from_hash).to be_instance_of(Bandwidth::CreateEndpointResponse)
  57. 1 expect(create_endpoint_response_from_hash.links.first).to be_instance_of(Bandwidth::BrtcLink)
  58. 1 expect(create_endpoint_response_from_hash.data).to be_instance_of(Bandwidth::CreateEndpointResponseData)
  59. 1 expect(create_endpoint_response_from_hash.errors.first).to be_instance_of(Bandwidth::BrtcError)
  60. end
  61. end
  62. 1 describe '#to_s' do
  63. 1 it 'returns a string representation of the object' do
  64. 1 expect(create_endpoint_response_values.to_s).to eq('{:links=>[{:href=>"https://example.com", :rel=>"self", :method=>"GET"}], :data=>{:endpointId=>"ep-abc-123", :type=>"WEBRTC", :status=>"CONNECTED", :creationTimestamp=>"2022-06-16T13:15:07.160Z", :expirationTimestamp=>"2022-06-17T13:15:07.160Z", :token=>"eyJhbGciOiJIUzI1NiJ9"}, :errors=>[{:type=>"validation", :description=>"bad input"}]}')
  65. end
  66. end
  67. 1 describe '#eq? #==' do
  68. 1 it 'returns true/false when comparing objects' do
  69. 1 create_endpoint_response_equal = Bandwidth::CreateEndpointResponse.new({
  70. links: [],
  71. data: {},
  72. errors: []
  73. })
  74. 1 expect(create_endpoint_response_default.eql?(create_endpoint_response_equal)).to be true
  75. 1 expect(create_endpoint_response_default.eql?(create_endpoint_response_values)).to be false
  76. end
  77. end
  78. 1 describe '#to_body #to_hash' do
  79. 1 it 'returns a hash representation of the object' do
  80. 1 expect(create_endpoint_response_values.to_body).to eq({
  81. links: [{ href: 'https://example.com', rel: 'self', method: 'GET' }],
  82. data: {
  83. endpointId: 'ep-abc-123',
  84. type: Bandwidth::EndpointTypeEnum::WEBRTC,
  85. status: Bandwidth::EndpointStatusEnum::CONNECTED,
  86. creationTimestamp: '2022-06-16T13:15:07.160Z',
  87. expirationTimestamp: '2022-06-17T13:15:07.160Z',
  88. token: 'eyJhbGciOiJIUzI1NiJ9'
  89. },
  90. errors: [{ type: 'validation', description: 'bad input' }]
  91. })
  92. end
  93. end
  94. 1 describe 'custom attribute writers' do
  95. 1 it '#links=' do
  96. 1 expect {
  97. 1 create_endpoint_response_values.links = nil
  98. }.to raise_error(ArgumentError, 'links cannot be nil')
  99. end
  100. 1 it '#data=' do
  101. 1 expect {
  102. 1 create_endpoint_response_values.data = nil
  103. }.to raise_error(ArgumentError, 'data cannot be nil')
  104. end
  105. 1 it '#errors=' do
  106. 1 expect {
  107. 1 create_endpoint_response_values.errors = nil
  108. }.to raise_error(ArgumentError, 'errors cannot be nil')
  109. end
  110. end
  111. end

spec/unit/models/create_message_request_error_spec.rb

100.0% lines covered

41 relevant lines. 41 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CreateMessageRequestError
  2. 1 describe Bandwidth::CreateMessageRequestError do
  3. 2 let(:create_message_request_error_default) { Bandwidth::CreateMessageRequestError.new({
  4. type: 'baseline-type',
  5. description: 'baseline description'
  6. }) }
  7. 4 let(:create_message_request_error_values) { Bandwidth::CreateMessageRequestError.new({
  8. type: 'request-validation',
  9. description: 'Your request could not be processed.',
  10. field_errors: [Bandwidth::FieldError.new({ field_name: 'to', description: 'must be present' })]
  11. }) }
  12. 1 describe '#initialize' do
  13. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  14. 1 expect {
  15. 1 Bandwidth::CreateMessageRequestError.new([])
  16. }.to raise_error(ArgumentError)
  17. end
  18. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  19. 1 expect {
  20. 1 Bandwidth::CreateMessageRequestError.new({ invalid: true })
  21. }.to raise_error(ArgumentError)
  22. end
  23. end
  24. 1 describe '#acceptable_attributes' do
  25. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  26. 1 expect(Bandwidth::CreateMessageRequestError.acceptable_attributes).to eq(Bandwidth::CreateMessageRequestError.attribute_map.values)
  27. end
  28. end
  29. 1 describe '#openapi_nullable' do
  30. 1 it 'expects nullable attributes to be an empty set' do
  31. 1 expect(Bandwidth::CreateMessageRequestError.openapi_nullable).to eq(Set.new([]))
  32. end
  33. end
  34. 1 describe '#build_from_hash' do
  35. 1 it 'validates instance of CreateMessageRequestError created by the build_from_hash method' do
  36. 1 create_message_request_error_from_hash = Bandwidth::CreateMessageRequestError.build_from_hash({
  37. type: 'request-validation',
  38. description: 'Your request could not be processed.',
  39. fieldErrors: [{ fieldName: 'to', description: 'must be present' }]
  40. })
  41. 1 expect(create_message_request_error_from_hash).to be_instance_of(Bandwidth::CreateMessageRequestError)
  42. 1 expect(create_message_request_error_from_hash.type).to eq('request-validation')
  43. 1 expect(create_message_request_error_from_hash.description).to eq('Your request could not be processed.')
  44. 1 expect(create_message_request_error_from_hash.field_errors.first).to be_instance_of(Bandwidth::FieldError)
  45. end
  46. end
  47. 1 describe '#to_s' do
  48. 1 it 'returns a string representation of the object' do
  49. 1 expect(create_message_request_error_values.to_s).to eq('{:type=>"request-validation", :description=>"Your request could not be processed.", :fieldErrors=>[{:fieldName=>"to", :description=>"must be present"}]}')
  50. end
  51. end
  52. 1 describe '#eq? #==' do
  53. 1 it 'returns true/false when comparing objects' do
  54. 1 create_message_request_error_equal = Bandwidth::CreateMessageRequestError.new({
  55. type: 'baseline-type',
  56. description: 'baseline description'
  57. })
  58. 1 expect(create_message_request_error_default.eql?(create_message_request_error_equal)).to be true
  59. 1 expect(create_message_request_error_default.eql?(create_message_request_error_values)).to be false
  60. end
  61. end
  62. 1 describe '#to_body #to_hash' do
  63. 1 it 'returns a hash representation of the object' do
  64. 1 expect(create_message_request_error_values.to_body).to eq({
  65. type: 'request-validation',
  66. description: 'Your request could not be processed.',
  67. fieldErrors: [{ fieldName: 'to', description: 'must be present' }]
  68. })
  69. end
  70. end
  71. 1 describe 'custom attribute writers' do
  72. 1 it '#type=' do
  73. 1 expect {
  74. 1 Bandwidth::CreateMessageRequestError.new({ type: nil, description: 'a' })
  75. }.to raise_error(ArgumentError, 'type cannot be nil')
  76. end
  77. 1 it '#description=' do
  78. 1 expect {
  79. 1 Bandwidth::CreateMessageRequestError.new({ type: 'a', description: nil })
  80. }.to raise_error(ArgumentError, 'description cannot be nil')
  81. end
  82. end
  83. end

spec/unit/models/create_multi_channel_message_response_spec.rb

100.0% lines covered

32 relevant lines. 32 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CreateMultiChannelMessageResponse
  2. 1 describe Bandwidth::CreateMultiChannelMessageResponse do
  3. 2 let(:create_multi_channel_message_response_default) { Bandwidth::CreateMultiChannelMessageResponse.new }
  4. 4 let(:create_multi_channel_message_response_values) { Bandwidth::CreateMultiChannelMessageResponse.new({
  5. links: [Bandwidth::Link.new({ rel: 'self', href: 'https://example.com' })],
  6. errors: [Bandwidth::ErrorObject.new({ type: 'validation', description: 'bad input', source: Bandwidth::ErrorSource.new })]
  7. }) }
  8. 1 describe '#initialize' do
  9. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  10. 1 expect {
  11. 1 Bandwidth::CreateMultiChannelMessageResponse.new([])
  12. }.to raise_error(ArgumentError)
  13. end
  14. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  15. 1 expect {
  16. 1 Bandwidth::CreateMultiChannelMessageResponse.new({ invalid: true })
  17. }.to raise_error(ArgumentError)
  18. end
  19. end
  20. 1 describe '#acceptable_attributes' do
  21. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  22. 1 expect(Bandwidth::CreateMultiChannelMessageResponse.acceptable_attributes).to eq(Bandwidth::CreateMultiChannelMessageResponse.attribute_map.values)
  23. end
  24. end
  25. 1 describe '#openapi_nullable' do
  26. 1 it 'expects nullable attributes to be an empty set' do
  27. 1 expect(Bandwidth::CreateMultiChannelMessageResponse.openapi_nullable).to eq(Set.new([]))
  28. end
  29. end
  30. 1 describe '#build_from_hash' do
  31. 1 it 'validates instance of CreateMultiChannelMessageResponse created by the build_from_hash method' do
  32. 1 create_multi_channel_message_response_from_hash = Bandwidth::CreateMultiChannelMessageResponse.build_from_hash({
  33. links: [{ rel: 'self', href: 'https://example.com' }],
  34. errors: [{ type: 'validation', description: 'bad input', source: {} }]
  35. })
  36. 1 expect(create_multi_channel_message_response_from_hash).to be_instance_of(Bandwidth::CreateMultiChannelMessageResponse)
  37. 1 expect(create_multi_channel_message_response_from_hash.links.first).to be_instance_of(Bandwidth::Link)
  38. 1 expect(create_multi_channel_message_response_from_hash.errors.first).to be_instance_of(Bandwidth::ErrorObject)
  39. end
  40. end
  41. 1 describe '#to_s' do
  42. 1 it 'returns a string representation of the object' do
  43. 1 expect(create_multi_channel_message_response_values.to_s).to eq('{:links=>[{:rel=>"self", :href=>"https://example.com"}], :errors=>[{:type=>"validation", :description=>"bad input", :source=>{}}]}')
  44. end
  45. end
  46. 1 describe '#eq? #==' do
  47. 1 it 'returns true/false when comparing objects' do
  48. 1 expect(create_multi_channel_message_response_default.eql?(Bandwidth::CreateMultiChannelMessageResponse.new)).to be true
  49. 1 expect(create_multi_channel_message_response_default.eql?(create_multi_channel_message_response_values)).to be false
  50. end
  51. end
  52. 1 describe '#to_body #to_hash' do
  53. 1 it 'returns a hash representation of the object' do
  54. 1 expect(create_multi_channel_message_response_values.to_body).to eq({
  55. links: [{ rel: 'self', href: 'https://example.com' }],
  56. errors: [{ type: 'validation', description: 'bad input', source: {} }]
  57. })
  58. end
  59. end
  60. end

spec/unit/models/create_sync_lookup_response_data_spec.rb

100.0% lines covered

33 relevant lines. 33 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CreateSyncLookupResponseData
  2. 1 describe Bandwidth::CreateSyncLookupResponseData do
  3. 2 let(:create_sync_lookup_response_data_default) { Bandwidth::CreateSyncLookupResponseData.new }
  4. 4 let(:create_sync_lookup_response_data_values) { Bandwidth::CreateSyncLookupResponseData.new({
  5. request_id: '00b97c1b-d8b4-4a32-ad14-7d09ce04acb6',
  6. status: Bandwidth::CompletedLookupStatusEnum::COMPLETE,
  7. results: [Bandwidth::LookupResult.new({ phone_number: '+19195551234' })]
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::CreateSyncLookupResponseData.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::CreateSyncLookupResponseData.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::CreateSyncLookupResponseData.acceptable_attributes).to eq(Bandwidth::CreateSyncLookupResponseData.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be an empty set' do
  28. 1 expect(Bandwidth::CreateSyncLookupResponseData.openapi_nullable).to eq(Set.new([]))
  29. end
  30. end
  31. 1 describe '#build_from_hash' do
  32. 1 it 'validates instance of CreateSyncLookupResponseData created by the build_from_hash method' do
  33. 1 create_sync_lookup_response_data_from_hash = Bandwidth::CreateSyncLookupResponseData.build_from_hash({
  34. requestId: '00b97c1b-d8b4-4a32-ad14-7d09ce04acb6',
  35. status: 'COMPLETE',
  36. results: [{ phoneNumber: '+19195551234' }]
  37. })
  38. 1 expect(create_sync_lookup_response_data_from_hash).to be_instance_of(Bandwidth::CreateSyncLookupResponseData)
  39. 1 expect(create_sync_lookup_response_data_from_hash.request_id).to eq('00b97c1b-d8b4-4a32-ad14-7d09ce04acb6')
  40. 1 expect(create_sync_lookup_response_data_from_hash.status).to eq(Bandwidth::CompletedLookupStatusEnum::COMPLETE)
  41. 1 expect(create_sync_lookup_response_data_from_hash.results.first).to be_instance_of(Bandwidth::LookupResult)
  42. end
  43. end
  44. 1 describe '#to_s' do
  45. 1 it 'returns a string representation of the object' do
  46. 1 expect(create_sync_lookup_response_data_values.to_s).to eq('{:requestId=>"00b97c1b-d8b4-4a32-ad14-7d09ce04acb6", :status=>"COMPLETE", :results=>[{:phoneNumber=>"+19195551234"}]}')
  47. end
  48. end
  49. 1 describe '#eq? #==' do
  50. 1 it 'returns true/false when comparing objects' do
  51. 1 expect(create_sync_lookup_response_data_default.eql?(Bandwidth::CreateSyncLookupResponseData.new)).to be true
  52. 1 expect(create_sync_lookup_response_data_default.eql?(create_sync_lookup_response_data_values)).to be false
  53. end
  54. end
  55. 1 describe '#to_body #to_hash' do
  56. 1 it 'returns a hash representation of the object' do
  57. 1 expect(create_sync_lookup_response_data_values.to_body).to eq({
  58. requestId: '00b97c1b-d8b4-4a32-ad14-7d09ce04acb6',
  59. status: Bandwidth::CompletedLookupStatusEnum::COMPLETE,
  60. results: [{ phoneNumber: '+19195551234' }]
  61. })
  62. end
  63. end
  64. end

spec/unit/models/create_sync_lookup_response_spec.rb

100.0% lines covered

33 relevant lines. 33 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CreateSyncLookupResponse
  2. 1 describe Bandwidth::CreateSyncLookupResponse do
  3. 2 let(:create_sync_lookup_response_default) { Bandwidth::CreateSyncLookupResponse.new }
  4. 4 let(:create_sync_lookup_response_values) { Bandwidth::CreateSyncLookupResponse.new({
  5. links: [Bandwidth::LinkSchema.new({ href: 'https://example.com', rel: 'self', method: 'GET' })],
  6. data: Bandwidth::CreateSyncLookupResponseData.new({ request_id: '00b97c1b-d8b4-4a32-ad14-7d09ce04acb6', status: 'COMPLETE' }),
  7. errors: [Bandwidth::LookupErrorSchema.new({ code: 'E1', description: 'bad', type: 'validation' })]
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::CreateSyncLookupResponse.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::CreateSyncLookupResponse.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::CreateSyncLookupResponse.acceptable_attributes).to eq(Bandwidth::CreateSyncLookupResponse.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be an empty set' do
  28. 1 expect(Bandwidth::CreateSyncLookupResponse.openapi_nullable).to eq(Set.new([]))
  29. end
  30. end
  31. 1 describe '#build_from_hash' do
  32. 1 it 'validates instance of CreateSyncLookupResponse created by the build_from_hash method' do
  33. 1 create_sync_lookup_response_from_hash = Bandwidth::CreateSyncLookupResponse.build_from_hash({
  34. links: [{ href: 'https://example.com', rel: 'self', method: 'GET' }],
  35. data: { requestId: '00b97c1b-d8b4-4a32-ad14-7d09ce04acb6', status: 'COMPLETE' },
  36. errors: [{ code: 'E1', description: 'bad', type: 'validation' }]
  37. })
  38. 1 expect(create_sync_lookup_response_from_hash).to be_instance_of(Bandwidth::CreateSyncLookupResponse)
  39. 1 expect(create_sync_lookup_response_from_hash.links.first).to be_instance_of(Bandwidth::LinkSchema)
  40. 1 expect(create_sync_lookup_response_from_hash.data).to be_instance_of(Bandwidth::CreateSyncLookupResponseData)
  41. 1 expect(create_sync_lookup_response_from_hash.errors.first).to be_instance_of(Bandwidth::LookupErrorSchema)
  42. end
  43. end
  44. 1 describe '#to_s' do
  45. 1 it 'returns a string representation of the object' do
  46. 1 expect(create_sync_lookup_response_values.to_s).to eq('{:links=>[{:href=>"https://example.com", :rel=>"self", :method=>"GET"}], :data=>{:requestId=>"00b97c1b-d8b4-4a32-ad14-7d09ce04acb6", :status=>"COMPLETE"}, :errors=>[{:code=>"E1", :description=>"bad", :type=>"validation"}]}')
  47. end
  48. end
  49. 1 describe '#eq? #==' do
  50. 1 it 'returns true/false when comparing objects' do
  51. 1 expect(create_sync_lookup_response_default.eql?(Bandwidth::CreateSyncLookupResponse.new)).to be true
  52. 1 expect(create_sync_lookup_response_default.eql?(create_sync_lookup_response_values)).to be false
  53. end
  54. end
  55. 1 describe '#to_body #to_hash' do
  56. 1 it 'returns a hash representation of the object' do
  57. 1 expect(create_sync_lookup_response_values.to_body).to eq({
  58. links: [{ href: 'https://example.com', rel: 'self', method: 'GET' }],
  59. data: { requestId: '00b97c1b-d8b4-4a32-ad14-7d09ce04acb6', status: 'COMPLETE' },
  60. errors: [{ code: 'E1', description: 'bad', type: 'validation' }]
  61. })
  62. end
  63. end
  64. end

spec/unit/models/create_web_rtc_connection_request_spec.rb

100.0% lines covered

47 relevant lines. 47 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::CreateWebRtcConnectionRequest
  2. 1 describe Bandwidth::CreateWebRtcConnectionRequest do
  3. 2 let(:create_web_rtc_connection_request_default) { Bandwidth::CreateWebRtcConnectionRequest.new({
  4. type: 'WEBRTC',
  5. direction: 'INBOUND'
  6. }) }
  7. 4 let(:create_web_rtc_connection_request_values) { Bandwidth::CreateWebRtcConnectionRequest.new({
  8. type: Bandwidth::EndpointTypeEnum::WEBRTC,
  9. direction: Bandwidth::EndpointDirectionEnum::BIDIRECTIONAL,
  10. event_callback_url: 'https://example.com/event-callback',
  11. event_fallback_url: 'https://example.com/event-fallback',
  12. tag: 'custom tag',
  13. connection_metadata: { sessionId: 'session-1' }
  14. }) }
  15. 1 describe '#initialize' do
  16. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  17. 1 expect {
  18. 1 Bandwidth::CreateWebRtcConnectionRequest.new([])
  19. }.to raise_error(ArgumentError)
  20. end
  21. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  22. 1 expect {
  23. 1 Bandwidth::CreateWebRtcConnectionRequest.new({ invalid: true })
  24. }.to raise_error(ArgumentError)
  25. end
  26. end
  27. 1 describe '#acceptable_attributes' do
  28. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  29. 1 expect(Bandwidth::CreateWebRtcConnectionRequest.acceptable_attributes).to eq(Bandwidth::CreateWebRtcConnectionRequest.attribute_map.values)
  30. end
  31. end
  32. 1 describe '#openapi_nullable' do
  33. 1 it 'expects nullable attributes to be an empty set' do
  34. 1 expect(Bandwidth::CreateWebRtcConnectionRequest.openapi_nullable).to eq(Set.new([]))
  35. end
  36. end
  37. 1 describe '#build_from_hash' do
  38. 1 it 'validates instance of CreateWebRtcConnectionRequest created by the build_from_hash method' do
  39. 1 create_web_rtc_connection_request_from_hash = Bandwidth::CreateWebRtcConnectionRequest.build_from_hash({
  40. type: 'WEBRTC',
  41. direction: 'BIDIRECTIONAL',
  42. eventCallbackUrl: 'https://example.com/event-callback',
  43. eventFallbackUrl: 'https://example.com/event-fallback',
  44. tag: 'custom tag',
  45. connectionMetadata: { sessionId: 'session-1' }
  46. })
  47. 1 expect(create_web_rtc_connection_request_from_hash).to be_instance_of(Bandwidth::CreateWebRtcConnectionRequest)
  48. 1 expect(create_web_rtc_connection_request_from_hash.type).to eq(Bandwidth::EndpointTypeEnum::WEBRTC)
  49. 1 expect(create_web_rtc_connection_request_from_hash.direction).to eq(Bandwidth::EndpointDirectionEnum::BIDIRECTIONAL)
  50. 1 expect(create_web_rtc_connection_request_from_hash.event_callback_url).to eq('https://example.com/event-callback')
  51. 1 expect(create_web_rtc_connection_request_from_hash.event_fallback_url).to eq('https://example.com/event-fallback')
  52. 1 expect(create_web_rtc_connection_request_from_hash.tag).to eq('custom tag')
  53. 1 expect(create_web_rtc_connection_request_from_hash.connection_metadata).to eq({ sessionId: 'session-1' })
  54. end
  55. end
  56. 1 describe '#to_s' do
  57. 1 it 'returns a string representation of the object' do
  58. 1 expect(create_web_rtc_connection_request_values.to_s).to eq('{:type=>"WEBRTC", :direction=>"BIDIRECTIONAL", :eventCallbackUrl=>"https://example.com/event-callback", :eventFallbackUrl=>"https://example.com/event-fallback", :tag=>"custom tag", :connectionMetadata=>{:sessionId=>"session-1"}}')
  59. end
  60. end
  61. 1 describe '#eq? #==' do
  62. 1 it 'returns true/false when comparing objects' do
  63. 1 create_web_rtc_connection_request_equal = Bandwidth::CreateWebRtcConnectionRequest.new({
  64. type: 'WEBRTC',
  65. direction: 'INBOUND'
  66. })
  67. 1 expect(create_web_rtc_connection_request_default.eql?(create_web_rtc_connection_request_equal)).to be true
  68. 1 expect(create_web_rtc_connection_request_default.eql?(create_web_rtc_connection_request_values)).to be false
  69. end
  70. end
  71. 1 describe '#to_body #to_hash' do
  72. 1 it 'returns a hash representation of the object' do
  73. 1 expect(create_web_rtc_connection_request_values.to_body).to eq({
  74. type: Bandwidth::EndpointTypeEnum::WEBRTC,
  75. direction: Bandwidth::EndpointDirectionEnum::BIDIRECTIONAL,
  76. eventCallbackUrl: 'https://example.com/event-callback',
  77. eventFallbackUrl: 'https://example.com/event-fallback',
  78. tag: 'custom tag',
  79. connectionMetadata: { sessionId: 'session-1' }
  80. })
  81. end
  82. end
  83. 1 describe 'custom attribute writers' do
  84. 1 it '#type=' do
  85. 1 expect {
  86. 1 Bandwidth::CreateWebRtcConnectionRequest.new({ type: nil, direction: 'INBOUND' })
  87. }.to raise_error(ArgumentError, 'type cannot be nil')
  88. end
  89. 1 it '#direction=' do
  90. 1 expect {
  91. 1 Bandwidth::CreateWebRtcConnectionRequest.new({ type: 'WEBRTC', direction: nil })
  92. }.to raise_error(ArgumentError, 'direction cannot be nil')
  93. end
  94. 1 it '#tag=' do
  95. 1 expect {
  96. 1 Bandwidth::CreateWebRtcConnectionRequest.new({ type: 'WEBRTC', direction: 'INBOUND', tag: nil })
  97. }.to raise_error(ArgumentError, 'tag cannot be nil')
  98. end
  99. end
  100. end

spec/unit/models/deactivation_event_enum_spec.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::DeactivationEventEnum
  2. 1 describe Bandwidth::DeactivationEventEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines DEACTIVATED' do
  5. 1 expect(Bandwidth::DeactivationEventEnum::DEACTIVATED).to eq('DEACTIVATED')
  6. end
  7. end
  8. 1 describe '.all_vars' do
  9. 1 it 'returns every valid enum value' do
  10. 1 expect(Bandwidth::DeactivationEventEnum.all_vars).to eq([
  11. 'DEACTIVATED'
  12. ])
  13. end
  14. end
  15. 1 describe '.build_from_hash' do
  16. 1 it 'returns the value when it matches a valid enum value' do
  17. 1 expect(Bandwidth::DeactivationEventEnum.build_from_hash('DEACTIVATED')).to eq('DEACTIVATED')
  18. end
  19. 1 it 'raises an error for an invalid enum value' do
  20. 1 expect {
  21. 1 Bandwidth::DeactivationEventEnum.build_from_hash('invalid')
  22. }.to raise_error(RuntimeError)
  23. end
  24. end
  25. end

spec/unit/models/device_spec.rb

100.0% lines covered

48 relevant lines. 48 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Device
  2. 1 describe Bandwidth::Device do
  3. 2 let(:device_default) { Bandwidth::Device.new({
  4. device_id: 'baseline-device',
  5. status: 'CONNECTED',
  6. creation_timestamp: '2022-06-16T13:15:07.160Z'
  7. }) }
  8. 4 let(:device_values) { Bandwidth::Device.new({
  9. device_id: 'd-abc-123',
  10. device_name: 'Chrome on macOS',
  11. status: Bandwidth::DeviceStatusEnum::CONNECTED,
  12. creation_timestamp: '2022-06-16T13:15:07.160Z'
  13. }) }
  14. 1 describe '#initialize' do
  15. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::Device.new([])
  18. }.to raise_error(ArgumentError)
  19. end
  20. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  21. 1 expect {
  22. 1 Bandwidth::Device.new({ invalid: true })
  23. }.to raise_error(ArgumentError)
  24. end
  25. end
  26. 1 describe '#acceptable_attributes' do
  27. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  28. 1 expect(Bandwidth::Device.acceptable_attributes).to eq(Bandwidth::Device.attribute_map.values)
  29. end
  30. end
  31. 1 describe '#openapi_nullable' do
  32. 1 it 'expects nullable attributes to be an empty set' do
  33. 1 expect(Bandwidth::Device.openapi_nullable).to eq(Set.new([]))
  34. end
  35. end
  36. 1 describe '#build_from_hash' do
  37. 1 it 'validates instance of Device created by the build_from_hash method' do
  38. 1 device_from_hash = Bandwidth::Device.build_from_hash({
  39. deviceId: 'd-abc-123',
  40. deviceName: 'Chrome on macOS',
  41. status: 'CONNECTED',
  42. creationTimestamp: '2022-06-16T13:15:07.160Z'
  43. })
  44. 1 expect(device_from_hash).to be_instance_of(Bandwidth::Device)
  45. 1 expect(device_from_hash.device_id).to eq('d-abc-123')
  46. 1 expect(device_from_hash.device_name).to eq('Chrome on macOS')
  47. 1 expect(device_from_hash.status).to eq(Bandwidth::DeviceStatusEnum::CONNECTED)
  48. 1 expect(device_from_hash.creation_timestamp).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  49. end
  50. end
  51. 1 describe '#to_s' do
  52. 1 it 'returns a string representation of the object' do
  53. 1 expect(device_values.to_s).to eq('{:deviceId=>"d-abc-123", :deviceName=>"Chrome on macOS", :status=>"CONNECTED", :creationTimestamp=>"2022-06-16T13:15:07.160Z"}')
  54. end
  55. end
  56. 1 describe '#eq? #==' do
  57. 1 it 'returns true/false when comparing objects' do
  58. 1 device_equal = Bandwidth::Device.new({
  59. device_id: 'baseline-device',
  60. status: 'CONNECTED',
  61. creation_timestamp: '2022-06-16T13:15:07.160Z'
  62. })
  63. 1 expect(device_default.eql?(device_equal)).to be true
  64. 1 expect(device_default.eql?(device_values)).to be false
  65. end
  66. end
  67. 1 describe '#to_body #to_hash' do
  68. 1 it 'returns a hash representation of the object' do
  69. 1 expect(device_values.to_body).to eq({
  70. deviceId: 'd-abc-123',
  71. deviceName: 'Chrome on macOS',
  72. status: Bandwidth::DeviceStatusEnum::CONNECTED,
  73. creationTimestamp: '2022-06-16T13:15:07.160Z'
  74. })
  75. end
  76. end
  77. 1 describe 'custom attribute writers' do
  78. 1 it '#device_id=' do
  79. 1 expect {
  80. 1 Bandwidth::Device.new({ device_id: nil, status: 'CONNECTED', creation_timestamp: 'a' })
  81. }.to raise_error(ArgumentError, 'device_id cannot be nil')
  82. end
  83. 1 it '#device_name=' do
  84. 1 expect {
  85. 1 Bandwidth::Device.new({ device_id: 'a', device_name: nil, status: 'CONNECTED', creation_timestamp: 'a' })
  86. }.to raise_error(ArgumentError, 'device_name cannot be nil')
  87. end
  88. 1 it '#status=' do
  89. 1 expect {
  90. 1 Bandwidth::Device.new({ device_id: 'a', status: nil, creation_timestamp: 'a' })
  91. }.to raise_error(ArgumentError, 'status cannot be nil')
  92. end
  93. 1 it '#creation_timestamp=' do
  94. 1 expect {
  95. 1 Bandwidth::Device.new({ device_id: 'a', status: 'CONNECTED', creation_timestamp: nil })
  96. }.to raise_error(ArgumentError, 'creation_timestamp cannot be nil')
  97. end
  98. end
  99. end

spec/unit/models/device_status_enum_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::DeviceStatusEnum
  2. 1 describe Bandwidth::DeviceStatusEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines CONNECTED' do
  5. 1 expect(Bandwidth::DeviceStatusEnum::CONNECTED).to eq('CONNECTED')
  6. end
  7. 1 it 'defines DISCONNECTED' do
  8. 1 expect(Bandwidth::DeviceStatusEnum::DISCONNECTED).to eq('DISCONNECTED')
  9. end
  10. end
  11. 1 describe '.all_vars' do
  12. 1 it 'returns every valid enum value' do
  13. 1 expect(Bandwidth::DeviceStatusEnum.all_vars).to eq([
  14. 'CONNECTED',
  15. 'DISCONNECTED'
  16. ])
  17. end
  18. end
  19. 1 describe '.build_from_hash' do
  20. 1 it 'returns the value when it matches a valid enum value' do
  21. 1 expect(Bandwidth::DeviceStatusEnum.build_from_hash('CONNECTED')).to eq('CONNECTED')
  22. 1 expect(Bandwidth::DeviceStatusEnum.build_from_hash('DISCONNECTED')).to eq('DISCONNECTED')
  23. end
  24. 1 it 'raises an error for an invalid enum value' do
  25. 1 expect {
  26. 1 Bandwidth::DeviceStatusEnum.build_from_hash('invalid')
  27. }.to raise_error(RuntimeError)
  28. end
  29. end
  30. end

spec/unit/models/disconnect_callback_spec.rb

100.0% lines covered

47 relevant lines. 47 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::DisconnectCallback
  2. 1 describe Bandwidth::DisconnectCallback do
  3. 2 let(:disconnect_callback_default) { Bandwidth::DisconnectCallback.new }
  4. 4 let(:disconnect_callback_values) { Bandwidth::DisconnectCallback.new({
  5. event_type: 'disconnect',
  6. event_time: '2022-06-16T13:15:07.160Z',
  7. account_id: '9900000',
  8. application_id: '04e88489-df02-4e34-a0ee-27a91849555f',
  9. from: '+19195554321',
  10. to: '+19195551234',
  11. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  12. direction: Bandwidth::CallDirectionEnum::INBOUND,
  13. call_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  14. enqueued_time: '2022-06-16T13:15:07.160Z',
  15. start_time: '2022-06-16T13:15:07.160Z',
  16. answer_time: '2022-06-16T13:15:18.126Z',
  17. end_time: '2022-06-16T13:16:18.126Z',
  18. cause: 'hangup',
  19. error_message: 'call rejected',
  20. error_id: '4642074b-7b58-478b-96e4-3a60955c6765',
  21. tag: 'custom tag'
  22. }) }
  23. 1 describe '#initialize' do
  24. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  25. 1 expect {
  26. 1 Bandwidth::DisconnectCallback.new([])
  27. }.to raise_error(ArgumentError)
  28. end
  29. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  30. 1 expect {
  31. 1 Bandwidth::DisconnectCallback.new({ invalid: true })
  32. }.to raise_error(ArgumentError)
  33. end
  34. end
  35. 1 describe '#acceptable_attributes' do
  36. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  37. 1 expect(Bandwidth::DisconnectCallback.acceptable_attributes).to eq(Bandwidth::DisconnectCallback.attribute_map.values)
  38. end
  39. end
  40. 1 describe '#openapi_nullable' do
  41. 1 it 'expects nullable attributes to be the set of nullable fields' do
  42. 1 expect(Bandwidth::DisconnectCallback.openapi_nullable).to eq(Set.new([
  43. :'enqueued_time',
  44. :'answer_time',
  45. :'error_message',
  46. :'error_id',
  47. :'tag'
  48. ]))
  49. end
  50. end
  51. 1 describe '#build_from_hash' do
  52. 1 it 'validates instance of DisconnectCallback created by the build_from_hash method' do
  53. 1 disconnect_callback_from_hash = Bandwidth::DisconnectCallback.build_from_hash({
  54. eventType: 'disconnect',
  55. eventTime: '2022-06-16T13:15:07.160Z',
  56. accountId: '9900000',
  57. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  58. from: '+19195554321',
  59. to: '+19195551234',
  60. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  61. direction: Bandwidth::CallDirectionEnum::INBOUND,
  62. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  63. enqueuedTime: '2022-06-16T13:15:07.160Z',
  64. startTime: '2022-06-16T13:15:07.160Z',
  65. answerTime: '2022-06-16T13:15:18.126Z',
  66. endTime: '2022-06-16T13:16:18.126Z',
  67. cause: 'hangup',
  68. errorMessage: 'call rejected',
  69. errorId: '4642074b-7b58-478b-96e4-3a60955c6765',
  70. tag: 'custom tag'
  71. })
  72. 1 expect(disconnect_callback_from_hash).to be_instance_of(Bandwidth::DisconnectCallback)
  73. 1 expect(disconnect_callback_from_hash.event_type).to eq('disconnect')
  74. 1 expect(disconnect_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  75. 1 expect(disconnect_callback_from_hash.account_id).to eq('9900000')
  76. 1 expect(disconnect_callback_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f')
  77. 1 expect(disconnect_callback_from_hash.from).to eq('+19195554321')
  78. 1 expect(disconnect_callback_from_hash.to).to eq('+19195551234')
  79. 1 expect(disconnect_callback_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  80. 1 expect(disconnect_callback_from_hash.direction).to eq(Bandwidth::CallDirectionEnum::INBOUND)
  81. 1 expect(disconnect_callback_from_hash.call_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  82. 1 expect(disconnect_callback_from_hash.enqueued_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  83. 1 expect(disconnect_callback_from_hash.start_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  84. 1 expect(disconnect_callback_from_hash.answer_time).to eq(Time.parse('2022-06-16T13:15:18.126Z'))
  85. 1 expect(disconnect_callback_from_hash.end_time).to eq(Time.parse('2022-06-16T13:16:18.126Z'))
  86. 1 expect(disconnect_callback_from_hash.cause).to eq('hangup')
  87. 1 expect(disconnect_callback_from_hash.error_message).to eq('call rejected')
  88. 1 expect(disconnect_callback_from_hash.error_id).to eq('4642074b-7b58-478b-96e4-3a60955c6765')
  89. 1 expect(disconnect_callback_from_hash.tag).to eq('custom tag')
  90. end
  91. end
  92. 1 describe '#to_s' do
  93. 1 it 'returns a string representation of the object' do
  94. 1 expect(disconnect_callback_values.to_s).to eq('{:eventType=>"disconnect", :eventTime=>"2022-06-16T13:15:07.160Z", :accountId=>"9900000", :applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :from=>"+19195554321", :to=>"+19195551234", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :direction=>"inbound", :callUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :enqueuedTime=>"2022-06-16T13:15:07.160Z", :startTime=>"2022-06-16T13:15:07.160Z", :answerTime=>"2022-06-16T13:15:18.126Z", :endTime=>"2022-06-16T13:16:18.126Z", :cause=>"hangup", :errorMessage=>"call rejected", :errorId=>"4642074b-7b58-478b-96e4-3a60955c6765", :tag=>"custom tag"}')
  95. end
  96. end
  97. 1 describe '#eq? #==' do
  98. 1 it 'returns true/false when comparing objects' do
  99. 1 expect(disconnect_callback_default.eql?(Bandwidth::DisconnectCallback.new)).to be true
  100. 1 expect(disconnect_callback_default.eql?(disconnect_callback_values)).to be false
  101. end
  102. end
  103. 1 describe '#to_body #to_hash' do
  104. 1 it 'returns a hash representation of the object' do
  105. 1 expect(disconnect_callback_values.to_body).to eq({
  106. eventType: 'disconnect',
  107. eventTime: '2022-06-16T13:15:07.160Z',
  108. accountId: '9900000',
  109. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  110. from: '+19195554321',
  111. to: '+19195551234',
  112. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  113. direction: Bandwidth::CallDirectionEnum::INBOUND,
  114. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  115. enqueuedTime: '2022-06-16T13:15:07.160Z',
  116. startTime: '2022-06-16T13:15:07.160Z',
  117. answerTime: '2022-06-16T13:15:18.126Z',
  118. endTime: '2022-06-16T13:16:18.126Z',
  119. cause: 'hangup',
  120. errorMessage: 'call rejected',
  121. errorId: '4642074b-7b58-478b-96e4-3a60955c6765',
  122. tag: 'custom tag'
  123. })
  124. end
  125. end
  126. end

spec/unit/models/diversion_spec.rb

100.0% lines covered

37 relevant lines. 37 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Diversion
  2. 1 describe Bandwidth::Diversion do
  3. 2 let(:diversion_default) { Bandwidth::Diversion.new }
  4. 4 let(:diversion_values) { Bandwidth::Diversion.new({
  5. reason: 'unconditional',
  6. privacy: 'off',
  7. screen: 'no',
  8. counter: '2',
  9. limit: '5',
  10. unknown: 'some-value',
  11. orig_to: '+19195551234'
  12. }) }
  13. 1 describe '#initialize' do
  14. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  15. 1 expect {
  16. 1 Bandwidth::Diversion.new([])
  17. }.to raise_error(ArgumentError)
  18. end
  19. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  20. 1 expect {
  21. 1 Bandwidth::Diversion.new({ invalid: true })
  22. }.to raise_error(ArgumentError)
  23. end
  24. end
  25. 1 describe '#acceptable_attributes' do
  26. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  27. 1 expect(Bandwidth::Diversion.acceptable_attributes).to eq(Bandwidth::Diversion.attribute_map.values)
  28. end
  29. end
  30. 1 describe '#openapi_nullable' do
  31. 1 it 'expects nullable attributes to be an empty set' do
  32. 1 expect(Bandwidth::Diversion.openapi_nullable).to eq(Set.new([]))
  33. end
  34. end
  35. 1 describe '#build_from_hash' do
  36. 1 it 'validates instance of Diversion created by the build_from_hash method' do
  37. 1 diversion_from_hash = Bandwidth::Diversion.build_from_hash({
  38. reason: 'unconditional',
  39. privacy: 'off',
  40. screen: 'no',
  41. counter: '2',
  42. limit: '5',
  43. unknown: 'some-value',
  44. origTo: '+19195551234'
  45. })
  46. 1 expect(diversion_from_hash).to be_instance_of(Bandwidth::Diversion)
  47. 1 expect(diversion_from_hash.reason).to eq('unconditional')
  48. 1 expect(diversion_from_hash.privacy).to eq('off')
  49. 1 expect(diversion_from_hash.screen).to eq('no')
  50. 1 expect(diversion_from_hash.counter).to eq('2')
  51. 1 expect(diversion_from_hash.limit).to eq('5')
  52. 1 expect(diversion_from_hash.unknown).to eq('some-value')
  53. 1 expect(diversion_from_hash.orig_to).to eq('+19195551234')
  54. end
  55. end
  56. 1 describe '#to_s' do
  57. 1 it 'returns a string representation of the object' do
  58. 1 expect(diversion_values.to_s).to eq('{:reason=>"unconditional", :privacy=>"off", :screen=>"no", :counter=>"2", :limit=>"5", :unknown=>"some-value", :origTo=>"+19195551234"}')
  59. end
  60. end
  61. 1 describe '#eq? #==' do
  62. 1 it 'returns true/false when comparing objects' do
  63. 1 expect(diversion_default.eql?(Bandwidth::Diversion.new)).to be true
  64. 1 expect(diversion_default.eql?(diversion_values)).to be false
  65. end
  66. end
  67. 1 describe '#to_body #to_hash' do
  68. 1 it 'returns a hash representation of the object' do
  69. 1 expect(diversion_values.to_body).to eq({
  70. reason: 'unconditional',
  71. privacy: 'off',
  72. screen: 'no',
  73. counter: '2',
  74. limit: '5',
  75. unknown: 'some-value',
  76. origTo: '+19195551234'
  77. })
  78. end
  79. end
  80. end

spec/unit/models/dtmf_callback_spec.rb

100.0% lines covered

47 relevant lines. 47 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::DtmfCallback
  2. 1 describe Bandwidth::DtmfCallback do
  3. 2 let(:dtmf_callback_default) { Bandwidth::DtmfCallback.new }
  4. 4 let(:dtmf_callback_values) { Bandwidth::DtmfCallback.new({
  5. event_type: 'dtmf',
  6. event_time: '2022-06-16T13:15:07.160Z',
  7. account_id: '9900000',
  8. application_id: '04e88489-df02-4e34-a0ee-27a91849555f',
  9. from: '+19195554321',
  10. to: '+19195551234',
  11. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  12. direction: Bandwidth::CallDirectionEnum::INBOUND,
  13. digit: '1',
  14. call_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  15. enqueued_time: '2022-06-16T13:15:07.160Z',
  16. start_time: '2022-06-16T13:15:07.160Z',
  17. answer_time: '2022-06-16T13:15:18.126Z',
  18. parent_call_id: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  19. transfer_caller_id: '+19195554321',
  20. transfer_to: '+19195551234',
  21. tag: 'custom tag'
  22. }) }
  23. 1 describe '#initialize' do
  24. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  25. 1 expect {
  26. 1 Bandwidth::DtmfCallback.new([])
  27. }.to raise_error(ArgumentError)
  28. end
  29. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  30. 1 expect {
  31. 1 Bandwidth::DtmfCallback.new({ invalid: true })
  32. }.to raise_error(ArgumentError)
  33. end
  34. end
  35. 1 describe '#acceptable_attributes' do
  36. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  37. 1 expect(Bandwidth::DtmfCallback.acceptable_attributes).to eq(Bandwidth::DtmfCallback.attribute_map.values)
  38. end
  39. end
  40. 1 describe '#openapi_nullable' do
  41. 1 it 'expects nullable attributes to be the set of nullable fields' do
  42. 1 expect(Bandwidth::DtmfCallback.openapi_nullable).to eq(Set.new([
  43. :'enqueued_time',
  44. :'answer_time',
  45. :'tag'
  46. ]))
  47. end
  48. end
  49. 1 describe '#build_from_hash' do
  50. 1 it 'validates instance of DtmfCallback created by the build_from_hash method' do
  51. 1 dtmf_callback_from_hash = Bandwidth::DtmfCallback.build_from_hash({
  52. eventType: 'dtmf',
  53. eventTime: '2022-06-16T13:15:07.160Z',
  54. accountId: '9900000',
  55. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  56. from: '+19195554321',
  57. to: '+19195551234',
  58. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  59. direction: Bandwidth::CallDirectionEnum::INBOUND,
  60. digit: '1',
  61. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  62. enqueuedTime: '2022-06-16T13:15:07.160Z',
  63. startTime: '2022-06-16T13:15:07.160Z',
  64. answerTime: '2022-06-16T13:15:18.126Z',
  65. parentCallId: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  66. transferCallerId: '+19195554321',
  67. transferTo: '+19195551234',
  68. tag: 'custom tag'
  69. })
  70. 1 expect(dtmf_callback_from_hash).to be_instance_of(Bandwidth::DtmfCallback)
  71. 1 expect(dtmf_callback_from_hash.event_type).to eq('dtmf')
  72. 1 expect(dtmf_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  73. 1 expect(dtmf_callback_from_hash.account_id).to eq('9900000')
  74. 1 expect(dtmf_callback_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f')
  75. 1 expect(dtmf_callback_from_hash.from).to eq('+19195554321')
  76. 1 expect(dtmf_callback_from_hash.to).to eq('+19195551234')
  77. 1 expect(dtmf_callback_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  78. 1 expect(dtmf_callback_from_hash.direction).to eq(Bandwidth::CallDirectionEnum::INBOUND)
  79. 1 expect(dtmf_callback_from_hash.digit).to eq('1')
  80. 1 expect(dtmf_callback_from_hash.call_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  81. 1 expect(dtmf_callback_from_hash.enqueued_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  82. 1 expect(dtmf_callback_from_hash.start_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  83. 1 expect(dtmf_callback_from_hash.answer_time).to eq(Time.parse('2022-06-16T13:15:18.126Z'))
  84. 1 expect(dtmf_callback_from_hash.parent_call_id).to eq('c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99')
  85. 1 expect(dtmf_callback_from_hash.transfer_caller_id).to eq('+19195554321')
  86. 1 expect(dtmf_callback_from_hash.transfer_to).to eq('+19195551234')
  87. 1 expect(dtmf_callback_from_hash.tag).to eq('custom tag')
  88. end
  89. end
  90. 1 describe '#to_s' do
  91. 1 it 'returns a string representation of the object' do
  92. 1 expect(dtmf_callback_values.to_s).to eq('{:eventType=>"dtmf", :eventTime=>"2022-06-16T13:15:07.160Z", :accountId=>"9900000", :applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :from=>"+19195554321", :to=>"+19195551234", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :direction=>"inbound", :digit=>"1", :callUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :enqueuedTime=>"2022-06-16T13:15:07.160Z", :startTime=>"2022-06-16T13:15:07.160Z", :answerTime=>"2022-06-16T13:15:18.126Z", :parentCallId=>"c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99", :transferCallerId=>"+19195554321", :transferTo=>"+19195551234", :tag=>"custom tag"}')
  93. end
  94. end
  95. 1 describe '#eq? #==' do
  96. 1 it 'returns true/false when comparing objects' do
  97. 1 expect(dtmf_callback_default.eql?(Bandwidth::DtmfCallback.new)).to be true
  98. 1 expect(dtmf_callback_default.eql?(dtmf_callback_values)).to be false
  99. end
  100. end
  101. 1 describe '#to_body #to_hash' do
  102. 1 it 'returns a hash representation of the object' do
  103. 1 expect(dtmf_callback_values.to_body).to eq({
  104. eventType: 'dtmf',
  105. eventTime: '2022-06-16T13:15:07.160Z',
  106. accountId: '9900000',
  107. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  108. from: '+19195554321',
  109. to: '+19195551234',
  110. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  111. direction: Bandwidth::CallDirectionEnum::INBOUND,
  112. digit: '1',
  113. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  114. enqueuedTime: '2022-06-16T13:15:07.160Z',
  115. startTime: '2022-06-16T13:15:07.160Z',
  116. answerTime: '2022-06-16T13:15:18.126Z',
  117. parentCallId: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  118. transferCallerId: '+19195554321',
  119. transferTo: '+19195551234',
  120. tag: 'custom tag'
  121. })
  122. end
  123. end
  124. end

spec/unit/models/endpoint_direction_enum_spec.rb

100.0% lines covered

19 relevant lines. 19 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::EndpointDirectionEnum
  2. 1 describe Bandwidth::EndpointDirectionEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines INBOUND' do
  5. 1 expect(Bandwidth::EndpointDirectionEnum::INBOUND).to eq('INBOUND')
  6. end
  7. 1 it 'defines OUTBOUND' do
  8. 1 expect(Bandwidth::EndpointDirectionEnum::OUTBOUND).to eq('OUTBOUND')
  9. end
  10. 1 it 'defines BIDIRECTIONAL' do
  11. 1 expect(Bandwidth::EndpointDirectionEnum::BIDIRECTIONAL).to eq('BIDIRECTIONAL')
  12. end
  13. end
  14. 1 describe '.all_vars' do
  15. 1 it 'returns every valid enum value' do
  16. 1 expect(Bandwidth::EndpointDirectionEnum.all_vars).to eq([
  17. 'INBOUND',
  18. 'OUTBOUND',
  19. 'BIDIRECTIONAL'
  20. ])
  21. end
  22. end
  23. 1 describe '.build_from_hash' do
  24. 1 it 'returns the value when it matches a valid enum value' do
  25. 1 expect(Bandwidth::EndpointDirectionEnum.build_from_hash('INBOUND')).to eq('INBOUND')
  26. 1 expect(Bandwidth::EndpointDirectionEnum.build_from_hash('OUTBOUND')).to eq('OUTBOUND')
  27. 1 expect(Bandwidth::EndpointDirectionEnum.build_from_hash('BIDIRECTIONAL')).to eq('BIDIRECTIONAL')
  28. end
  29. 1 it 'raises an error for an invalid enum value' do
  30. 1 expect {
  31. 1 Bandwidth::EndpointDirectionEnum.build_from_hash('invalid')
  32. }.to raise_error(RuntimeError)
  33. end
  34. end
  35. end

spec/unit/models/endpoint_event_spec.rb

100.0% lines covered

65 relevant lines. 65 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::EndpointEvent
  2. 1 describe Bandwidth::EndpointEvent do
  3. 2 let(:endpoint_event_default) { Bandwidth::EndpointEvent.new({
  4. endpoint_id: 'baseline-endpoint',
  5. type: 'WEBRTC',
  6. status: 'CONNECTED',
  7. creation_timestamp: '2022-06-16T13:15:07.160Z',
  8. expiration_timestamp: '2022-06-17T13:15:07.160Z',
  9. event_time: '2022-06-16T13:15:08.000Z',
  10. event_type: 'DEVICE_CONNECTED'
  11. }) }
  12. 4 let(:endpoint_event_values) { Bandwidth::EndpointEvent.new({
  13. endpoint_id: 'ep-abc-123',
  14. type: Bandwidth::EndpointTypeEnum::WEBRTC,
  15. status: Bandwidth::EndpointStatusEnum::CONNECTED,
  16. creation_timestamp: '2022-06-16T13:15:07.160Z',
  17. expiration_timestamp: '2022-06-17T13:15:07.160Z',
  18. tag: 'custom tag',
  19. event_time: '2022-06-16T13:15:08.000Z',
  20. event_type: Bandwidth::EndpointEventTypeEnum::DEVICE_CONNECTED,
  21. device: Bandwidth::Device.new({ device_id: 'd-1', status: 'CONNECTED', creation_timestamp: '2022-06-16T13:15:08.000Z' })
  22. }) }
  23. 1 describe '#initialize' do
  24. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  25. 1 expect {
  26. 1 Bandwidth::EndpointEvent.new([])
  27. }.to raise_error(ArgumentError)
  28. end
  29. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  30. 1 expect {
  31. 1 Bandwidth::EndpointEvent.new({ invalid: true })
  32. }.to raise_error(ArgumentError)
  33. end
  34. end
  35. 1 describe '#acceptable_attributes' do
  36. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  37. 1 expect(Bandwidth::EndpointEvent.acceptable_attributes).to eq(Bandwidth::EndpointEvent.attribute_map.values)
  38. end
  39. end
  40. 1 describe '#openapi_nullable' do
  41. 1 it 'expects nullable attributes to be an empty set' do
  42. 1 expect(Bandwidth::EndpointEvent.openapi_nullable).to eq(Set.new([]))
  43. end
  44. end
  45. 1 describe '#build_from_hash' do
  46. 1 it 'validates instance of EndpointEvent created by the build_from_hash method' do
  47. 1 endpoint_event_from_hash = Bandwidth::EndpointEvent.build_from_hash({
  48. endpointId: 'ep-abc-123',
  49. type: 'WEBRTC',
  50. status: 'CONNECTED',
  51. creationTimestamp: '2022-06-16T13:15:07.160Z',
  52. expirationTimestamp: '2022-06-17T13:15:07.160Z',
  53. tag: 'custom tag',
  54. eventTime: '2022-06-16T13:15:08.000Z',
  55. eventType: 'DEVICE_CONNECTED',
  56. device: { deviceId: 'd-1', status: 'CONNECTED', creationTimestamp: '2022-06-16T13:15:08.000Z' }
  57. })
  58. 1 expect(endpoint_event_from_hash).to be_instance_of(Bandwidth::EndpointEvent)
  59. 1 expect(endpoint_event_from_hash.endpoint_id).to eq('ep-abc-123')
  60. 1 expect(endpoint_event_from_hash.type).to eq(Bandwidth::EndpointTypeEnum::WEBRTC)
  61. 1 expect(endpoint_event_from_hash.status).to eq(Bandwidth::EndpointStatusEnum::CONNECTED)
  62. 1 expect(endpoint_event_from_hash.creation_timestamp).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  63. 1 expect(endpoint_event_from_hash.expiration_timestamp).to eq(Time.parse('2022-06-17T13:15:07.160Z'))
  64. 1 expect(endpoint_event_from_hash.tag).to eq('custom tag')
  65. 1 expect(endpoint_event_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:08.000Z'))
  66. 1 expect(endpoint_event_from_hash.event_type).to eq(Bandwidth::EndpointEventTypeEnum::DEVICE_CONNECTED)
  67. 1 expect(endpoint_event_from_hash.device).to be_instance_of(Bandwidth::Device)
  68. end
  69. end
  70. 1 describe '#to_s' do
  71. 1 it 'returns a string representation of the object' do
  72. 1 expect(endpoint_event_values.to_s).to eq('{:endpointId=>"ep-abc-123", :type=>"WEBRTC", :status=>"CONNECTED", :creationTimestamp=>"2022-06-16T13:15:07.160Z", :expirationTimestamp=>"2022-06-17T13:15:07.160Z", :tag=>"custom tag", :eventTime=>"2022-06-16T13:15:08.000Z", :eventType=>"DEVICE_CONNECTED", :device=>{:deviceId=>"d-1", :status=>"CONNECTED", :creationTimestamp=>"2022-06-16T13:15:08.000Z"}}')
  73. end
  74. end
  75. 1 describe '#eq? #==' do
  76. 1 it 'returns true/false when comparing objects' do
  77. 1 endpoint_event_equal = Bandwidth::EndpointEvent.new({
  78. endpoint_id: 'baseline-endpoint',
  79. type: 'WEBRTC',
  80. status: 'CONNECTED',
  81. creation_timestamp: '2022-06-16T13:15:07.160Z',
  82. expiration_timestamp: '2022-06-17T13:15:07.160Z',
  83. event_time: '2022-06-16T13:15:08.000Z',
  84. event_type: 'DEVICE_CONNECTED'
  85. })
  86. 1 expect(endpoint_event_default.eql?(endpoint_event_equal)).to be true
  87. 1 expect(endpoint_event_default.eql?(endpoint_event_values)).to be false
  88. end
  89. end
  90. 1 describe '#to_body #to_hash' do
  91. 1 it 'returns a hash representation of the object' do
  92. 1 expect(endpoint_event_values.to_body).to eq({
  93. endpointId: 'ep-abc-123',
  94. type: Bandwidth::EndpointTypeEnum::WEBRTC,
  95. status: Bandwidth::EndpointStatusEnum::CONNECTED,
  96. creationTimestamp: '2022-06-16T13:15:07.160Z',
  97. expirationTimestamp: '2022-06-17T13:15:07.160Z',
  98. tag: 'custom tag',
  99. eventTime: '2022-06-16T13:15:08.000Z',
  100. eventType: Bandwidth::EndpointEventTypeEnum::DEVICE_CONNECTED,
  101. device: { deviceId: 'd-1', status: 'CONNECTED', creationTimestamp: '2022-06-16T13:15:08.000Z' }
  102. })
  103. end
  104. end
  105. 1 describe 'custom attribute writers' do
  106. 1 it '#endpoint_id=' do
  107. 1 expect {
  108. 1 Bandwidth::EndpointEvent.new({ endpoint_id: nil, type: 'WEBRTC', status: 'CONNECTED', creation_timestamp: 'a', expiration_timestamp: 'a', event_time: 'a', event_type: 'DEVICE_CONNECTED' })
  109. }.to raise_error(ArgumentError, 'endpoint_id cannot be nil')
  110. end
  111. 1 it '#type=' do
  112. 1 expect {
  113. 1 Bandwidth::EndpointEvent.new({ endpoint_id: 'a', type: nil, status: 'CONNECTED', creation_timestamp: 'a', expiration_timestamp: 'a', event_time: 'a', event_type: 'DEVICE_CONNECTED' })
  114. }.to raise_error(ArgumentError, 'type cannot be nil')
  115. end
  116. 1 it '#status=' do
  117. 1 expect {
  118. 1 Bandwidth::EndpointEvent.new({ endpoint_id: 'a', type: 'WEBRTC', status: nil, creation_timestamp: 'a', expiration_timestamp: 'a', event_time: 'a', event_type: 'DEVICE_CONNECTED' })
  119. }.to raise_error(ArgumentError, 'status cannot be nil')
  120. end
  121. 1 it '#creation_timestamp=' do
  122. 1 expect {
  123. 1 Bandwidth::EndpointEvent.new({ endpoint_id: 'a', type: 'WEBRTC', status: 'CONNECTED', creation_timestamp: nil, expiration_timestamp: 'a', event_time: 'a', event_type: 'DEVICE_CONNECTED' })
  124. }.to raise_error(ArgumentError, 'creation_timestamp cannot be nil')
  125. end
  126. 1 it '#expiration_timestamp=' do
  127. 1 expect {
  128. 1 Bandwidth::EndpointEvent.new({ endpoint_id: 'a', type: 'WEBRTC', status: 'CONNECTED', creation_timestamp: 'a', expiration_timestamp: nil, event_time: 'a', event_type: 'DEVICE_CONNECTED' })
  129. }.to raise_error(ArgumentError, 'expiration_timestamp cannot be nil')
  130. end
  131. 1 it '#tag=' do
  132. 1 expect {
  133. 1 Bandwidth::EndpointEvent.new({ endpoint_id: 'a', type: 'WEBRTC', status: 'CONNECTED', creation_timestamp: 'a', expiration_timestamp: 'a', event_time: 'a', event_type: 'DEVICE_CONNECTED', tag: nil })
  134. }.to raise_error(ArgumentError, 'tag cannot be nil')
  135. end
  136. 1 it '#event_time=' do
  137. 1 expect {
  138. 1 Bandwidth::EndpointEvent.new({ endpoint_id: 'a', type: 'WEBRTC', status: 'CONNECTED', creation_timestamp: 'a', expiration_timestamp: 'a', event_time: nil, event_type: 'DEVICE_CONNECTED' })
  139. }.to raise_error(ArgumentError, 'event_time cannot be nil')
  140. end
  141. 1 it '#event_type=' do
  142. 1 expect {
  143. 1 Bandwidth::EndpointEvent.new({ endpoint_id: 'a', type: 'WEBRTC', status: 'CONNECTED', creation_timestamp: 'a', expiration_timestamp: 'a', event_time: 'a', event_type: nil })
  144. }.to raise_error(ArgumentError, 'event_type cannot be nil')
  145. end
  146. end
  147. end

spec/unit/models/endpoint_event_type_enum_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::EndpointEventTypeEnum
  2. 1 describe Bandwidth::EndpointEventTypeEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines DEVICE_CONNECTED' do
  5. 1 expect(Bandwidth::EndpointEventTypeEnum::DEVICE_CONNECTED).to eq('DEVICE_CONNECTED')
  6. end
  7. 1 it 'defines DEVICE_DISCONNECTED' do
  8. 1 expect(Bandwidth::EndpointEventTypeEnum::DEVICE_DISCONNECTED).to eq('DEVICE_DISCONNECTED')
  9. end
  10. end
  11. 1 describe '.all_vars' do
  12. 1 it 'returns every valid enum value' do
  13. 1 expect(Bandwidth::EndpointEventTypeEnum.all_vars).to eq([
  14. 'DEVICE_CONNECTED',
  15. 'DEVICE_DISCONNECTED'
  16. ])
  17. end
  18. end
  19. 1 describe '.build_from_hash' do
  20. 1 it 'returns the value when it matches a valid enum value' do
  21. 1 expect(Bandwidth::EndpointEventTypeEnum.build_from_hash('DEVICE_CONNECTED')).to eq('DEVICE_CONNECTED')
  22. 1 expect(Bandwidth::EndpointEventTypeEnum.build_from_hash('DEVICE_DISCONNECTED')).to eq('DEVICE_DISCONNECTED')
  23. end
  24. 1 it 'raises an error for an invalid enum value' do
  25. 1 expect {
  26. 1 Bandwidth::EndpointEventTypeEnum.build_from_hash('invalid')
  27. }.to raise_error(RuntimeError)
  28. end
  29. end
  30. end

spec/unit/models/endpoint_response_spec.rb

100.0% lines covered

45 relevant lines. 45 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::EndpointResponse
  2. 1 describe Bandwidth::EndpointResponse do
  3. 7 let(:endpoint_data) { Bandwidth::Endpoint.new({
  4. endpoint_id: 'abc123',
  5. type: 'WEBRTC',
  6. status: 'CONNECTED',
  7. creation_timestamp: '2024-01-01T00:00:00Z',
  8. expiration_timestamp: '2024-01-02T00:00:00Z'
  9. }) }
  10. 2 let(:endpoint_response_default) { Bandwidth::EndpointResponse.new({
  11. links: [],
  12. data: endpoint_data,
  13. errors: []
  14. }) }
  15. 7 let(:endpoint_response_values) { Bandwidth::EndpointResponse.new({
  16. links: [Bandwidth::BrtcLink.new({ href: 'https://example.com', rel: 'self', method: 'GET' })],
  17. data: endpoint_data,
  18. errors: [Bandwidth::BrtcError.new({ type: 'validation', description: 'bad input' })]
  19. }) }
  20. 1 describe '#initialize' do
  21. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  22. 1 expect {
  23. 1 Bandwidth::EndpointResponse.new([])
  24. }.to raise_error(ArgumentError)
  25. end
  26. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  27. 1 expect {
  28. 1 Bandwidth::EndpointResponse.new({ invalid: true })
  29. }.to raise_error(ArgumentError)
  30. end
  31. end
  32. 1 describe '#acceptable_attributes' do
  33. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  34. 1 expect(Bandwidth::EndpointResponse.acceptable_attributes).to eq(Bandwidth::EndpointResponse.attribute_map.values)
  35. end
  36. end
  37. 1 describe '#openapi_nullable' do
  38. 1 it 'expects nullable attributes to be an empty set' do
  39. 1 expect(Bandwidth::EndpointResponse.openapi_nullable).to eq(Set.new([]))
  40. end
  41. end
  42. 1 describe '#build_from_hash' do
  43. 1 it 'validates instance of EndpointResponse created by the build_from_hash method' do
  44. 1 endpoint_response_from_hash = Bandwidth::EndpointResponse.build_from_hash({
  45. links: [{ href: 'https://example.com', rel: 'self', method: 'GET' }],
  46. data: { endpointId: 'abc123', type: 'WEBRTC', status: 'CONNECTED', creationTimestamp: '2024-01-01T00:00:00Z', expirationTimestamp: '2024-01-02T00:00:00Z' },
  47. errors: [{ type: 'validation', description: 'bad input' }]
  48. })
  49. 1 expect(endpoint_response_from_hash).to be_instance_of(Bandwidth::EndpointResponse)
  50. 1 expect(endpoint_response_from_hash.links.first).to be_instance_of(Bandwidth::BrtcLink)
  51. 1 expect(endpoint_response_from_hash.data).to be_instance_of(Bandwidth::Endpoint)
  52. 1 expect(endpoint_response_from_hash.errors.first).to be_instance_of(Bandwidth::BrtcError)
  53. end
  54. end
  55. 1 describe '#to_s' do
  56. 1 it 'returns a string representation of the object' do
  57. 1 expect(endpoint_response_values.to_s).to eq('{:links=>[{:href=>"https://example.com", :rel=>"self", :method=>"GET"}], :data=>{:endpointId=>"abc123", :type=>"WEBRTC", :status=>"CONNECTED", :creationTimestamp=>"2024-01-01T00:00:00Z", :expirationTimestamp=>"2024-01-02T00:00:00Z"}, :errors=>[{:type=>"validation", :description=>"bad input"}]}')
  58. end
  59. end
  60. 1 describe '#eq? #==' do
  61. 1 it 'returns true/false when comparing objects' do
  62. 1 endpoint_response_equal = Bandwidth::EndpointResponse.new({
  63. links: [],
  64. data: endpoint_data,
  65. errors: []
  66. })
  67. 1 expect(endpoint_response_default.eql?(endpoint_response_equal)).to be true
  68. 1 expect(endpoint_response_default.eql?(endpoint_response_values)).to be false
  69. end
  70. end
  71. 1 describe '#to_body #to_hash' do
  72. 1 it 'returns a hash representation of the object' do
  73. 1 expect(endpoint_response_values.to_body).to eq({
  74. links: [{ href: 'https://example.com', rel: 'self', method: 'GET' }],
  75. data: { endpointId: 'abc123', type: 'WEBRTC', status: 'CONNECTED', creationTimestamp: '2024-01-01T00:00:00Z', expirationTimestamp: '2024-01-02T00:00:00Z' },
  76. errors: [{ type: 'validation', description: 'bad input' }]
  77. })
  78. end
  79. end
  80. 1 describe 'custom attribute writers' do
  81. 1 it '#links=' do
  82. 1 expect {
  83. 1 endpoint_response_values.links = nil
  84. }.to raise_error(ArgumentError, 'links cannot be nil')
  85. end
  86. 1 it '#data=' do
  87. 1 expect {
  88. 1 endpoint_response_values.data = nil
  89. }.to raise_error(ArgumentError, 'data cannot be nil')
  90. end
  91. 1 it '#errors=' do
  92. 1 expect {
  93. 1 endpoint_response_values.errors = nil
  94. }.to raise_error(ArgumentError, 'errors cannot be nil')
  95. end
  96. end
  97. end

spec/unit/models/endpoint_spec.rb

100.0% lines covered

58 relevant lines. 58 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Endpoint
  2. 1 describe Bandwidth::Endpoint do
  3. 2 let(:endpoint_default) { Bandwidth::Endpoint.new({
  4. endpoint_id: 'endpoint-1',
  5. type: Bandwidth::EndpointTypeEnum::WEBRTC,
  6. status: Bandwidth::EndpointStatusEnum::CONNECTED,
  7. creation_timestamp: '2024-01-01T00:00:00Z',
  8. expiration_timestamp: '2024-01-02T00:00:00Z'
  9. }) }
  10. 5 let(:endpoint_values) { Bandwidth::Endpoint.new({
  11. endpoint_id: 'endpoint-2',
  12. type: Bandwidth::EndpointTypeEnum::WEBRTC,
  13. status: Bandwidth::EndpointStatusEnum::DISCONNECTED,
  14. creation_timestamp: '2024-02-01T00:00:00Z',
  15. expiration_timestamp: '2024-02-02T00:00:00Z',
  16. tag: 'custom tag',
  17. devices: [{ device_id: 'device-1', device_name: 'Phone', status: 'CONNECTED', creation_timestamp: '2024-02-01T00:00:00Z' }]
  18. }) }
  19. 1 describe '#initialize' do
  20. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  21. 1 expect {
  22. 1 Bandwidth::Endpoint.new([])
  23. }.to raise_error(ArgumentError)
  24. end
  25. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  26. 1 expect {
  27. 1 Bandwidth::Endpoint.new({ invalid: true })
  28. }.to raise_error(ArgumentError)
  29. end
  30. end
  31. 1 describe '#acceptable_attributes' do
  32. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  33. 1 expect(Bandwidth::Endpoint.acceptable_attributes).to eq(Bandwidth::Endpoint.attribute_map.values)
  34. end
  35. end
  36. 1 describe '#openapi_nullable' do
  37. 1 it 'expects nullable attributes to be an empty set' do
  38. 1 expect(Bandwidth::Endpoint.openapi_nullable).to eq(Set.new([]))
  39. end
  40. end
  41. 1 describe '#build_from_hash' do
  42. 1 it 'validates instance of Endpoint created by the build_from_hash method' do
  43. 1 endpoint_from_hash = Bandwidth::Endpoint.build_from_hash({
  44. endpointId: 'endpoint-2',
  45. type: Bandwidth::EndpointTypeEnum::WEBRTC,
  46. status: Bandwidth::EndpointStatusEnum::DISCONNECTED,
  47. creationTimestamp: '2024-02-01T00:00:00Z',
  48. expirationTimestamp: '2024-02-02T00:00:00Z',
  49. tag: 'custom tag',
  50. devices: [{ deviceId: 'device-1', deviceName: 'Phone', status: 'CONNECTED', creationTimestamp: '2024-02-01T00:00:00Z' }]
  51. })
  52. 1 expect(endpoint_from_hash).to be_instance_of(Bandwidth::Endpoint)
  53. 1 expect(endpoint_from_hash.endpoint_id).to eq('endpoint-2')
  54. 1 expect(endpoint_from_hash.type).to eq(Bandwidth::EndpointTypeEnum::WEBRTC)
  55. 1 expect(endpoint_from_hash.status).to eq(Bandwidth::EndpointStatusEnum::DISCONNECTED)
  56. 1 expect(endpoint_from_hash.creation_timestamp).to eq(Time.parse('2024-02-01T00:00:00Z'))
  57. 1 expect(endpoint_from_hash.expiration_timestamp).to eq(Time.parse('2024-02-02T00:00:00Z'))
  58. 1 expect(endpoint_from_hash.tag).to eq('custom tag')
  59. 1 expect(endpoint_from_hash.devices).to be_instance_of(Array)
  60. 1 expect(endpoint_from_hash.devices.first).to be_instance_of(Bandwidth::Device)
  61. end
  62. end
  63. 1 describe '#to_s' do
  64. 1 it 'returns a string representation of the object' do
  65. 1 expect(endpoint_values.to_s).to eq('{:endpointId=>"endpoint-2", :type=>"WEBRTC", :status=>"DISCONNECTED", :creationTimestamp=>"2024-02-01T00:00:00Z", :expirationTimestamp=>"2024-02-02T00:00:00Z", :tag=>"custom tag", :devices=>[{:device_id=>"device-1", :device_name=>"Phone", :status=>"CONNECTED", :creation_timestamp=>"2024-02-01T00:00:00Z"}]}')
  66. end
  67. end
  68. 1 describe '#eq? #==' do
  69. 1 it 'returns true/false when comparing objects' do
  70. 1 endpoint_equal = Bandwidth::Endpoint.new({
  71. endpoint_id: 'endpoint-1',
  72. type: Bandwidth::EndpointTypeEnum::WEBRTC,
  73. status: Bandwidth::EndpointStatusEnum::CONNECTED,
  74. creation_timestamp: '2024-01-01T00:00:00Z',
  75. expiration_timestamp: '2024-01-02T00:00:00Z'
  76. })
  77. 1 expect(endpoint_default.eql?(endpoint_equal)).to be true
  78. 1 expect(endpoint_default.eql?(endpoint_values)).to be false
  79. end
  80. end
  81. 1 describe '#to_body #to_hash' do
  82. 1 it 'returns a hash representation of the object' do
  83. 1 expect(endpoint_values.to_body).to eq({
  84. endpointId: 'endpoint-2',
  85. type: Bandwidth::EndpointTypeEnum::WEBRTC,
  86. status: Bandwidth::EndpointStatusEnum::DISCONNECTED,
  87. creationTimestamp: '2024-02-01T00:00:00Z',
  88. expirationTimestamp: '2024-02-02T00:00:00Z',
  89. tag: 'custom tag',
  90. devices: [{ device_id: 'device-1', device_name: 'Phone', status: 'CONNECTED', creation_timestamp: '2024-02-01T00:00:00Z' }]
  91. })
  92. end
  93. end
  94. 1 describe 'custom attribute writers' do
  95. 1 it '#endpoint_id=' do
  96. 1 expect {
  97. 1 Bandwidth::Endpoint.new({ endpoint_id: nil })
  98. }.to raise_error(ArgumentError, 'endpoint_id cannot be nil')
  99. end
  100. 1 it '#type=' do
  101. 1 expect {
  102. 1 Bandwidth::Endpoint.new({ endpoint_id: 'endpoint-1', type: nil })
  103. }.to raise_error(ArgumentError, 'type cannot be nil')
  104. end
  105. 1 it '#status=' do
  106. 1 expect {
  107. 1 Bandwidth::Endpoint.new({ endpoint_id: 'endpoint-1', type: Bandwidth::EndpointTypeEnum::WEBRTC, status: nil })
  108. }.to raise_error(ArgumentError, 'status cannot be nil')
  109. end
  110. 1 it '#creation_timestamp=' do
  111. 1 expect {
  112. 1 Bandwidth::Endpoint.new({ endpoint_id: 'endpoint-1', type: Bandwidth::EndpointTypeEnum::WEBRTC, status: Bandwidth::EndpointStatusEnum::CONNECTED, creation_timestamp: nil })
  113. }.to raise_error(ArgumentError, 'creation_timestamp cannot be nil')
  114. end
  115. 1 it '#expiration_timestamp=' do
  116. 1 expect {
  117. 1 Bandwidth::Endpoint.new({ endpoint_id: 'endpoint-1', type: Bandwidth::EndpointTypeEnum::WEBRTC, status: Bandwidth::EndpointStatusEnum::CONNECTED, creation_timestamp: '2024-01-01T00:00:00Z', expiration_timestamp: nil })
  118. }.to raise_error(ArgumentError, 'expiration_timestamp cannot be nil')
  119. end
  120. 1 it '#tag=' do
  121. 1 expect {
  122. 1 endpoint_values.tag = nil
  123. }.to raise_error(ArgumentError, 'tag cannot be nil')
  124. end
  125. end
  126. end

spec/unit/models/endpoint_status_enum_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::EndpointStatusEnum
  2. 1 describe Bandwidth::EndpointStatusEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines CONNECTED' do
  5. 1 expect(Bandwidth::EndpointStatusEnum::CONNECTED).to eq('CONNECTED')
  6. end
  7. 1 it 'defines DISCONNECTED' do
  8. 1 expect(Bandwidth::EndpointStatusEnum::DISCONNECTED).to eq('DISCONNECTED')
  9. end
  10. end
  11. 1 describe '.all_vars' do
  12. 1 it 'returns every valid enum value' do
  13. 1 expect(Bandwidth::EndpointStatusEnum.all_vars).to eq([
  14. 'CONNECTED',
  15. 'DISCONNECTED'
  16. ])
  17. end
  18. end
  19. 1 describe '.build_from_hash' do
  20. 1 it 'returns the value when it matches a valid enum value' do
  21. 1 expect(Bandwidth::EndpointStatusEnum.build_from_hash('CONNECTED')).to eq('CONNECTED')
  22. 1 expect(Bandwidth::EndpointStatusEnum.build_from_hash('DISCONNECTED')).to eq('DISCONNECTED')
  23. end
  24. 1 it 'raises an error for an invalid enum value' do
  25. 1 expect {
  26. 1 Bandwidth::EndpointStatusEnum.build_from_hash('invalid')
  27. }.to raise_error(RuntimeError)
  28. end
  29. end
  30. end

spec/unit/models/endpoint_type_enum_spec.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::EndpointTypeEnum
  2. 1 describe Bandwidth::EndpointTypeEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines WEBRTC' do
  5. 1 expect(Bandwidth::EndpointTypeEnum::WEBRTC).to eq('WEBRTC')
  6. end
  7. end
  8. 1 describe '.all_vars' do
  9. 1 it 'returns every valid enum value' do
  10. 1 expect(Bandwidth::EndpointTypeEnum.all_vars).to eq([
  11. 'WEBRTC'
  12. ])
  13. end
  14. end
  15. 1 describe '.build_from_hash' do
  16. 1 it 'returns the value when it matches a valid enum value' do
  17. 1 expect(Bandwidth::EndpointTypeEnum.build_from_hash('WEBRTC')).to eq('WEBRTC')
  18. end
  19. 1 it 'raises an error for an invalid enum value' do
  20. 1 expect {
  21. 1 Bandwidth::EndpointTypeEnum.build_from_hash('invalid')
  22. }.to raise_error(RuntimeError)
  23. end
  24. end
  25. end

spec/unit/models/endpoints_spec.rb

100.0% lines covered

56 relevant lines. 56 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Endpoints
  2. 1 describe Bandwidth::Endpoints do
  3. 2 let(:endpoints_default) { Bandwidth::Endpoints.new({
  4. endpoint_id: 'baseline',
  5. type: 'WEBRTC',
  6. status: 'CONNECTED',
  7. creation_timestamp: '2024-01-01T00:00:00Z',
  8. expiration_timestamp: '2024-01-02T00:00:00Z'
  9. }) }
  10. 5 let(:endpoints_values) { Bandwidth::Endpoints.new({
  11. endpoint_id: 'abc123',
  12. type: 'WEBRTC',
  13. status: 'CONNECTED',
  14. creation_timestamp: '2024-01-01T00:00:00Z',
  15. expiration_timestamp: '2024-01-02T00:00:00Z',
  16. tag: 'custom tag'
  17. }) }
  18. 1 describe '#initialize' do
  19. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  20. 1 expect {
  21. 1 Bandwidth::Endpoints.new([])
  22. }.to raise_error(ArgumentError)
  23. end
  24. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  25. 1 expect {
  26. 1 Bandwidth::Endpoints.new({ invalid: true })
  27. }.to raise_error(ArgumentError)
  28. end
  29. end
  30. 1 describe '#acceptable_attributes' do
  31. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  32. 1 expect(Bandwidth::Endpoints.acceptable_attributes).to eq(Bandwidth::Endpoints.attribute_map.values)
  33. end
  34. end
  35. 1 describe '#openapi_nullable' do
  36. 1 it 'expects nullable attributes to be an empty set' do
  37. 1 expect(Bandwidth::Endpoints.openapi_nullable).to eq(Set.new([]))
  38. end
  39. end
  40. 1 describe '#build_from_hash' do
  41. 1 it 'validates instance of Endpoints created by the build_from_hash method' do
  42. 1 endpoints_from_hash = Bandwidth::Endpoints.build_from_hash({
  43. endpointId: 'abc123',
  44. type: 'WEBRTC',
  45. status: 'CONNECTED',
  46. creationTimestamp: '2024-01-01T00:00:00Z',
  47. expirationTimestamp: '2024-01-02T00:00:00Z',
  48. tag: 'custom tag'
  49. })
  50. 1 expect(endpoints_from_hash).to be_instance_of(Bandwidth::Endpoints)
  51. 1 expect(endpoints_from_hash.endpoint_id).to eq('abc123')
  52. 1 expect(endpoints_from_hash.type).to eq('WEBRTC')
  53. 1 expect(endpoints_from_hash.status).to eq('CONNECTED')
  54. 1 expect(endpoints_from_hash.creation_timestamp).to eq(Time.parse('2024-01-01T00:00:00Z'))
  55. 1 expect(endpoints_from_hash.expiration_timestamp).to eq(Time.parse('2024-01-02T00:00:00Z'))
  56. 1 expect(endpoints_from_hash.tag).to eq('custom tag')
  57. end
  58. end
  59. 1 describe '#to_s' do
  60. 1 it 'returns a string representation of the object' do
  61. 1 expect(endpoints_values.to_s).to eq('{:endpointId=>"abc123", :type=>"WEBRTC", :status=>"CONNECTED", :creationTimestamp=>"2024-01-01T00:00:00Z", :expirationTimestamp=>"2024-01-02T00:00:00Z", :tag=>"custom tag"}')
  62. end
  63. end
  64. 1 describe '#eq? #==' do
  65. 1 it 'returns true/false when comparing objects' do
  66. 1 endpoints_equal = Bandwidth::Endpoints.new({
  67. endpoint_id: 'baseline',
  68. type: 'WEBRTC',
  69. status: 'CONNECTED',
  70. creation_timestamp: '2024-01-01T00:00:00Z',
  71. expiration_timestamp: '2024-01-02T00:00:00Z'
  72. })
  73. 1 expect(endpoints_default.eql?(endpoints_equal)).to be true
  74. 1 expect(endpoints_default.eql?(endpoints_values)).to be false
  75. end
  76. end
  77. 1 describe '#to_body #to_hash' do
  78. 1 it 'returns a hash representation of the object' do
  79. 1 expect(endpoints_values.to_body).to eq({
  80. endpointId: 'abc123',
  81. type: 'WEBRTC',
  82. status: 'CONNECTED',
  83. creationTimestamp: '2024-01-01T00:00:00Z',
  84. expirationTimestamp: '2024-01-02T00:00:00Z',
  85. tag: 'custom tag'
  86. })
  87. end
  88. end
  89. 1 describe 'custom attribute writers' do
  90. 1 it '#endpoint_id=' do
  91. 1 expect {
  92. 1 Bandwidth::Endpoints.new({ endpoint_id: nil })
  93. }.to raise_error(ArgumentError, 'endpoint_id cannot be nil')
  94. end
  95. 1 it '#type=' do
  96. 1 expect {
  97. 1 Bandwidth::Endpoints.new({ endpoint_id: 'a', type: nil })
  98. }.to raise_error(ArgumentError, 'type cannot be nil')
  99. end
  100. 1 it '#status=' do
  101. 1 expect {
  102. 1 Bandwidth::Endpoints.new({ endpoint_id: 'a', type: 'WEBRTC', status: nil })
  103. }.to raise_error(ArgumentError, 'status cannot be nil')
  104. end
  105. 1 it '#creation_timestamp=' do
  106. 1 expect {
  107. 1 Bandwidth::Endpoints.new({ endpoint_id: 'a', type: 'WEBRTC', status: 'CONNECTED', creation_timestamp: nil })
  108. }.to raise_error(ArgumentError, 'creation_timestamp cannot be nil')
  109. end
  110. 1 it '#expiration_timestamp=' do
  111. 1 expect {
  112. 1 Bandwidth::Endpoints.new({ endpoint_id: 'a', type: 'WEBRTC', status: 'CONNECTED', creation_timestamp: '2024-01-01T00:00:00Z', expiration_timestamp: nil })
  113. }.to raise_error(ArgumentError, 'expiration_timestamp cannot be nil')
  114. end
  115. 1 it '#tag=' do
  116. 1 expect {
  117. 1 endpoints_values.tag = nil
  118. }.to raise_error(ArgumentError, 'tag cannot be nil')
  119. end
  120. end
  121. end

spec/unit/models/error_object_spec.rb

100.0% lines covered

46 relevant lines. 46 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::ErrorObject
  2. 1 describe Bandwidth::ErrorObject do
  3. 4 let(:error_source) { Bandwidth::ErrorSource.new({ field: 'phoneNumber' }) }
  4. 2 let(:error_object_default) { Bandwidth::ErrorObject.new({
  5. type: 'baseline',
  6. description: 'baseline description',
  7. source: error_source
  8. }) }
  9. 4 let(:error_object_values) { Bandwidth::ErrorObject.new({
  10. type: 'validation',
  11. description: 'bad input',
  12. source: error_source
  13. }) }
  14. 1 describe '#initialize' do
  15. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::ErrorObject.new([])
  18. }.to raise_error(ArgumentError)
  19. end
  20. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  21. 1 expect {
  22. 1 Bandwidth::ErrorObject.new({ invalid: true })
  23. }.to raise_error(ArgumentError)
  24. end
  25. end
  26. 1 describe '#acceptable_attributes' do
  27. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  28. 1 expect(Bandwidth::ErrorObject.acceptable_attributes).to eq(Bandwidth::ErrorObject.attribute_map.values)
  29. end
  30. end
  31. 1 describe '#openapi_nullable' do
  32. 1 it 'expects nullable attributes to be an empty set' do
  33. 1 expect(Bandwidth::ErrorObject.openapi_nullable).to eq(Set.new([]))
  34. end
  35. end
  36. 1 describe '#build_from_hash' do
  37. 1 it 'validates instance of ErrorObject created by the build_from_hash method' do
  38. 1 error_object_from_hash = Bandwidth::ErrorObject.build_from_hash({
  39. type: 'validation',
  40. description: 'bad input',
  41. source: { field: 'phoneNumber' }
  42. })
  43. 1 expect(error_object_from_hash).to be_instance_of(Bandwidth::ErrorObject)
  44. 1 expect(error_object_from_hash.type).to eq('validation')
  45. 1 expect(error_object_from_hash.description).to eq('bad input')
  46. 1 expect(error_object_from_hash.source).to be_instance_of(Bandwidth::ErrorSource)
  47. 1 expect(error_object_from_hash.source.field).to eq('phoneNumber')
  48. end
  49. end
  50. 1 describe '#to_s' do
  51. 1 it 'returns a string representation of the object' do
  52. 1 expect(error_object_values.to_s).to eq('{:type=>"validation", :description=>"bad input", :source=>{:field=>"phoneNumber"}}')
  53. end
  54. end
  55. 1 describe '#eq? #==' do
  56. 1 it 'returns true/false when comparing objects' do
  57. 1 error_object_equal = Bandwidth::ErrorObject.new({
  58. type: 'baseline',
  59. description: 'baseline description',
  60. source: error_source
  61. })
  62. 1 expect(error_object_default.eql?(error_object_equal)).to be true
  63. 1 expect(error_object_default.eql?(error_object_values)).to be false
  64. end
  65. end
  66. 1 describe '#to_body #to_hash' do
  67. 1 it 'returns a hash representation of the object' do
  68. 1 expect(error_object_values.to_body).to eq({
  69. type: 'validation',
  70. description: 'bad input',
  71. source: { field: 'phoneNumber' }
  72. })
  73. end
  74. end
  75. 1 describe 'custom attribute writers' do
  76. 1 it '#type=' do
  77. 1 expect {
  78. 1 Bandwidth::ErrorObject.new({ type: nil })
  79. }.to raise_error(ArgumentError, 'type cannot be nil')
  80. end
  81. 1 it '#description=' do
  82. 1 expect {
  83. 1 Bandwidth::ErrorObject.new({ type: 'a', description: nil })
  84. }.to raise_error(ArgumentError, 'description cannot be nil')
  85. end
  86. 1 it '#source=' do
  87. 1 expect {
  88. 1 Bandwidth::ErrorObject.new({ type: 'a', description: 'b', source: nil })
  89. }.to raise_error(ArgumentError, 'source cannot be nil')
  90. end
  91. end
  92. end

spec/unit/models/error_source_spec.rb

100.0% lines covered

34 relevant lines. 34 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::ErrorSource
  2. 1 describe Bandwidth::ErrorSource do
  3. 2 let(:error_source_default) { Bandwidth::ErrorSource.new }
  4. 4 let(:error_source_values) { Bandwidth::ErrorSource.new({
  5. parameter: 'phoneNumber',
  6. field: 'to',
  7. header: 'X-Request-Id',
  8. reference: '/messages/123'
  9. }) }
  10. 1 describe '#initialize' do
  11. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  12. 1 expect {
  13. 1 Bandwidth::ErrorSource.new([])
  14. }.to raise_error(ArgumentError)
  15. end
  16. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  17. 1 expect {
  18. 1 Bandwidth::ErrorSource.new({ invalid: true })
  19. }.to raise_error(ArgumentError)
  20. end
  21. end
  22. 1 describe '#acceptable_attributes' do
  23. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  24. 1 expect(Bandwidth::ErrorSource.acceptable_attributes).to eq(Bandwidth::ErrorSource.attribute_map.values)
  25. end
  26. end
  27. 1 describe '#openapi_nullable' do
  28. 1 it 'expects nullable attributes to be an empty set' do
  29. 1 expect(Bandwidth::ErrorSource.openapi_nullable).to eq(Set.new([]))
  30. end
  31. end
  32. 1 describe '#build_from_hash' do
  33. 1 it 'validates instance of ErrorSource created by the build_from_hash method' do
  34. 1 error_source_from_hash = Bandwidth::ErrorSource.build_from_hash({
  35. parameter: 'phoneNumber',
  36. field: 'to',
  37. header: 'X-Request-Id',
  38. reference: '/messages/123'
  39. })
  40. 1 expect(error_source_from_hash).to be_instance_of(Bandwidth::ErrorSource)
  41. 1 expect(error_source_from_hash.parameter).to eq('phoneNumber')
  42. 1 expect(error_source_from_hash.field).to eq('to')
  43. 1 expect(error_source_from_hash.header).to eq('X-Request-Id')
  44. 1 expect(error_source_from_hash.reference).to eq('/messages/123')
  45. end
  46. end
  47. 1 describe '#to_s' do
  48. 1 it 'returns a string representation of the object' do
  49. 1 expect(error_source_values.to_s).to eq('{:parameter=>"phoneNumber", :field=>"to", :header=>"X-Request-Id", :reference=>"/messages/123"}')
  50. end
  51. end
  52. 1 describe '#eq? #==' do
  53. 1 it 'returns true/false when comparing objects' do
  54. 1 expect(error_source_default.eql?(Bandwidth::ErrorSource.new)).to be true
  55. 1 expect(error_source_default.eql?(error_source_values)).to be false
  56. end
  57. end
  58. 1 describe '#to_body #to_hash' do
  59. 1 it 'returns a hash representation of the object' do
  60. 1 expect(error_source_values.to_body).to eq({
  61. parameter: 'phoneNumber',
  62. field: 'to',
  63. header: 'X-Request-Id',
  64. reference: '/messages/123'
  65. })
  66. end
  67. end
  68. end

spec/unit/models/failure_webhook_spec.rb

100.0% lines covered

46 relevant lines. 46 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::FailureWebhook
  2. 1 describe Bandwidth::FailureWebhook do
  3. 2 let(:failure_webhook_default) { Bandwidth::FailureWebhook.new }
  4. 4 let(:failure_webhook_values) { Bandwidth::FailureWebhook.new({
  5. account_id: '9900000',
  6. phone_number: '+18005551234',
  7. error_code: '400',
  8. error_message: 'bad request',
  9. errors: ['missing field'],
  10. internal_ticket_number: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
  11. }) }
  12. 1 describe '#initialize' do
  13. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  14. 1 expect {
  15. 1 Bandwidth::FailureWebhook.new([])
  16. }.to raise_error(ArgumentError)
  17. end
  18. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  19. 1 expect {
  20. 1 Bandwidth::FailureWebhook.new({ invalid: true })
  21. }.to raise_error(ArgumentError)
  22. end
  23. end
  24. 1 describe '#acceptable_attributes' do
  25. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  26. 1 expect(Bandwidth::FailureWebhook.acceptable_attributes).to eq(Bandwidth::FailureWebhook.attribute_map.values)
  27. end
  28. end
  29. 1 describe '#openapi_nullable' do
  30. 1 it 'expects nullable attributes to be an empty set' do
  31. 1 expect(Bandwidth::FailureWebhook.openapi_nullable).to eq(Set.new([]))
  32. end
  33. end
  34. 1 describe '#build_from_hash' do
  35. 1 it 'validates instance of FailureWebhook created by the build_from_hash method' do
  36. 1 failure_webhook_from_hash = Bandwidth::FailureWebhook.build_from_hash({
  37. accountId: '9900000',
  38. phoneNumber: '+18005551234',
  39. errorCode: '400',
  40. errorMessage: 'bad request',
  41. errors: ['missing field'],
  42. internalTicketNumber: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
  43. })
  44. 1 expect(failure_webhook_from_hash).to be_instance_of(Bandwidth::FailureWebhook)
  45. 1 expect(failure_webhook_from_hash.account_id).to eq('9900000')
  46. 1 expect(failure_webhook_from_hash.phone_number).to eq('+18005551234')
  47. 1 expect(failure_webhook_from_hash.error_code).to eq('400')
  48. 1 expect(failure_webhook_from_hash.error_message).to eq('bad request')
  49. 1 expect(failure_webhook_from_hash.errors).to eq(['missing field'])
  50. 1 expect(failure_webhook_from_hash.internal_ticket_number).to eq('aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee')
  51. end
  52. end
  53. 1 describe '#to_s' do
  54. 1 it 'returns a string representation of the object' do
  55. 1 expect(failure_webhook_values.to_s).to eq('{:accountId=>"9900000", :phoneNumber=>"+18005551234", :errorCode=>"400", :errorMessage=>"bad request", :errors=>["missing field"], :internalTicketNumber=>"aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"}')
  56. end
  57. end
  58. 1 describe '#eq? #==' do
  59. 1 it 'returns true/false when comparing objects' do
  60. 1 expect(failure_webhook_default.eql?(Bandwidth::FailureWebhook.new)).to be true
  61. 1 expect(failure_webhook_default.eql?(failure_webhook_values)).to be false
  62. end
  63. end
  64. 1 describe '#to_body #to_hash' do
  65. 1 it 'returns a hash representation of the object' do
  66. 1 expect(failure_webhook_values.to_body).to eq({
  67. accountId: '9900000',
  68. phoneNumber: '+18005551234',
  69. errorCode: '400',
  70. errorMessage: 'bad request',
  71. errors: ['missing field'],
  72. internalTicketNumber: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
  73. })
  74. end
  75. end
  76. 1 describe 'custom attribute writers' do
  77. 1 it '#phone_number=' do
  78. 1 expect {
  79. 1 Bandwidth::FailureWebhook.new({ phone_number: nil })
  80. }.to raise_error(ArgumentError, 'phone_number cannot be nil')
  81. 1 expect {
  82. 1 Bandwidth::FailureWebhook.new({ phone_number: '+1800555123456' })
  83. }.to raise_error(ArgumentError, 'invalid value for "phone_number", the character length must be smaller than or equal to 12.')
  84. 1 expect {
  85. 1 Bandwidth::FailureWebhook.new({ phone_number: '+1800555' })
  86. }.to raise_error(ArgumentError, 'invalid value for "phone_number", the character length must be greater than or equal to 12.')
  87. 1 expect {
  88. 1 Bandwidth::FailureWebhook.new({ phone_number: '+19195551234' })
  89. }.to raise_error(ArgumentError, 'invalid value for "phone_number", must conform to the pattern (?-mix:^\+1(800|833|844|855|866|877|888)[2-9]\d{6}$).')
  90. end
  91. end
  92. end

spec/unit/models/field_error_spec.rb

100.0% lines covered

32 relevant lines. 32 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::FieldError
  2. 1 describe Bandwidth::FieldError do
  3. 2 let(:field_error_default) { Bandwidth::FieldError.new }
  4. 4 let(:field_error_values) { Bandwidth::FieldError.new({
  5. field_name: 'to',
  6. description: 'invalid phone number'
  7. }) }
  8. 1 describe '#initialize' do
  9. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  10. 1 expect {
  11. 1 Bandwidth::FieldError.new([])
  12. }.to raise_error(ArgumentError)
  13. end
  14. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  15. 1 expect {
  16. 1 Bandwidth::FieldError.new({ invalid: true })
  17. }.to raise_error(ArgumentError)
  18. end
  19. end
  20. 1 describe '#acceptable_attributes' do
  21. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  22. 1 expect(Bandwidth::FieldError.acceptable_attributes).to eq(Bandwidth::FieldError.attribute_map.values)
  23. end
  24. end
  25. 1 describe '#openapi_nullable' do
  26. 1 it 'expects nullable attributes to be an empty set' do
  27. 1 expect(Bandwidth::FieldError.openapi_nullable).to eq(Set.new([]))
  28. end
  29. end
  30. 1 describe '#build_from_hash' do
  31. 1 it 'validates instance of FieldError created by the build_from_hash method' do
  32. 1 field_error_from_hash = Bandwidth::FieldError.build_from_hash({
  33. fieldName: 'to',
  34. description: 'invalid phone number'
  35. })
  36. 1 expect(field_error_from_hash).to be_instance_of(Bandwidth::FieldError)
  37. 1 expect(field_error_from_hash.field_name).to eq('to')
  38. 1 expect(field_error_from_hash.description).to eq('invalid phone number')
  39. end
  40. end
  41. 1 describe '#to_s' do
  42. 1 it 'returns a string representation of the object' do
  43. 1 expect(field_error_values.to_s).to eq('{:fieldName=>"to", :description=>"invalid phone number"}')
  44. end
  45. end
  46. 1 describe '#eq? #==' do
  47. 1 it 'returns true/false when comparing objects' do
  48. 1 expect(field_error_default.eql?(Bandwidth::FieldError.new)).to be true
  49. 1 expect(field_error_default.eql?(field_error_values)).to be false
  50. end
  51. end
  52. 1 describe '#to_body #to_hash' do
  53. 1 it 'returns a hash representation of the object' do
  54. 1 expect(field_error_values.to_body).to eq({
  55. fieldName: 'to',
  56. description: 'invalid phone number'
  57. })
  58. end
  59. end
  60. end

spec/unit/models/file_format_enum_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::FileFormatEnum
  2. 1 describe Bandwidth::FileFormatEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines MP3' do
  5. 1 expect(Bandwidth::FileFormatEnum::MP3).to eq('mp3')
  6. end
  7. 1 it 'defines WAV' do
  8. 1 expect(Bandwidth::FileFormatEnum::WAV).to eq('wav')
  9. end
  10. end
  11. 1 describe '.all_vars' do
  12. 1 it 'returns every valid enum value' do
  13. 1 expect(Bandwidth::FileFormatEnum.all_vars).to eq([
  14. 'mp3',
  15. 'wav'
  16. ])
  17. end
  18. end
  19. 1 describe '.build_from_hash' do
  20. 1 it 'returns the value when it matches a valid enum value' do
  21. 1 expect(Bandwidth::FileFormatEnum.build_from_hash('mp3')).to eq('mp3')
  22. 1 expect(Bandwidth::FileFormatEnum.build_from_hash('wav')).to eq('wav')
  23. end
  24. 1 it 'raises an error for an invalid enum value' do
  25. 1 expect {
  26. 1 Bandwidth::FileFormatEnum.build_from_hash('invalid')
  27. }.to raise_error(RuntimeError)
  28. end
  29. end
  30. end

spec/unit/models/gather_callback_spec.rb

100.0% lines covered

48 relevant lines. 48 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::GatherCallback
  2. 1 describe Bandwidth::GatherCallback do
  3. 2 let(:gather_callback_default) { Bandwidth::GatherCallback.new }
  4. 4 let(:gather_callback_values) { Bandwidth::GatherCallback.new({
  5. event_type: 'gather',
  6. event_time: '2022-06-16T13:15:07.160Z',
  7. account_id: '9900000',
  8. application_id: '04e88489-df02-4e34-a0ee-27a91849555f',
  9. from: '+19195554321',
  10. to: '+19195551234',
  11. direction: Bandwidth::CallDirectionEnum::INBOUND,
  12. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  13. digits: '123',
  14. call_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  15. enqueued_time: '2022-06-16T13:15:07.160Z',
  16. start_time: '2022-06-16T13:15:07.160Z',
  17. answer_time: '2022-06-16T13:15:18.126Z',
  18. parent_call_id: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  19. terminating_digit: '#',
  20. transfer_caller_id: '+19195554321',
  21. transfer_to: '+19195551234',
  22. tag: 'custom tag'
  23. }) }
  24. 1 describe '#initialize' do
  25. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  26. 1 expect {
  27. 1 Bandwidth::GatherCallback.new([])
  28. }.to raise_error(ArgumentError)
  29. end
  30. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  31. 1 expect {
  32. 1 Bandwidth::GatherCallback.new({ invalid: true })
  33. }.to raise_error(ArgumentError)
  34. end
  35. end
  36. 1 describe '#acceptable_attributes' do
  37. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  38. 1 expect(Bandwidth::GatherCallback.acceptable_attributes).to eq(Bandwidth::GatherCallback.attribute_map.values)
  39. end
  40. end
  41. 1 describe '#openapi_nullable' do
  42. 1 it 'expects nullable attributes to be the set of nullable fields' do
  43. 1 expect(Bandwidth::GatherCallback.openapi_nullable).to eq(Set.new([
  44. :'enqueued_time',
  45. :'answer_time',
  46. :'tag'
  47. ]))
  48. end
  49. end
  50. 1 describe '#build_from_hash' do
  51. 1 it 'validates instance of GatherCallback created by the build_from_hash method' do
  52. 1 gather_callback_from_hash = Bandwidth::GatherCallback.build_from_hash({
  53. eventType: 'gather',
  54. eventTime: '2022-06-16T13:15:07.160Z',
  55. accountId: '9900000',
  56. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  57. from: '+19195554321',
  58. to: '+19195551234',
  59. direction: Bandwidth::CallDirectionEnum::INBOUND,
  60. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  61. digits: '123',
  62. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  63. enqueuedTime: '2022-06-16T13:15:07.160Z',
  64. startTime: '2022-06-16T13:15:07.160Z',
  65. answerTime: '2022-06-16T13:15:18.126Z',
  66. parentCallId: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  67. terminatingDigit: '#',
  68. transferCallerId: '+19195554321',
  69. transferTo: '+19195551234',
  70. tag: 'custom tag'
  71. })
  72. 1 expect(gather_callback_from_hash).to be_instance_of(Bandwidth::GatherCallback)
  73. 1 expect(gather_callback_from_hash.event_type).to eq('gather')
  74. 1 expect(gather_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  75. 1 expect(gather_callback_from_hash.account_id).to eq('9900000')
  76. 1 expect(gather_callback_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f')
  77. 1 expect(gather_callback_from_hash.from).to eq('+19195554321')
  78. 1 expect(gather_callback_from_hash.to).to eq('+19195551234')
  79. 1 expect(gather_callback_from_hash.direction).to eq(Bandwidth::CallDirectionEnum::INBOUND)
  80. 1 expect(gather_callback_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  81. 1 expect(gather_callback_from_hash.digits).to eq('123')
  82. 1 expect(gather_callback_from_hash.call_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  83. 1 expect(gather_callback_from_hash.enqueued_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  84. 1 expect(gather_callback_from_hash.start_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  85. 1 expect(gather_callback_from_hash.answer_time).to eq(Time.parse('2022-06-16T13:15:18.126Z'))
  86. 1 expect(gather_callback_from_hash.parent_call_id).to eq('c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99')
  87. 1 expect(gather_callback_from_hash.terminating_digit).to eq('#')
  88. 1 expect(gather_callback_from_hash.transfer_caller_id).to eq('+19195554321')
  89. 1 expect(gather_callback_from_hash.transfer_to).to eq('+19195551234')
  90. 1 expect(gather_callback_from_hash.tag).to eq('custom tag')
  91. end
  92. end
  93. 1 describe '#to_s' do
  94. 1 it 'returns a string representation of the object' do
  95. 1 expect(gather_callback_values.to_s).to eq('{:eventType=>"gather", :eventTime=>"2022-06-16T13:15:07.160Z", :accountId=>"9900000", :applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :from=>"+19195554321", :to=>"+19195551234", :direction=>"inbound", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :digits=>"123", :callUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :enqueuedTime=>"2022-06-16T13:15:07.160Z", :startTime=>"2022-06-16T13:15:07.160Z", :answerTime=>"2022-06-16T13:15:18.126Z", :parentCallId=>"c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99", :terminatingDigit=>"#", :transferCallerId=>"+19195554321", :transferTo=>"+19195551234", :tag=>"custom tag"}')
  96. end
  97. end
  98. 1 describe '#eq? #==' do
  99. 1 it 'returns true/false when comparing objects' do
  100. 1 expect(gather_callback_default.eql?(Bandwidth::GatherCallback.new)).to be true
  101. 1 expect(gather_callback_default.eql?(gather_callback_values)).to be false
  102. end
  103. end
  104. 1 describe '#to_body #to_hash' do
  105. 1 it 'returns a hash representation of the object' do
  106. 1 expect(gather_callback_values.to_body).to eq({
  107. eventType: 'gather',
  108. eventTime: '2022-06-16T13:15:07.160Z',
  109. accountId: '9900000',
  110. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  111. from: '+19195554321',
  112. to: '+19195551234',
  113. direction: Bandwidth::CallDirectionEnum::INBOUND,
  114. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  115. digits: '123',
  116. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  117. enqueuedTime: '2022-06-16T13:15:07.160Z',
  118. startTime: '2022-06-16T13:15:07.160Z',
  119. answerTime: '2022-06-16T13:15:18.126Z',
  120. parentCallId: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  121. terminatingDigit: '#',
  122. transferCallerId: '+19195554321',
  123. transferTo: '+19195551234',
  124. tag: 'custom tag'
  125. })
  126. end
  127. end
  128. end

spec/unit/models/get_async_bulk_lookup_response_data_spec.rb

100.0% lines covered

35 relevant lines. 35 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::GetAsyncBulkLookupResponseData
  2. 1 describe Bandwidth::GetAsyncBulkLookupResponseData do
  3. 4 let(:lookup_result) { Bandwidth::LookupResult.new({ phone_number: '+19195551234' }) }
  4. 2 let(:get_async_bulk_lookup_response_data_default) { Bandwidth::GetAsyncBulkLookupResponseData.new }
  5. 4 let(:get_async_bulk_lookup_response_data_values) { Bandwidth::GetAsyncBulkLookupResponseData.new({
  6. request_id: 'abc-123',
  7. status: Bandwidth::InProgressLookupStatusEnum::COMPLETE,
  8. results: [lookup_result]
  9. }) }
  10. 1 describe '#initialize' do
  11. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  12. 1 expect {
  13. 1 Bandwidth::GetAsyncBulkLookupResponseData.new([])
  14. }.to raise_error(ArgumentError)
  15. end
  16. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  17. 1 expect {
  18. 1 Bandwidth::GetAsyncBulkLookupResponseData.new({ invalid: true })
  19. }.to raise_error(ArgumentError)
  20. end
  21. end
  22. 1 describe '#acceptable_attributes' do
  23. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  24. 1 expect(Bandwidth::GetAsyncBulkLookupResponseData.acceptable_attributes).to eq(Bandwidth::GetAsyncBulkLookupResponseData.attribute_map.values)
  25. end
  26. end
  27. 1 describe '#openapi_nullable' do
  28. 1 it 'expects nullable attributes to be an empty set' do
  29. 1 expect(Bandwidth::GetAsyncBulkLookupResponseData.openapi_nullable).to eq(Set.new([]))
  30. end
  31. end
  32. 1 describe '#build_from_hash' do
  33. 1 it 'validates instance of GetAsyncBulkLookupResponseData created by the build_from_hash method' do
  34. 1 get_async_bulk_lookup_response_data_from_hash = Bandwidth::GetAsyncBulkLookupResponseData.build_from_hash({
  35. requestId: 'abc-123',
  36. status: 'COMPLETE',
  37. results: [{ phoneNumber: '+19195551234' }]
  38. })
  39. 1 expect(get_async_bulk_lookup_response_data_from_hash).to be_instance_of(Bandwidth::GetAsyncBulkLookupResponseData)
  40. 1 expect(get_async_bulk_lookup_response_data_from_hash.request_id).to eq('abc-123')
  41. 1 expect(get_async_bulk_lookup_response_data_from_hash.status).to eq('COMPLETE')
  42. 1 expect(get_async_bulk_lookup_response_data_from_hash.results.first).to be_instance_of(Bandwidth::LookupResult)
  43. 1 expect(get_async_bulk_lookup_response_data_from_hash.results.first.phone_number).to eq('+19195551234')
  44. end
  45. end
  46. 1 describe '#to_s' do
  47. 1 it 'returns a string representation of the object' do
  48. 1 expect(get_async_bulk_lookup_response_data_values.to_s).to eq('{:requestId=>"abc-123", :status=>"COMPLETE", :results=>[{:phoneNumber=>"+19195551234"}]}')
  49. end
  50. end
  51. 1 describe '#eq? #==' do
  52. 1 it 'returns true/false when comparing objects' do
  53. 1 expect(get_async_bulk_lookup_response_data_default.eql?(Bandwidth::GetAsyncBulkLookupResponseData.new)).to be true
  54. 1 expect(get_async_bulk_lookup_response_data_default.eql?(get_async_bulk_lookup_response_data_values)).to be false
  55. end
  56. end
  57. 1 describe '#to_body #to_hash' do
  58. 1 it 'returns a hash representation of the object' do
  59. 1 expect(get_async_bulk_lookup_response_data_values.to_body).to eq({
  60. requestId: 'abc-123',
  61. status: Bandwidth::InProgressLookupStatusEnum::COMPLETE,
  62. results: [{ phoneNumber: '+19195551234' }]
  63. })
  64. end
  65. end
  66. end

spec/unit/models/get_async_bulk_lookup_response_spec.rb

100.0% lines covered

33 relevant lines. 33 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::GetAsyncBulkLookupResponse
  2. 1 describe Bandwidth::GetAsyncBulkLookupResponse do
  3. 2 let(:get_async_bulk_lookup_response_default) { Bandwidth::GetAsyncBulkLookupResponse.new }
  4. 4 let(:get_async_bulk_lookup_response_values) { Bandwidth::GetAsyncBulkLookupResponse.new({
  5. links: [Bandwidth::LinkSchema.new({ href: 'https://example.com', rel: 'self', method: 'GET' })],
  6. data: Bandwidth::GetAsyncBulkLookupResponseData.new({ request_id: 'abc-123' }),
  7. errors: [Bandwidth::LookupErrorSchema.new({ code: '400', description: 'bad request', type: 'validation' })]
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::GetAsyncBulkLookupResponse.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::GetAsyncBulkLookupResponse.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::GetAsyncBulkLookupResponse.acceptable_attributes).to eq(Bandwidth::GetAsyncBulkLookupResponse.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be an empty set' do
  28. 1 expect(Bandwidth::GetAsyncBulkLookupResponse.openapi_nullable).to eq(Set.new([]))
  29. end
  30. end
  31. 1 describe '#build_from_hash' do
  32. 1 it 'validates instance of GetAsyncBulkLookupResponse created by the build_from_hash method' do
  33. 1 get_async_bulk_lookup_response_from_hash = Bandwidth::GetAsyncBulkLookupResponse.build_from_hash({
  34. links: [{ href: 'https://example.com', rel: 'self', method: 'GET' }],
  35. data: { requestId: 'abc-123' },
  36. errors: [{ code: '400', description: 'bad request', type: 'validation' }]
  37. })
  38. 1 expect(get_async_bulk_lookup_response_from_hash).to be_instance_of(Bandwidth::GetAsyncBulkLookupResponse)
  39. 1 expect(get_async_bulk_lookup_response_from_hash.links.first).to be_instance_of(Bandwidth::LinkSchema)
  40. 1 expect(get_async_bulk_lookup_response_from_hash.data).to be_instance_of(Bandwidth::GetAsyncBulkLookupResponseData)
  41. 1 expect(get_async_bulk_lookup_response_from_hash.errors.first).to be_instance_of(Bandwidth::LookupErrorSchema)
  42. end
  43. end
  44. 1 describe '#to_s' do
  45. 1 it 'returns a string representation of the object' do
  46. 1 expect(get_async_bulk_lookup_response_values.to_s).to eq('{:links=>[{:href=>"https://example.com", :rel=>"self", :method=>"GET"}], :data=>{:requestId=>"abc-123"}, :errors=>[{:code=>"400", :description=>"bad request", :type=>"validation"}]}')
  47. end
  48. end
  49. 1 describe '#eq? #==' do
  50. 1 it 'returns true/false when comparing objects' do
  51. 1 expect(get_async_bulk_lookup_response_default.eql?(Bandwidth::GetAsyncBulkLookupResponse.new)).to be true
  52. 1 expect(get_async_bulk_lookup_response_default.eql?(get_async_bulk_lookup_response_values)).to be false
  53. end
  54. end
  55. 1 describe '#to_body #to_hash' do
  56. 1 it 'returns a hash representation of the object' do
  57. 1 expect(get_async_bulk_lookup_response_values.to_body).to eq({
  58. links: [{ href: 'https://example.com', rel: 'self', method: 'GET' }],
  59. data: { requestId: 'abc-123' },
  60. errors: [{ code: '400', description: 'bad request', type: 'validation' }]
  61. })
  62. end
  63. end
  64. end

spec/unit/models/in_progress_lookup_status_enum_spec.rb

100.0% lines covered

22 relevant lines. 22 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::InProgressLookupStatusEnum
  2. 1 describe Bandwidth::InProgressLookupStatusEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines IN_PROGRESS' do
  5. 1 expect(Bandwidth::InProgressLookupStatusEnum::IN_PROGRESS).to eq('IN_PROGRESS')
  6. end
  7. 1 it 'defines COMPLETE' do
  8. 1 expect(Bandwidth::InProgressLookupStatusEnum::COMPLETE).to eq('COMPLETE')
  9. end
  10. 1 it 'defines PARTIAL_COMPLETE' do
  11. 1 expect(Bandwidth::InProgressLookupStatusEnum::PARTIAL_COMPLETE).to eq('PARTIAL_COMPLETE')
  12. end
  13. 1 it 'defines FAILED' do
  14. 1 expect(Bandwidth::InProgressLookupStatusEnum::FAILED).to eq('FAILED')
  15. end
  16. end
  17. 1 describe '.all_vars' do
  18. 1 it 'returns every valid enum value' do
  19. 1 expect(Bandwidth::InProgressLookupStatusEnum.all_vars).to eq([
  20. 'IN_PROGRESS',
  21. 'COMPLETE',
  22. 'PARTIAL_COMPLETE',
  23. 'FAILED'
  24. ])
  25. end
  26. end
  27. 1 describe '.build_from_hash' do
  28. 1 it 'returns the value when it matches a valid enum value' do
  29. 1 expect(Bandwidth::InProgressLookupStatusEnum.build_from_hash('IN_PROGRESS')).to eq('IN_PROGRESS')
  30. 1 expect(Bandwidth::InProgressLookupStatusEnum.build_from_hash('COMPLETE')).to eq('COMPLETE')
  31. 1 expect(Bandwidth::InProgressLookupStatusEnum.build_from_hash('PARTIAL_COMPLETE')).to eq('PARTIAL_COMPLETE')
  32. 1 expect(Bandwidth::InProgressLookupStatusEnum.build_from_hash('FAILED')).to eq('FAILED')
  33. end
  34. 1 it 'raises an error for an invalid enum value' do
  35. 1 expect {
  36. 1 Bandwidth::InProgressLookupStatusEnum.build_from_hash('invalid')
  37. }.to raise_error(RuntimeError)
  38. end
  39. end
  40. end

spec/unit/models/inbound_callback_message_spec.rb

100.0% lines covered

69 relevant lines. 69 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::InboundCallbackMessage
  2. 1 describe Bandwidth::InboundCallbackMessage do
  3. 2 let(:inbound_callback_message_default) { Bandwidth::InboundCallbackMessage.new({
  4. id: 'baseline-id',
  5. owner: '+19195554321',
  6. application_id: 'baseline-app',
  7. time: '2022-06-16T13:15:07.160Z',
  8. segment_count: 1,
  9. direction: Bandwidth::MessageDirectionEnum::IN,
  10. to: ['+19195551234'],
  11. from: '+19195554321'
  12. }) }
  13. 12 let(:inbound_callback_message_values) { Bandwidth::InboundCallbackMessage.new({
  14. id: '1589228074636lm4k2je7j7jklbn2',
  15. owner: '+19195554321',
  16. application_id: '93de2206-9669-4e07-948d-329f4b722ee2',
  17. time: '2022-06-16T13:15:07.160Z',
  18. segment_count: 2,
  19. direction: Bandwidth::MessageDirectionEnum::IN,
  20. to: ['+19195551234'],
  21. from: '+19195554321',
  22. text: 'Hello world',
  23. tag: 'custom tag',
  24. media: ['https://dev.bandwidth.com/images/bandwidth-logo.png'],
  25. priority: Bandwidth::PriorityEnum::DEFAULT,
  26. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS
  27. }) }
  28. 1 describe '#initialize' do
  29. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  30. 1 expect {
  31. 1 Bandwidth::InboundCallbackMessage.new([])
  32. }.to raise_error(ArgumentError)
  33. end
  34. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  35. 1 expect {
  36. 1 Bandwidth::InboundCallbackMessage.new({ invalid: true })
  37. }.to raise_error(ArgumentError)
  38. end
  39. end
  40. 1 describe '#acceptable_attributes' do
  41. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  42. 1 expect(Bandwidth::InboundCallbackMessage.acceptable_attributes).to eq(Bandwidth::InboundCallbackMessage.attribute_map.values)
  43. end
  44. end
  45. 1 describe '#openapi_nullable' do
  46. 1 it 'expects nullable attributes to be an empty set' do
  47. 1 expect(Bandwidth::InboundCallbackMessage.openapi_nullable).to eq(Set.new([]))
  48. end
  49. end
  50. 1 describe '#build_from_hash' do
  51. 1 it 'validates instance of InboundCallbackMessage created by the build_from_hash method' do
  52. 1 inbound_callback_message_from_hash = Bandwidth::InboundCallbackMessage.build_from_hash({
  53. id: '1589228074636lm4k2je7j7jklbn2',
  54. owner: '+19195554321',
  55. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  56. time: '2022-06-16T13:15:07.160Z',
  57. segmentCount: 2,
  58. direction: Bandwidth::MessageDirectionEnum::IN,
  59. to: ['+19195551234'],
  60. from: '+19195554321',
  61. text: 'Hello world',
  62. tag: 'custom tag',
  63. media: ['https://dev.bandwidth.com/images/bandwidth-logo.png'],
  64. priority: Bandwidth::PriorityEnum::DEFAULT,
  65. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS
  66. })
  67. 1 expect(inbound_callback_message_from_hash).to be_instance_of(Bandwidth::InboundCallbackMessage)
  68. 1 expect(inbound_callback_message_from_hash.id).to eq('1589228074636lm4k2je7j7jklbn2')
  69. 1 expect(inbound_callback_message_from_hash.owner).to eq('+19195554321')
  70. 1 expect(inbound_callback_message_from_hash.application_id).to eq('93de2206-9669-4e07-948d-329f4b722ee2')
  71. 1 expect(inbound_callback_message_from_hash.time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  72. 1 expect(inbound_callback_message_from_hash.segment_count).to eq(2)
  73. 1 expect(inbound_callback_message_from_hash.direction).to eq(Bandwidth::MessageDirectionEnum::IN)
  74. 1 expect(inbound_callback_message_from_hash.to).to eq(['+19195551234'])
  75. 1 expect(inbound_callback_message_from_hash.from).to eq('+19195554321')
  76. 1 expect(inbound_callback_message_from_hash.text).to eq('Hello world')
  77. 1 expect(inbound_callback_message_from_hash.tag).to eq('custom tag')
  78. 1 expect(inbound_callback_message_from_hash.media).to eq(['https://dev.bandwidth.com/images/bandwidth-logo.png'])
  79. 1 expect(inbound_callback_message_from_hash.priority).to eq(Bandwidth::PriorityEnum::DEFAULT)
  80. 1 expect(inbound_callback_message_from_hash.channel).to eq(Bandwidth::MultiChannelMessageChannelEnum::SMS)
  81. end
  82. end
  83. 1 describe '#to_s' do
  84. 1 it 'returns a string representation of the object' do
  85. 1 expect(inbound_callback_message_values.to_s).to eq('{:id=>"1589228074636lm4k2je7j7jklbn2", :owner=>"+19195554321", :applicationId=>"93de2206-9669-4e07-948d-329f4b722ee2", :time=>"2022-06-16T13:15:07.160Z", :segmentCount=>2, :direction=>"in", :to=>["+19195551234"], :from=>"+19195554321", :text=>"Hello world", :tag=>"custom tag", :media=>["https://dev.bandwidth.com/images/bandwidth-logo.png"], :priority=>"default", :channel=>"SMS"}')
  86. end
  87. end
  88. 1 describe '#eq? #==' do
  89. 1 it 'returns true/false when comparing objects' do
  90. 1 inbound_callback_message_equal = Bandwidth::InboundCallbackMessage.new({
  91. id: 'baseline-id',
  92. owner: '+19195554321',
  93. application_id: 'baseline-app',
  94. time: '2022-06-16T13:15:07.160Z',
  95. segment_count: 1,
  96. direction: Bandwidth::MessageDirectionEnum::IN,
  97. to: ['+19195551234'],
  98. from: '+19195554321'
  99. })
  100. 1 expect(inbound_callback_message_default.eql?(inbound_callback_message_equal)).to be true
  101. 1 expect(inbound_callback_message_default.eql?(inbound_callback_message_values)).to be false
  102. end
  103. end
  104. 1 describe '#to_body #to_hash' do
  105. 1 it 'returns a hash representation of the object' do
  106. 1 expect(inbound_callback_message_values.to_body).to eq({
  107. id: '1589228074636lm4k2je7j7jklbn2',
  108. owner: '+19195554321',
  109. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  110. time: '2022-06-16T13:15:07.160Z',
  111. segmentCount: 2,
  112. direction: Bandwidth::MessageDirectionEnum::IN,
  113. to: ['+19195551234'],
  114. from: '+19195554321',
  115. text: 'Hello world',
  116. tag: 'custom tag',
  117. media: ['https://dev.bandwidth.com/images/bandwidth-logo.png'],
  118. priority: Bandwidth::PriorityEnum::DEFAULT,
  119. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS
  120. })
  121. end
  122. end
  123. 1 describe 'custom attribute writers' do
  124. 1 it '#id=' do
  125. 1 expect {
  126. 1 inbound_callback_message_values.id = nil
  127. }.to raise_error(ArgumentError, 'id cannot be nil')
  128. end
  129. 1 it '#owner=' do
  130. 1 expect {
  131. 1 inbound_callback_message_values.owner = nil
  132. }.to raise_error(ArgumentError, 'owner cannot be nil')
  133. end
  134. 1 it '#application_id=' do
  135. 1 expect {
  136. 1 inbound_callback_message_values.application_id = nil
  137. }.to raise_error(ArgumentError, 'application_id cannot be nil')
  138. end
  139. 1 it '#time=' do
  140. 1 expect {
  141. 1 inbound_callback_message_values.time = nil
  142. }.to raise_error(ArgumentError, 'time cannot be nil')
  143. end
  144. 1 it '#segment_count=' do
  145. 1 expect {
  146. 1 inbound_callback_message_values.segment_count = nil
  147. }.to raise_error(ArgumentError, 'segment_count cannot be nil')
  148. end
  149. 1 it '#direction=' do
  150. 1 expect {
  151. 1 inbound_callback_message_values.direction = nil
  152. }.to raise_error(ArgumentError, 'direction cannot be nil')
  153. end
  154. 1 it '#to=' do
  155. 1 expect {
  156. 1 inbound_callback_message_values.to = nil
  157. }.to raise_error(ArgumentError, 'to cannot be nil')
  158. end
  159. 1 it '#from=' do
  160. 1 expect {
  161. 1 inbound_callback_message_values.from = nil
  162. }.to raise_error(ArgumentError, 'from cannot be nil')
  163. end
  164. end
  165. end

spec/unit/models/inbound_callback_spec.rb

100.0% lines covered

55 relevant lines. 55 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::InboundCallback
  2. 1 describe Bandwidth::InboundCallback do
  3. 2 let(:inbound_callback_default) { Bandwidth::InboundCallback.new({
  4. time: '2022-06-16T13:15:07.160Z',
  5. type: Bandwidth::InboundCallbackTypeEnum::MESSAGE_RECEIVED,
  6. to: '+19195551234',
  7. description: 'baseline description',
  8. message: { id: 'baseline' }
  9. }) }
  10. 9 let(:inbound_callback_values) { Bandwidth::InboundCallback.new({
  11. time: '2022-06-16T13:15:07.160Z',
  12. type: Bandwidth::InboundCallbackTypeEnum::MESSAGE_RECEIVED,
  13. to: '+19195551234',
  14. description: 'Incoming message received',
  15. message: {
  16. id: '1589228074636lm4k2je7j7jklbn2',
  17. owner: '+19195554321',
  18. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  19. time: '2022-06-16T13:15:07.160Z',
  20. segmentCount: 1,
  21. direction: 'in',
  22. to: ['+19195551234'],
  23. from: '+19195554321',
  24. text: 'Hello world'
  25. },
  26. carrier_name: 'Verizon'
  27. }) }
  28. 1 describe '#initialize' do
  29. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  30. 1 expect {
  31. 1 Bandwidth::InboundCallback.new([])
  32. }.to raise_error(ArgumentError)
  33. end
  34. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  35. 1 expect {
  36. 1 Bandwidth::InboundCallback.new({ invalid: true })
  37. }.to raise_error(ArgumentError)
  38. end
  39. end
  40. 1 describe '#acceptable_attributes' do
  41. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  42. 1 expect(Bandwidth::InboundCallback.acceptable_attributes).to eq(Bandwidth::InboundCallback.attribute_map.values)
  43. end
  44. end
  45. 1 describe '#openapi_nullable' do
  46. 1 it 'expects nullable attributes to be an empty set' do
  47. 1 expect(Bandwidth::InboundCallback.openapi_nullable).to eq(Set.new([]))
  48. end
  49. end
  50. 1 describe '#build_from_hash' do
  51. 1 it 'validates instance of InboundCallback created by the build_from_hash method' do
  52. 1 inbound_callback_from_hash = Bandwidth::InboundCallback.build_from_hash({
  53. time: '2022-06-16T13:15:07.160Z',
  54. type: Bandwidth::InboundCallbackTypeEnum::MESSAGE_RECEIVED,
  55. to: '+19195551234',
  56. description: 'Incoming message received',
  57. message: {
  58. id: '1589228074636lm4k2je7j7jklbn2',
  59. owner: '+19195554321',
  60. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  61. time: '2022-06-16T13:15:07.160Z',
  62. segmentCount: 1,
  63. direction: Bandwidth::MessageDirectionEnum::IN,
  64. to: ['+19195551234'],
  65. from: '+19195554321',
  66. text: 'Hello world'
  67. },
  68. carrierName: 'Verizon'
  69. })
  70. 1 expect(inbound_callback_from_hash).to be_instance_of(Bandwidth::InboundCallback)
  71. 1 expect(inbound_callback_from_hash.time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  72. 1 expect(inbound_callback_from_hash.type).to eq(Bandwidth::InboundCallbackTypeEnum::MESSAGE_RECEIVED)
  73. 1 expect(inbound_callback_from_hash.to).to eq('+19195551234')
  74. 1 expect(inbound_callback_from_hash.description).to eq('Incoming message received')
  75. 1 expect(inbound_callback_from_hash.message).to be_instance_of(Bandwidth::InboundCallbackMessage)
  76. 1 expect(inbound_callback_from_hash.message.id).to eq('1589228074636lm4k2je7j7jklbn2')
  77. 1 expect(inbound_callback_from_hash.message.text).to eq('Hello world')
  78. 1 expect(inbound_callback_from_hash.carrier_name).to eq('Verizon')
  79. end
  80. end
  81. 1 describe '#to_s' do
  82. 1 it 'returns a string representation of the object' do
  83. 1 expect(inbound_callback_values.to_s).to eq('{:time=>"2022-06-16T13:15:07.160Z", :type=>"message-received", :to=>"+19195551234", :description=>"Incoming message received", :message=>{:id=>"1589228074636lm4k2je7j7jklbn2", :owner=>"+19195554321", :applicationId=>"93de2206-9669-4e07-948d-329f4b722ee2", :time=>"2022-06-16T13:15:07.160Z", :segmentCount=>1, :direction=>"in", :to=>["+19195551234"], :from=>"+19195554321", :text=>"Hello world"}, :carrierName=>"Verizon"}')
  84. end
  85. end
  86. 1 describe '#eq? #==' do
  87. 1 it 'returns true/false when comparing objects' do
  88. 1 inbound_callback_equal = Bandwidth::InboundCallback.new({
  89. time: '2022-06-16T13:15:07.160Z',
  90. type: Bandwidth::InboundCallbackTypeEnum::MESSAGE_RECEIVED,
  91. to: '+19195551234',
  92. description: 'baseline description',
  93. message: { id: 'baseline' }
  94. })
  95. 1 expect(inbound_callback_default.eql?(inbound_callback_equal)).to be true
  96. 1 expect(inbound_callback_default.eql?(inbound_callback_values)).to be false
  97. end
  98. end
  99. 1 describe '#to_body #to_hash' do
  100. 1 it 'returns a hash representation of the object' do
  101. 1 expect(inbound_callback_values.to_body).to eq({
  102. time: '2022-06-16T13:15:07.160Z',
  103. type: Bandwidth::InboundCallbackTypeEnum::MESSAGE_RECEIVED,
  104. to: '+19195551234',
  105. description: 'Incoming message received',
  106. message: {
  107. id: '1589228074636lm4k2je7j7jklbn2',
  108. owner: '+19195554321',
  109. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  110. time: '2022-06-16T13:15:07.160Z',
  111. segmentCount: 1,
  112. direction: 'in',
  113. to: ['+19195551234'],
  114. from: '+19195554321',
  115. text: 'Hello world'
  116. },
  117. carrierName: 'Verizon'
  118. })
  119. end
  120. end
  121. 1 describe 'custom attribute writers' do
  122. 1 it '#time=' do
  123. 1 expect {
  124. 1 inbound_callback_values.time = nil
  125. }.to raise_error(ArgumentError, 'time cannot be nil')
  126. end
  127. 1 it '#type=' do
  128. 1 expect {
  129. 1 inbound_callback_values.type = nil
  130. }.to raise_error(ArgumentError, 'type cannot be nil')
  131. end
  132. 1 it '#to=' do
  133. 1 expect {
  134. 1 inbound_callback_values.to = nil
  135. }.to raise_error(ArgumentError, 'to cannot be nil')
  136. end
  137. 1 it '#description=' do
  138. 1 expect {
  139. 1 inbound_callback_values.description = nil
  140. }.to raise_error(ArgumentError, 'description cannot be nil')
  141. end
  142. 1 it '#message=' do
  143. 1 expect {
  144. 1 inbound_callback_values.message = nil
  145. }.to raise_error(ArgumentError, 'message cannot be nil')
  146. end
  147. end
  148. end

spec/unit/models/inbound_callback_type_enum_spec.rb

100.0% lines covered

19 relevant lines. 19 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::InboundCallbackTypeEnum
  2. 1 describe Bandwidth::InboundCallbackTypeEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines MESSAGE_RECEIVED' do
  5. 1 expect(Bandwidth::InboundCallbackTypeEnum::MESSAGE_RECEIVED).to eq('message-received')
  6. end
  7. 1 it 'defines REQUEST_LOCATION_RESPONSE' do
  8. 1 expect(Bandwidth::InboundCallbackTypeEnum::REQUEST_LOCATION_RESPONSE).to eq('request-location-response')
  9. end
  10. 1 it 'defines SUGGESTION_RESPONSE' do
  11. 1 expect(Bandwidth::InboundCallbackTypeEnum::SUGGESTION_RESPONSE).to eq('suggestion-response')
  12. end
  13. end
  14. 1 describe '.all_vars' do
  15. 1 it 'returns every valid enum value' do
  16. 1 expect(Bandwidth::InboundCallbackTypeEnum.all_vars).to eq([
  17. 'message-received',
  18. 'request-location-response',
  19. 'suggestion-response'
  20. ])
  21. end
  22. end
  23. 1 describe '.build_from_hash' do
  24. 1 it 'returns the value when it matches a valid enum value' do
  25. 1 expect(Bandwidth::InboundCallbackTypeEnum.build_from_hash('message-received')).to eq('message-received')
  26. 1 expect(Bandwidth::InboundCallbackTypeEnum.build_from_hash('request-location-response')).to eq('request-location-response')
  27. 1 expect(Bandwidth::InboundCallbackTypeEnum.build_from_hash('suggestion-response')).to eq('suggestion-response')
  28. end
  29. 1 it 'raises an error for an invalid enum value' do
  30. 1 expect {
  31. 1 Bandwidth::InboundCallbackTypeEnum.build_from_hash('invalid')
  32. }.to raise_error(RuntimeError)
  33. end
  34. end
  35. end

spec/unit/models/initiate_callback_spec.rb

100.0% lines covered

45 relevant lines. 45 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::InitiateCallback
  2. 1 describe Bandwidth::InitiateCallback do
  3. 2 let(:initiate_callback_default) { Bandwidth::InitiateCallback.new }
  4. 4 let(:initiate_callback_values) { Bandwidth::InitiateCallback.new({
  5. event_type: 'initiate',
  6. event_time: '2022-06-16T13:15:07.160Z',
  7. account_id: '9900000',
  8. application_id: '04e88489-df02-4e34-a0ee-27a91849555f',
  9. from: '+19195554321',
  10. to: '+19195551234',
  11. direction: Bandwidth::CallDirectionEnum::INBOUND,
  12. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  13. call_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  14. start_time: '2022-06-16T13:15:07.160Z',
  15. diversion: { reason: 'unconditional', privacy: 'off' },
  16. stir_shaken: { verstat: 'TN-Validation-Passed', attestationIndicator: 'A', originatingId: '527c7d1f-22a4-4ec1-ad19-1a4ec9466cdb' },
  17. uui: 'aGVsbG8sIHdvcmxkIQ==;encoding=base64'
  18. }) }
  19. 1 describe '#initialize' do
  20. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  21. 1 expect {
  22. 1 Bandwidth::InitiateCallback.new([])
  23. }.to raise_error(ArgumentError)
  24. end
  25. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  26. 1 expect {
  27. 1 Bandwidth::InitiateCallback.new({ invalid: true })
  28. }.to raise_error(ArgumentError)
  29. end
  30. end
  31. 1 describe '#acceptable_attributes' do
  32. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  33. 1 expect(Bandwidth::InitiateCallback.acceptable_attributes).to eq(Bandwidth::InitiateCallback.attribute_map.values)
  34. end
  35. end
  36. 1 describe '#openapi_nullable' do
  37. 1 it 'expects nullable attributes to be an empty set' do
  38. 1 expect(Bandwidth::InitiateCallback.openapi_nullable).to eq(Set.new([]))
  39. end
  40. end
  41. 1 describe '#build_from_hash' do
  42. 1 it 'validates instance of InitiateCallback created by the build_from_hash method' do
  43. 1 initiate_callback_from_hash = Bandwidth::InitiateCallback.build_from_hash({
  44. eventType: 'initiate',
  45. eventTime: '2022-06-16T13:15:07.160Z',
  46. accountId: '9900000',
  47. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  48. from: '+19195554321',
  49. to: '+19195551234',
  50. direction: Bandwidth::CallDirectionEnum::INBOUND,
  51. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  52. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  53. startTime: '2022-06-16T13:15:07.160Z',
  54. diversion: { reason: 'unconditional', privacy: 'off' },
  55. stirShaken: { verstat: 'TN-Validation-Passed', attestationIndicator: 'A', originatingId: '527c7d1f-22a4-4ec1-ad19-1a4ec9466cdb' },
  56. uui: 'aGVsbG8sIHdvcmxkIQ==;encoding=base64'
  57. })
  58. 1 expect(initiate_callback_from_hash).to be_instance_of(Bandwidth::InitiateCallback)
  59. 1 expect(initiate_callback_from_hash.event_type).to eq('initiate')
  60. 1 expect(initiate_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  61. 1 expect(initiate_callback_from_hash.account_id).to eq('9900000')
  62. 1 expect(initiate_callback_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f')
  63. 1 expect(initiate_callback_from_hash.from).to eq('+19195554321')
  64. 1 expect(initiate_callback_from_hash.to).to eq('+19195551234')
  65. 1 expect(initiate_callback_from_hash.direction).to eq(Bandwidth::CallDirectionEnum::INBOUND)
  66. 1 expect(initiate_callback_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  67. 1 expect(initiate_callback_from_hash.call_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  68. 1 expect(initiate_callback_from_hash.start_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  69. 1 expect(initiate_callback_from_hash.diversion).to be_instance_of(Bandwidth::Diversion)
  70. 1 expect(initiate_callback_from_hash.diversion.reason).to eq('unconditional')
  71. 1 expect(initiate_callback_from_hash.stir_shaken).to be_instance_of(Bandwidth::StirShaken)
  72. 1 expect(initiate_callback_from_hash.stir_shaken.verstat).to eq('TN-Validation-Passed')
  73. 1 expect(initiate_callback_from_hash.uui).to eq('aGVsbG8sIHdvcmxkIQ==;encoding=base64')
  74. end
  75. end
  76. 1 describe '#to_s' do
  77. 1 it 'returns a string representation of the object' do
  78. 1 expect(initiate_callback_values.to_s).to eq('{:eventType=>"initiate", :eventTime=>"2022-06-16T13:15:07.160Z", :accountId=>"9900000", :applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :from=>"+19195554321", :to=>"+19195551234", :direction=>"inbound", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :callUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :startTime=>"2022-06-16T13:15:07.160Z", :diversion=>{:reason=>"unconditional", :privacy=>"off"}, :stirShaken=>{:verstat=>"TN-Validation-Passed", :attestationIndicator=>"A", :originatingId=>"527c7d1f-22a4-4ec1-ad19-1a4ec9466cdb"}, :uui=>"aGVsbG8sIHdvcmxkIQ==;encoding=base64"}')
  79. end
  80. end
  81. 1 describe '#eq? #==' do
  82. 1 it 'returns true/false when comparing objects' do
  83. 1 expect(initiate_callback_default.eql?(Bandwidth::InitiateCallback.new)).to be true
  84. 1 expect(initiate_callback_default.eql?(initiate_callback_values)).to be false
  85. end
  86. end
  87. 1 describe '#to_body #to_hash' do
  88. 1 it 'returns a hash representation of the object' do
  89. 1 expect(initiate_callback_values.to_body).to eq({
  90. eventType: 'initiate',
  91. eventTime: '2022-06-16T13:15:07.160Z',
  92. accountId: '9900000',
  93. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  94. from: '+19195554321',
  95. to: '+19195551234',
  96. direction: Bandwidth::CallDirectionEnum::INBOUND,
  97. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  98. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  99. startTime: '2022-06-16T13:15:07.160Z',
  100. diversion: { reason: 'unconditional', privacy: 'off' },
  101. stirShaken: { verstat: 'TN-Validation-Passed', attestationIndicator: 'A', originatingId: '527c7d1f-22a4-4ec1-ad19-1a4ec9466cdb' },
  102. uui: 'aGVsbG8sIHdvcmxkIQ==;encoding=base64'
  103. })
  104. end
  105. end
  106. end

spec/unit/models/latest_message_delivery_status_enum_spec.rb

100.0% lines covered

22 relevant lines. 22 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::LatestMessageDeliveryStatusEnum
  2. 1 describe Bandwidth::LatestMessageDeliveryStatusEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines ACTIVE' do
  5. 1 expect(Bandwidth::LatestMessageDeliveryStatusEnum::ACTIVE).to eq('ACTIVE')
  6. end
  7. 1 it 'defines DEACTIVATED' do
  8. 1 expect(Bandwidth::LatestMessageDeliveryStatusEnum::DEACTIVATED).to eq('DEACTIVATED')
  9. end
  10. 1 it 'defines UNKNOWN' do
  11. 1 expect(Bandwidth::LatestMessageDeliveryStatusEnum::UNKNOWN).to eq('UNKNOWN')
  12. end
  13. 1 it 'defines NOT_ENABLED' do
  14. 1 expect(Bandwidth::LatestMessageDeliveryStatusEnum::NOT_ENABLED).to eq('NOT_ENABLED')
  15. end
  16. end
  17. 1 describe '.all_vars' do
  18. 1 it 'returns every valid enum value' do
  19. 1 expect(Bandwidth::LatestMessageDeliveryStatusEnum.all_vars).to eq([
  20. 'ACTIVE',
  21. 'DEACTIVATED',
  22. 'UNKNOWN',
  23. 'NOT_ENABLED'
  24. ])
  25. end
  26. end
  27. 1 describe '.build_from_hash' do
  28. 1 it 'returns the value when it matches a valid enum value' do
  29. 1 expect(Bandwidth::LatestMessageDeliveryStatusEnum.build_from_hash('ACTIVE')).to eq('ACTIVE')
  30. 1 expect(Bandwidth::LatestMessageDeliveryStatusEnum.build_from_hash('DEACTIVATED')).to eq('DEACTIVATED')
  31. 1 expect(Bandwidth::LatestMessageDeliveryStatusEnum.build_from_hash('UNKNOWN')).to eq('UNKNOWN')
  32. 1 expect(Bandwidth::LatestMessageDeliveryStatusEnum.build_from_hash('NOT_ENABLED')).to eq('NOT_ENABLED')
  33. end
  34. 1 it 'raises an error for an invalid enum value' do
  35. 1 expect {
  36. 1 Bandwidth::LatestMessageDeliveryStatusEnum.build_from_hash('invalid')
  37. }.to raise_error(RuntimeError)
  38. end
  39. end
  40. end

spec/unit/models/line_type_enum_spec.rb

100.0% lines covered

22 relevant lines. 22 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::LineTypeEnum
  2. 1 describe Bandwidth::LineTypeEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines FIXED' do
  5. 1 expect(Bandwidth::LineTypeEnum::FIXED).to eq('FIXED')
  6. end
  7. 1 it 'defines VOIP_FIXED' do
  8. 1 expect(Bandwidth::LineTypeEnum::VOIP_FIXED).to eq('VOIP-FIXED')
  9. end
  10. 1 it 'defines MOBILE' do
  11. 1 expect(Bandwidth::LineTypeEnum::MOBILE).to eq('MOBILE')
  12. end
  13. 1 it 'defines VOIP' do
  14. 1 expect(Bandwidth::LineTypeEnum::VOIP).to eq('VOIP')
  15. end
  16. end
  17. 1 describe '.all_vars' do
  18. 1 it 'returns every valid enum value' do
  19. 1 expect(Bandwidth::LineTypeEnum.all_vars).to eq([
  20. 'FIXED',
  21. 'VOIP-FIXED',
  22. 'MOBILE',
  23. 'VOIP'
  24. ])
  25. end
  26. end
  27. 1 describe '.build_from_hash' do
  28. 1 it 'returns the value when it matches a valid enum value' do
  29. 1 expect(Bandwidth::LineTypeEnum.build_from_hash('FIXED')).to eq('FIXED')
  30. 1 expect(Bandwidth::LineTypeEnum.build_from_hash('VOIP-FIXED')).to eq('VOIP-FIXED')
  31. 1 expect(Bandwidth::LineTypeEnum.build_from_hash('MOBILE')).to eq('MOBILE')
  32. 1 expect(Bandwidth::LineTypeEnum.build_from_hash('VOIP')).to eq('VOIP')
  33. end
  34. 1 it 'raises an error for an invalid enum value' do
  35. 1 expect {
  36. 1 Bandwidth::LineTypeEnum.build_from_hash('invalid')
  37. }.to raise_error(RuntimeError)
  38. end
  39. end
  40. end

spec/unit/models/link_schema_spec.rb

100.0% lines covered

33 relevant lines. 33 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::LinkSchema
  2. 1 describe Bandwidth::LinkSchema do
  3. 2 let(:link_schema_default) { Bandwidth::LinkSchema.new }
  4. 4 let(:link_schema_values) { Bandwidth::LinkSchema.new({
  5. href: 'https://example.com',
  6. rel: 'self',
  7. method: 'GET'
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::LinkSchema.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::LinkSchema.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::LinkSchema.acceptable_attributes).to eq(Bandwidth::LinkSchema.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be an empty set' do
  28. 1 expect(Bandwidth::LinkSchema.openapi_nullable).to eq(Set.new([]))
  29. end
  30. end
  31. 1 describe '#build_from_hash' do
  32. 1 it 'validates instance of LinkSchema created by the build_from_hash method' do
  33. 1 link_schema_from_hash = Bandwidth::LinkSchema.build_from_hash({
  34. href: 'https://example.com',
  35. rel: 'self',
  36. method: 'GET'
  37. })
  38. 1 expect(link_schema_from_hash).to be_instance_of(Bandwidth::LinkSchema)
  39. 1 expect(link_schema_from_hash.href).to eq('https://example.com')
  40. 1 expect(link_schema_from_hash.rel).to eq('self')
  41. 1 expect(link_schema_from_hash.method).to eq('GET')
  42. end
  43. end
  44. 1 describe '#to_s' do
  45. 1 it 'returns a string representation of the object' do
  46. 1 expect(link_schema_values.to_s).to eq('{:href=>"https://example.com", :rel=>"self", :method=>"GET"}')
  47. end
  48. end
  49. 1 describe '#eq? #==' do
  50. 1 it 'returns true/false when comparing objects' do
  51. 1 expect(link_schema_default.eql?(Bandwidth::LinkSchema.new)).to be true
  52. 1 expect(link_schema_default.eql?(link_schema_values)).to be false
  53. end
  54. end
  55. 1 describe '#to_body #to_hash' do
  56. 1 it 'returns a hash representation of the object' do
  57. 1 expect(link_schema_values.to_body).to eq({
  58. href: 'https://example.com',
  59. rel: 'self',
  60. method: 'GET'
  61. })
  62. end
  63. end
  64. end

spec/unit/models/link_spec.rb

100.0% lines covered

32 relevant lines. 32 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Link
  2. 1 describe Bandwidth::Link do
  3. 2 let(:link_default) { Bandwidth::Link.new }
  4. 4 let(:link_values) { Bandwidth::Link.new({
  5. rel: 'next',
  6. href: 'https://example.com/page/2'
  7. }) }
  8. 1 describe '#initialize' do
  9. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  10. 1 expect {
  11. 1 Bandwidth::Link.new([])
  12. }.to raise_error(ArgumentError)
  13. end
  14. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  15. 1 expect {
  16. 1 Bandwidth::Link.new({ invalid: true })
  17. }.to raise_error(ArgumentError)
  18. end
  19. end
  20. 1 describe '#acceptable_attributes' do
  21. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  22. 1 expect(Bandwidth::Link.acceptable_attributes).to eq(Bandwidth::Link.attribute_map.values)
  23. end
  24. end
  25. 1 describe '#openapi_nullable' do
  26. 1 it 'expects nullable attributes to be an empty set' do
  27. 1 expect(Bandwidth::Link.openapi_nullable).to eq(Set.new([]))
  28. end
  29. end
  30. 1 describe '#build_from_hash' do
  31. 1 it 'validates instance of Link created by the build_from_hash method' do
  32. 1 link_from_hash = Bandwidth::Link.build_from_hash({
  33. rel: 'next',
  34. href: 'https://example.com/page/2'
  35. })
  36. 1 expect(link_from_hash).to be_instance_of(Bandwidth::Link)
  37. 1 expect(link_from_hash.rel).to eq('next')
  38. 1 expect(link_from_hash.href).to eq('https://example.com/page/2')
  39. end
  40. end
  41. 1 describe '#to_s' do
  42. 1 it 'returns a string representation of the object' do
  43. 1 expect(link_values.to_s).to eq('{:rel=>"next", :href=>"https://example.com/page/2"}')
  44. end
  45. end
  46. 1 describe '#eq? #==' do
  47. 1 it 'returns true/false when comparing objects' do
  48. 1 expect(link_default.eql?(Bandwidth::Link.new)).to be true
  49. 1 expect(link_default.eql?(link_values)).to be false
  50. end
  51. end
  52. 1 describe '#to_body #to_hash' do
  53. 1 it 'returns a hash representation of the object' do
  54. 1 expect(link_values.to_body).to eq({
  55. rel: 'next',
  56. href: 'https://example.com/page/2'
  57. })
  58. end
  59. end
  60. end

spec/unit/models/links_object_spec.rb

100.0% lines covered

34 relevant lines. 34 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::LinksObject
  2. 1 describe Bandwidth::LinksObject do
  3. 2 let(:links_object_default) { Bandwidth::LinksObject.new }
  4. 4 let(:links_object_values) { Bandwidth::LinksObject.new({
  5. first: 'https://example.com/page/1',
  6. _next: 'https://example.com/page/2',
  7. previous: 'https://example.com/page/0',
  8. last: 'https://example.com/page/9'
  9. }) }
  10. 1 describe '#initialize' do
  11. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  12. 1 expect {
  13. 1 Bandwidth::LinksObject.new([])
  14. }.to raise_error(ArgumentError)
  15. end
  16. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  17. 1 expect {
  18. 1 Bandwidth::LinksObject.new({ invalid: true })
  19. }.to raise_error(ArgumentError)
  20. end
  21. end
  22. 1 describe '#acceptable_attributes' do
  23. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  24. 1 expect(Bandwidth::LinksObject.acceptable_attributes).to eq(Bandwidth::LinksObject.attribute_map.values)
  25. end
  26. end
  27. 1 describe '#openapi_nullable' do
  28. 1 it 'expects nullable attributes to be an empty set' do
  29. 1 expect(Bandwidth::LinksObject.openapi_nullable).to eq(Set.new([]))
  30. end
  31. end
  32. 1 describe '#build_from_hash' do
  33. 1 it 'validates instance of LinksObject created by the build_from_hash method' do
  34. 1 links_object_from_hash = Bandwidth::LinksObject.build_from_hash({
  35. first: 'https://example.com/page/1',
  36. next: 'https://example.com/page/2',
  37. previous: 'https://example.com/page/0',
  38. last: 'https://example.com/page/9'
  39. })
  40. 1 expect(links_object_from_hash).to be_instance_of(Bandwidth::LinksObject)
  41. 1 expect(links_object_from_hash.first).to eq('https://example.com/page/1')
  42. 1 expect(links_object_from_hash._next).to eq('https://example.com/page/2')
  43. 1 expect(links_object_from_hash.previous).to eq('https://example.com/page/0')
  44. 1 expect(links_object_from_hash.last).to eq('https://example.com/page/9')
  45. end
  46. end
  47. 1 describe '#to_s' do
  48. 1 it 'returns a string representation of the object' do
  49. 1 expect(links_object_values.to_s).to eq('{:first=>"https://example.com/page/1", :next=>"https://example.com/page/2", :previous=>"https://example.com/page/0", :last=>"https://example.com/page/9"}')
  50. end
  51. end
  52. 1 describe '#eq? #==' do
  53. 1 it 'returns true/false when comparing objects' do
  54. 1 expect(links_object_default.eql?(Bandwidth::LinksObject.new)).to be true
  55. 1 expect(links_object_default.eql?(links_object_values)).to be false
  56. end
  57. end
  58. 1 describe '#to_body #to_hash' do
  59. 1 it 'returns a hash representation of the object' do
  60. 1 expect(links_object_values.to_body).to eq({
  61. first: 'https://example.com/page/1',
  62. next: 'https://example.com/page/2',
  63. previous: 'https://example.com/page/0',
  64. last: 'https://example.com/page/9'
  65. })
  66. end
  67. end
  68. end

spec/unit/models/list_endpoints_response_spec.rb

100.0% lines covered

47 relevant lines. 47 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::ListEndpointsResponse
  2. 1 describe Bandwidth::ListEndpointsResponse do
  3. 7 let(:page) { Bandwidth::Page.new({ page_size: 25, total_elements: 100, total_pages: 4, page_number: 1 }) }
  4. 7 let(:endpoint) { Bandwidth::Endpoints.new({
  5. endpoint_id: 'abc123',
  6. type: 'WEBRTC',
  7. status: 'CONNECTED',
  8. creation_timestamp: '2024-01-01T00:00:00Z',
  9. expiration_timestamp: '2024-01-02T00:00:00Z'
  10. }) }
  11. 2 let(:list_endpoints_response_default) { Bandwidth::ListEndpointsResponse.new({
  12. links: [],
  13. data: [],
  14. errors: []
  15. }) }
  16. 7 let(:list_endpoints_response_values) { Bandwidth::ListEndpointsResponse.new({
  17. links: [Bandwidth::BrtcLink.new({ href: 'https://example.com', rel: 'self', method: 'GET' })],
  18. page: page,
  19. data: [endpoint],
  20. errors: [Bandwidth::BrtcError.new({ type: 'validation', description: 'bad input' })]
  21. }) }
  22. 1 describe '#initialize' do
  23. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  24. 1 expect {
  25. 1 Bandwidth::ListEndpointsResponse.new([])
  26. }.to raise_error(ArgumentError)
  27. end
  28. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  29. 1 expect {
  30. 1 Bandwidth::ListEndpointsResponse.new({ invalid: true })
  31. }.to raise_error(ArgumentError)
  32. end
  33. end
  34. 1 describe '#acceptable_attributes' do
  35. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  36. 1 expect(Bandwidth::ListEndpointsResponse.acceptable_attributes).to eq(Bandwidth::ListEndpointsResponse.attribute_map.values)
  37. end
  38. end
  39. 1 describe '#openapi_nullable' do
  40. 1 it 'expects nullable attributes to be an empty set' do
  41. 1 expect(Bandwidth::ListEndpointsResponse.openapi_nullable).to eq(Set.new([]))
  42. end
  43. end
  44. 1 describe '#build_from_hash' do
  45. 1 it 'validates instance of ListEndpointsResponse created by the build_from_hash method' do
  46. 1 list_endpoints_response_from_hash = Bandwidth::ListEndpointsResponse.build_from_hash({
  47. links: [{ href: 'https://example.com', rel: 'self', method: 'GET' }],
  48. page: { pageSize: 25, totalElements: 100, totalPages: 4, pageNumber: 1 },
  49. data: [{ endpointId: 'abc123', type: 'WEBRTC', status: 'CONNECTED', creationTimestamp: '2024-01-01T00:00:00Z', expirationTimestamp: '2024-01-02T00:00:00Z' }],
  50. errors: [{ type: 'validation', description: 'bad input' }]
  51. })
  52. 1 expect(list_endpoints_response_from_hash).to be_instance_of(Bandwidth::ListEndpointsResponse)
  53. 1 expect(list_endpoints_response_from_hash.links.first).to be_instance_of(Bandwidth::BrtcLink)
  54. 1 expect(list_endpoints_response_from_hash.page).to be_instance_of(Bandwidth::Page)
  55. 1 expect(list_endpoints_response_from_hash.data.first).to be_instance_of(Bandwidth::Endpoints)
  56. 1 expect(list_endpoints_response_from_hash.errors.first).to be_instance_of(Bandwidth::BrtcError)
  57. end
  58. end
  59. 1 describe '#to_s' do
  60. 1 it 'returns a string representation of the object' do
  61. 1 expect(list_endpoints_response_values.to_s).to eq('{:links=>[{:href=>"https://example.com", :rel=>"self", :method=>"GET"}], :page=>{:pageSize=>25, :totalElements=>100, :totalPages=>4, :pageNumber=>1}, :data=>[{:endpointId=>"abc123", :type=>"WEBRTC", :status=>"CONNECTED", :creationTimestamp=>"2024-01-01T00:00:00Z", :expirationTimestamp=>"2024-01-02T00:00:00Z"}], :errors=>[{:type=>"validation", :description=>"bad input"}]}')
  62. end
  63. end
  64. 1 describe '#eq? #==' do
  65. 1 it 'returns true/false when comparing objects' do
  66. 1 list_endpoints_response_equal = Bandwidth::ListEndpointsResponse.new({
  67. links: [],
  68. data: [],
  69. errors: []
  70. })
  71. 1 expect(list_endpoints_response_default.eql?(list_endpoints_response_equal)).to be true
  72. 1 expect(list_endpoints_response_default.eql?(list_endpoints_response_values)).to be false
  73. end
  74. end
  75. 1 describe '#to_body #to_hash' do
  76. 1 it 'returns a hash representation of the object' do
  77. 1 expect(list_endpoints_response_values.to_body).to eq({
  78. links: [{ href: 'https://example.com', rel: 'self', method: 'GET' }],
  79. page: { pageSize: 25, totalElements: 100, totalPages: 4, pageNumber: 1 },
  80. data: [{ endpointId: 'abc123', type: 'WEBRTC', status: 'CONNECTED', creationTimestamp: '2024-01-01T00:00:00Z', expirationTimestamp: '2024-01-02T00:00:00Z' }],
  81. errors: [{ type: 'validation', description: 'bad input' }]
  82. })
  83. end
  84. end
  85. 1 describe 'custom attribute writers' do
  86. 1 it '#links=' do
  87. 1 expect {
  88. 1 list_endpoints_response_values.links = nil
  89. }.to raise_error(ArgumentError, 'links cannot be nil')
  90. end
  91. 1 it '#data=' do
  92. 1 expect {
  93. 1 list_endpoints_response_values.data = nil
  94. }.to raise_error(ArgumentError, 'data cannot be nil')
  95. end
  96. 1 it '#errors=' do
  97. 1 expect {
  98. 1 list_endpoints_response_values.errors = nil
  99. }.to raise_error(ArgumentError, 'errors cannot be nil')
  100. end
  101. end
  102. end

spec/unit/models/list_message_direction_enum_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::ListMessageDirectionEnum
  2. 1 describe Bandwidth::ListMessageDirectionEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines INBOUND' do
  5. 1 expect(Bandwidth::ListMessageDirectionEnum::INBOUND).to eq('INBOUND')
  6. end
  7. 1 it 'defines OUTBOUND' do
  8. 1 expect(Bandwidth::ListMessageDirectionEnum::OUTBOUND).to eq('OUTBOUND')
  9. end
  10. end
  11. 1 describe '.all_vars' do
  12. 1 it 'returns every valid enum value' do
  13. 1 expect(Bandwidth::ListMessageDirectionEnum.all_vars).to eq([
  14. 'INBOUND',
  15. 'OUTBOUND'
  16. ])
  17. end
  18. end
  19. 1 describe '.build_from_hash' do
  20. 1 it 'returns the value when it matches a valid enum value' do
  21. 1 expect(Bandwidth::ListMessageDirectionEnum.build_from_hash('INBOUND')).to eq('INBOUND')
  22. 1 expect(Bandwidth::ListMessageDirectionEnum.build_from_hash('OUTBOUND')).to eq('OUTBOUND')
  23. end
  24. 1 it 'raises an error for an invalid enum value' do
  25. 1 expect {
  26. 1 Bandwidth::ListMessageDirectionEnum.build_from_hash('invalid')
  27. }.to raise_error(RuntimeError)
  28. end
  29. end
  30. end

spec/unit/models/list_message_item_spec.rb

100.0% lines covered

53 relevant lines. 53 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::ListMessageItem
  2. 1 describe Bandwidth::ListMessageItem do
  3. 2 let(:list_message_item_default) { Bandwidth::ListMessageItem.new }
  4. 4 let(:list_message_item_values) { Bandwidth::ListMessageItem.new({
  5. message_id: '1589228074636lm4k2je7j7jklbn2',
  6. account_id: '9900000',
  7. source_tn: '+19195554321',
  8. destination_tn: '+19195551234',
  9. message_status: Bandwidth::MessageStatusEnum::DELIVERED,
  10. message_direction: Bandwidth::ListMessageDirectionEnum::OUTBOUND,
  11. message_type: Bandwidth::MessageTypeEnum::SMS,
  12. segment_count: 1,
  13. error_code: 0,
  14. receive_time: '2022-06-16T13:15:07.160Z',
  15. carrier_name: 'verizon',
  16. message_size: 27,
  17. message_length: 18,
  18. attachment_count: 0,
  19. recipient_count: 1,
  20. campaign_class: 'T',
  21. campaign_id: 'CABC123',
  22. bw_latency: 1,
  23. carrier_latency: 2,
  24. calling_number_country_a3: 'USA',
  25. called_number_country_a3: 'USA',
  26. product: 'MESSAGING-V2',
  27. location: 'loc-1'
  28. }) }
  29. 1 describe '#initialize' do
  30. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  31. 1 expect {
  32. 1 Bandwidth::ListMessageItem.new([])
  33. }.to raise_error(ArgumentError)
  34. end
  35. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  36. 1 expect {
  37. 1 Bandwidth::ListMessageItem.new({ invalid: true })
  38. }.to raise_error(ArgumentError)
  39. end
  40. end
  41. 1 describe '#acceptable_attributes' do
  42. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  43. 1 expect(Bandwidth::ListMessageItem.acceptable_attributes).to eq(Bandwidth::ListMessageItem.attribute_map.values)
  44. end
  45. end
  46. 1 describe '#openapi_nullable' do
  47. 1 it 'expects nullable attributes to be the set of nullable fields' do
  48. 1 expect(Bandwidth::ListMessageItem.openapi_nullable).to eq(Set.new([
  49. :'carrier_name',
  50. :'message_size',
  51. :'attachment_count',
  52. :'recipient_count',
  53. :'campaign_class',
  54. :'campaign_id',
  55. :'bw_latency',
  56. :'carrier_latency',
  57. :'calling_number_country_a3',
  58. :'called_number_country_a3',
  59. :'product',
  60. :'location'
  61. ]))
  62. end
  63. end
  64. 1 describe '#build_from_hash' do
  65. 1 it 'validates instance of ListMessageItem created by the build_from_hash method' do
  66. 1 list_message_item_from_hash = Bandwidth::ListMessageItem.build_from_hash({
  67. messageId: '1589228074636lm4k2je7j7jklbn2',
  68. accountId: '9900000',
  69. sourceTn: '+19195554321',
  70. destinationTn: '+19195551234',
  71. messageStatus: 'DELIVERED',
  72. messageDirection: 'OUTBOUND',
  73. messageType: 'sms',
  74. segmentCount: 1,
  75. errorCode: 0,
  76. receiveTime: '2022-06-16T13:15:07.160Z',
  77. carrierName: 'verizon',
  78. messageSize: 27,
  79. messageLength: 18,
  80. attachmentCount: 0,
  81. recipientCount: 1,
  82. campaignClass: 'T',
  83. campaignId: 'CABC123',
  84. bwLatency: 1,
  85. carrierLatency: 2,
  86. callingNumberCountryA3: 'USA',
  87. calledNumberCountryA3: 'USA',
  88. product: 'MESSAGING-V2',
  89. location: 'loc-1'
  90. })
  91. 1 expect(list_message_item_from_hash).to be_instance_of(Bandwidth::ListMessageItem)
  92. 1 expect(list_message_item_from_hash.message_id).to eq('1589228074636lm4k2je7j7jklbn2')
  93. 1 expect(list_message_item_from_hash.account_id).to eq('9900000')
  94. 1 expect(list_message_item_from_hash.source_tn).to eq('+19195554321')
  95. 1 expect(list_message_item_from_hash.destination_tn).to eq('+19195551234')
  96. 1 expect(list_message_item_from_hash.message_status).to eq('DELIVERED')
  97. 1 expect(list_message_item_from_hash.message_direction).to eq('OUTBOUND')
  98. 1 expect(list_message_item_from_hash.message_type).to eq('sms')
  99. 1 expect(list_message_item_from_hash.segment_count).to eq(1)
  100. 1 expect(list_message_item_from_hash.error_code).to eq(0)
  101. 1 expect(list_message_item_from_hash.receive_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  102. 1 expect(list_message_item_from_hash.carrier_name).to eq('verizon')
  103. 1 expect(list_message_item_from_hash.message_size).to eq(27)
  104. 1 expect(list_message_item_from_hash.message_length).to eq(18)
  105. 1 expect(list_message_item_from_hash.attachment_count).to eq(0)
  106. 1 expect(list_message_item_from_hash.recipient_count).to eq(1)
  107. 1 expect(list_message_item_from_hash.campaign_class).to eq('T')
  108. 1 expect(list_message_item_from_hash.campaign_id).to eq('CABC123')
  109. 1 expect(list_message_item_from_hash.bw_latency).to eq(1)
  110. 1 expect(list_message_item_from_hash.carrier_latency).to eq(2)
  111. 1 expect(list_message_item_from_hash.calling_number_country_a3).to eq('USA')
  112. 1 expect(list_message_item_from_hash.called_number_country_a3).to eq('USA')
  113. 1 expect(list_message_item_from_hash.product).to eq('MESSAGING-V2')
  114. 1 expect(list_message_item_from_hash.location).to eq('loc-1')
  115. end
  116. end
  117. 1 describe '#to_s' do
  118. 1 it 'returns a string representation of the object' do
  119. 1 expect(list_message_item_values.to_s).to eq('{:messageId=>"1589228074636lm4k2je7j7jklbn2", :accountId=>"9900000", :sourceTn=>"+19195554321", :destinationTn=>"+19195551234", :messageStatus=>"DELIVERED", :messageDirection=>"OUTBOUND", :messageType=>"sms", :segmentCount=>1, :errorCode=>0, :receiveTime=>"2022-06-16T13:15:07.160Z", :carrierName=>"verizon", :messageSize=>27, :messageLength=>18, :attachmentCount=>0, :recipientCount=>1, :campaignClass=>"T", :campaignId=>"CABC123", :bwLatency=>1, :carrierLatency=>2, :callingNumberCountryA3=>"USA", :calledNumberCountryA3=>"USA", :product=>"MESSAGING-V2", :location=>"loc-1"}')
  120. end
  121. end
  122. 1 describe '#eq? #==' do
  123. 1 it 'returns true/false when comparing objects' do
  124. 1 expect(list_message_item_default.eql?(Bandwidth::ListMessageItem.new)).to be true
  125. 1 expect(list_message_item_default.eql?(list_message_item_values)).to be false
  126. end
  127. end
  128. 1 describe '#to_body #to_hash' do
  129. 1 it 'returns a hash representation of the object' do
  130. 1 expect(list_message_item_values.to_body).to eq({
  131. messageId: '1589228074636lm4k2je7j7jklbn2',
  132. accountId: '9900000',
  133. sourceTn: '+19195554321',
  134. destinationTn: '+19195551234',
  135. messageStatus: Bandwidth::MessageStatusEnum::DELIVERED,
  136. messageDirection: Bandwidth::ListMessageDirectionEnum::OUTBOUND,
  137. messageType: Bandwidth::MessageTypeEnum::SMS,
  138. segmentCount: 1,
  139. errorCode: 0,
  140. receiveTime: '2022-06-16T13:15:07.160Z',
  141. carrierName: 'verizon',
  142. messageSize: 27,
  143. messageLength: 18,
  144. attachmentCount: 0,
  145. recipientCount: 1,
  146. campaignClass: 'T',
  147. campaignId: 'CABC123',
  148. bwLatency: 1,
  149. carrierLatency: 2,
  150. callingNumberCountryA3: 'USA',
  151. calledNumberCountryA3: 'USA',
  152. product: 'MESSAGING-V2',
  153. location: 'loc-1'
  154. })
  155. end
  156. end
  157. end

spec/unit/models/lookup_error_response_spec.rb

100.0% lines covered

33 relevant lines. 33 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::LookupErrorResponse
  2. 1 describe Bandwidth::LookupErrorResponse do
  3. 2 let(:lookup_error_response_default) { Bandwidth::LookupErrorResponse.new }
  4. 4 let(:lookup_error_response_values) { Bandwidth::LookupErrorResponse.new({
  5. links: [Bandwidth::LinkSchema.new({ href: 'https://example.com', rel: 'self', method: 'GET' })],
  6. data: { foo: 'bar' },
  7. errors: [Bandwidth::LookupErrorSchema.new({ code: '400', description: 'bad request', type: 'validation' })]
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::LookupErrorResponse.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::LookupErrorResponse.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::LookupErrorResponse.acceptable_attributes).to eq(Bandwidth::LookupErrorResponse.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be an empty set' do
  28. 1 expect(Bandwidth::LookupErrorResponse.openapi_nullable).to eq(Set.new([]))
  29. end
  30. end
  31. 1 describe '#build_from_hash' do
  32. 1 it 'validates instance of LookupErrorResponse created by the build_from_hash method' do
  33. 1 lookup_error_response_from_hash = Bandwidth::LookupErrorResponse.build_from_hash({
  34. links: [{ href: 'https://example.com', rel: 'self', method: 'GET' }],
  35. data: { foo: 'bar' },
  36. errors: [{ code: '400', description: 'bad request', type: 'validation' }]
  37. })
  38. 1 expect(lookup_error_response_from_hash).to be_instance_of(Bandwidth::LookupErrorResponse)
  39. 1 expect(lookup_error_response_from_hash.links.first).to be_instance_of(Bandwidth::LinkSchema)
  40. 1 expect(lookup_error_response_from_hash.data).to eq({ foo: 'bar' })
  41. 1 expect(lookup_error_response_from_hash.errors.first).to be_instance_of(Bandwidth::LookupErrorSchema)
  42. end
  43. end
  44. 1 describe '#to_s' do
  45. 1 it 'returns a string representation of the object' do
  46. 1 expect(lookup_error_response_values.to_s).to eq('{:links=>[{:href=>"https://example.com", :rel=>"self", :method=>"GET"}], :data=>{:foo=>"bar"}, :errors=>[{:code=>"400", :description=>"bad request", :type=>"validation"}]}')
  47. end
  48. end
  49. 1 describe '#eq? #==' do
  50. 1 it 'returns true/false when comparing objects' do
  51. 1 expect(lookup_error_response_default.eql?(Bandwidth::LookupErrorResponse.new)).to be true
  52. 1 expect(lookup_error_response_default.eql?(lookup_error_response_values)).to be false
  53. end
  54. end
  55. 1 describe '#to_body #to_hash' do
  56. 1 it 'returns a hash representation of the object' do
  57. 1 expect(lookup_error_response_values.to_body).to eq({
  58. links: [{ href: 'https://example.com', rel: 'self', method: 'GET' }],
  59. data: { foo: 'bar' },
  60. errors: [{ code: '400', description: 'bad request', type: 'validation' }]
  61. })
  62. end
  63. end
  64. end

spec/unit/models/lookup_error_schema_meta_spec.rb

100.0% lines covered

33 relevant lines. 33 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::LookupErrorSchemaMeta
  2. 1 describe Bandwidth::LookupErrorSchemaMeta do
  3. 2 let(:lookup_error_schema_meta_default) { Bandwidth::LookupErrorSchemaMeta.new }
  4. 4 let(:lookup_error_schema_meta_values) { Bandwidth::LookupErrorSchemaMeta.new({
  5. phone_numbers: ['+19195551234'],
  6. message: 'invalid phone number',
  7. code: 400
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::LookupErrorSchemaMeta.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::LookupErrorSchemaMeta.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::LookupErrorSchemaMeta.acceptable_attributes).to eq(Bandwidth::LookupErrorSchemaMeta.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be an empty set' do
  28. 1 expect(Bandwidth::LookupErrorSchemaMeta.openapi_nullable).to eq(Set.new([]))
  29. end
  30. end
  31. 1 describe '#build_from_hash' do
  32. 1 it 'validates instance of LookupErrorSchemaMeta created by the build_from_hash method' do
  33. 1 lookup_error_schema_meta_from_hash = Bandwidth::LookupErrorSchemaMeta.build_from_hash({
  34. phoneNumbers: ['+19195551234'],
  35. message: 'invalid phone number',
  36. code: 400
  37. })
  38. 1 expect(lookup_error_schema_meta_from_hash).to be_instance_of(Bandwidth::LookupErrorSchemaMeta)
  39. 1 expect(lookup_error_schema_meta_from_hash.phone_numbers).to eq(['+19195551234'])
  40. 1 expect(lookup_error_schema_meta_from_hash.message).to eq('invalid phone number')
  41. 1 expect(lookup_error_schema_meta_from_hash.code).to eq(400)
  42. end
  43. end
  44. 1 describe '#to_s' do
  45. 1 it 'returns a string representation of the object' do
  46. 1 expect(lookup_error_schema_meta_values.to_s).to eq('{:phoneNumbers=>["+19195551234"], :message=>"invalid phone number", :code=>400}')
  47. end
  48. end
  49. 1 describe '#eq? #==' do
  50. 1 it 'returns true/false when comparing objects' do
  51. 1 expect(lookup_error_schema_meta_default.eql?(Bandwidth::LookupErrorSchemaMeta.new)).to be true
  52. 1 expect(lookup_error_schema_meta_default.eql?(lookup_error_schema_meta_values)).to be false
  53. end
  54. end
  55. 1 describe '#to_body #to_hash' do
  56. 1 it 'returns a hash representation of the object' do
  57. 1 expect(lookup_error_schema_meta_values.to_body).to eq({
  58. phoneNumbers: ['+19195551234'],
  59. message: 'invalid phone number',
  60. code: 400
  61. })
  62. end
  63. end
  64. end

spec/unit/models/lookup_error_schema_spec.rb

100.0% lines covered

45 relevant lines. 45 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::LookupErrorSchema
  2. 1 describe Bandwidth::LookupErrorSchema do
  3. 2 let(:lookup_error_schema_default) { Bandwidth::LookupErrorSchema.new({
  4. code: '400',
  5. description: 'baseline description',
  6. type: 'baseline'
  7. }) }
  8. 4 let(:lookup_error_schema_values) { Bandwidth::LookupErrorSchema.new({
  9. code: '404',
  10. description: 'not found',
  11. type: 'validation',
  12. meta: Bandwidth::LookupErrorSchemaMeta.new({ phone_numbers: ['+19195551234'], message: 'invalid', code: 404 })
  13. }) }
  14. 1 describe '#initialize' do
  15. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::LookupErrorSchema.new([])
  18. }.to raise_error(ArgumentError)
  19. end
  20. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  21. 1 expect {
  22. 1 Bandwidth::LookupErrorSchema.new({ invalid: true })
  23. }.to raise_error(ArgumentError)
  24. end
  25. end
  26. 1 describe '#acceptable_attributes' do
  27. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  28. 1 expect(Bandwidth::LookupErrorSchema.acceptable_attributes).to eq(Bandwidth::LookupErrorSchema.attribute_map.values)
  29. end
  30. end
  31. 1 describe '#openapi_nullable' do
  32. 1 it 'expects nullable attributes to be an empty set' do
  33. 1 expect(Bandwidth::LookupErrorSchema.openapi_nullable).to eq(Set.new([]))
  34. end
  35. end
  36. 1 describe '#build_from_hash' do
  37. 1 it 'validates instance of LookupErrorSchema created by the build_from_hash method' do
  38. 1 lookup_error_schema_from_hash = Bandwidth::LookupErrorSchema.build_from_hash({
  39. code: '404',
  40. description: 'not found',
  41. type: 'validation',
  42. meta: { phoneNumbers: ['+19195551234'], message: 'invalid', code: 404 }
  43. })
  44. 1 expect(lookup_error_schema_from_hash).to be_instance_of(Bandwidth::LookupErrorSchema)
  45. 1 expect(lookup_error_schema_from_hash.code).to eq('404')
  46. 1 expect(lookup_error_schema_from_hash.description).to eq('not found')
  47. 1 expect(lookup_error_schema_from_hash.type).to eq('validation')
  48. 1 expect(lookup_error_schema_from_hash.meta).to be_instance_of(Bandwidth::LookupErrorSchemaMeta)
  49. end
  50. end
  51. 1 describe '#to_s' do
  52. 1 it 'returns a string representation of the object' do
  53. 1 expect(lookup_error_schema_values.to_s).to eq('{:code=>"404", :description=>"not found", :type=>"validation", :meta=>{:phoneNumbers=>["+19195551234"], :message=>"invalid", :code=>404}}')
  54. end
  55. end
  56. 1 describe '#eq? #==' do
  57. 1 it 'returns true/false when comparing objects' do
  58. 1 lookup_error_schema_equal = Bandwidth::LookupErrorSchema.new({
  59. code: '400',
  60. description: 'baseline description',
  61. type: 'baseline'
  62. })
  63. 1 expect(lookup_error_schema_default.eql?(lookup_error_schema_equal)).to be true
  64. 1 expect(lookup_error_schema_default.eql?(lookup_error_schema_values)).to be false
  65. end
  66. end
  67. 1 describe '#to_body #to_hash' do
  68. 1 it 'returns a hash representation of the object' do
  69. 1 expect(lookup_error_schema_values.to_body).to eq({
  70. code: '404',
  71. description: 'not found',
  72. type: 'validation',
  73. meta: { phoneNumbers: ['+19195551234'], message: 'invalid', code: 404 }
  74. })
  75. end
  76. end
  77. 1 describe 'custom attribute writers' do
  78. 1 it '#code=' do
  79. 1 expect {
  80. 1 Bandwidth::LookupErrorSchema.new({ code: nil })
  81. }.to raise_error(ArgumentError, 'code cannot be nil')
  82. end
  83. 1 it '#description=' do
  84. 1 expect {
  85. 1 Bandwidth::LookupErrorSchema.new({ code: '400', description: nil })
  86. }.to raise_error(ArgumentError, 'description cannot be nil')
  87. end
  88. 1 it '#type=' do
  89. 1 expect {
  90. 1 Bandwidth::LookupErrorSchema.new({ code: '400', description: 'a', type: nil })
  91. }.to raise_error(ArgumentError, 'type cannot be nil')
  92. end
  93. end
  94. end

spec/unit/models/lookup_result_spec.rb

100.0% lines covered

42 relevant lines. 42 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::LookupResult
  2. 1 describe Bandwidth::LookupResult do
  3. 2 let(:lookup_result_default) { Bandwidth::LookupResult.new }
  4. 4 let(:lookup_result_values) { Bandwidth::LookupResult.new({
  5. phone_number: '+19195551234',
  6. line_type: Bandwidth::LineTypeEnum::MOBILE,
  7. messaging_provider: 'Bandwidth',
  8. voice_provider: 'Bandwidth',
  9. country_code_a3: 'USA',
  10. deactivation_reporter: 'verizon',
  11. deactivation_date: '2024-01-01',
  12. deactivation_event: Bandwidth::DeactivationEventEnum::DEACTIVATED,
  13. latest_message_delivery_status: Bandwidth::LatestMessageDeliveryStatusEnum::ACTIVE,
  14. initial_message_delivery_status_date: '2024-01-01',
  15. latest_message_delivery_status_date: '2024-01-02',
  16. rcs_enabled: true
  17. }) }
  18. 1 describe '#initialize' do
  19. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  20. 1 expect {
  21. 1 Bandwidth::LookupResult.new([])
  22. }.to raise_error(ArgumentError)
  23. end
  24. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  25. 1 expect {
  26. 1 Bandwidth::LookupResult.new({ invalid: true })
  27. }.to raise_error(ArgumentError)
  28. end
  29. end
  30. 1 describe '#acceptable_attributes' do
  31. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  32. 1 expect(Bandwidth::LookupResult.acceptable_attributes).to eq(Bandwidth::LookupResult.attribute_map.values)
  33. end
  34. end
  35. 1 describe '#openapi_nullable' do
  36. 1 it 'expects nullable attributes to be an empty set' do
  37. 1 expect(Bandwidth::LookupResult.openapi_nullable).to eq(Set.new([]))
  38. end
  39. end
  40. 1 describe '#build_from_hash' do
  41. 1 it 'validates instance of LookupResult created by the build_from_hash method' do
  42. 1 lookup_result_from_hash = Bandwidth::LookupResult.build_from_hash({
  43. phoneNumber: '+19195551234',
  44. lineType: 'MOBILE',
  45. messagingProvider: 'Bandwidth',
  46. voiceProvider: 'Bandwidth',
  47. countryCodeA3: 'USA',
  48. deactivationReporter: 'verizon',
  49. deactivationDate: '2024-01-01',
  50. deactivationEvent: 'DEACTIVATED',
  51. latestMessageDeliveryStatus: 'ACTIVE',
  52. initialMessageDeliveryStatusDate: '2024-01-01',
  53. latestMessageDeliveryStatusDate: '2024-01-02',
  54. rcsEnabled: true
  55. })
  56. 1 expect(lookup_result_from_hash).to be_instance_of(Bandwidth::LookupResult)
  57. 1 expect(lookup_result_from_hash.phone_number).to eq('+19195551234')
  58. 1 expect(lookup_result_from_hash.line_type).to eq('MOBILE')
  59. 1 expect(lookup_result_from_hash.messaging_provider).to eq('Bandwidth')
  60. 1 expect(lookup_result_from_hash.voice_provider).to eq('Bandwidth')
  61. 1 expect(lookup_result_from_hash.country_code_a3).to eq('USA')
  62. 1 expect(lookup_result_from_hash.deactivation_reporter).to eq('verizon')
  63. 1 expect(lookup_result_from_hash.deactivation_date).to eq('2024-01-01')
  64. 1 expect(lookup_result_from_hash.deactivation_event).to eq('DEACTIVATED')
  65. 1 expect(lookup_result_from_hash.latest_message_delivery_status).to eq('ACTIVE')
  66. 1 expect(lookup_result_from_hash.initial_message_delivery_status_date).to eq(Date.parse('2024-01-01'))
  67. 1 expect(lookup_result_from_hash.latest_message_delivery_status_date).to eq(Date.parse('2024-01-02'))
  68. 1 expect(lookup_result_from_hash.rcs_enabled).to eq(true)
  69. end
  70. end
  71. 1 describe '#to_s' do
  72. 1 it 'returns a string representation of the object' do
  73. 1 expect(lookup_result_values.to_s).to eq('{:phoneNumber=>"+19195551234", :lineType=>"MOBILE", :messagingProvider=>"Bandwidth", :voiceProvider=>"Bandwidth", :countryCodeA3=>"USA", :deactivationReporter=>"verizon", :deactivationDate=>"2024-01-01", :deactivationEvent=>"DEACTIVATED", :latestMessageDeliveryStatus=>"ACTIVE", :initialMessageDeliveryStatusDate=>"2024-01-01", :latestMessageDeliveryStatusDate=>"2024-01-02", :rcsEnabled=>true}')
  74. end
  75. end
  76. 1 describe '#eq? #==' do
  77. 1 it 'returns true/false when comparing objects' do
  78. 1 expect(lookup_result_default.eql?(Bandwidth::LookupResult.new)).to be true
  79. 1 expect(lookup_result_default.eql?(lookup_result_values)).to be false
  80. end
  81. end
  82. 1 describe '#to_body #to_hash' do
  83. 1 it 'returns a hash representation of the object' do
  84. 1 expect(lookup_result_values.to_body).to eq({
  85. phoneNumber: '+19195551234',
  86. lineType: Bandwidth::LineTypeEnum::MOBILE,
  87. messagingProvider: 'Bandwidth',
  88. voiceProvider: 'Bandwidth',
  89. countryCodeA3: 'USA',
  90. deactivationReporter: 'verizon',
  91. deactivationDate: '2024-01-01',
  92. deactivationEvent: Bandwidth::DeactivationEventEnum::DEACTIVATED,
  93. latestMessageDeliveryStatus: Bandwidth::LatestMessageDeliveryStatusEnum::ACTIVE,
  94. initialMessageDeliveryStatusDate: '2024-01-01',
  95. latestMessageDeliveryStatusDate: '2024-01-02',
  96. rcsEnabled: true
  97. })
  98. end
  99. end
  100. end

spec/unit/models/machine_detection_complete_callback_spec.rb

100.0% lines covered

46 relevant lines. 46 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MachineDetectionCompleteCallback
  2. 1 describe Bandwidth::MachineDetectionCompleteCallback do
  3. 2 let(:machine_detection_complete_callback_default) { Bandwidth::MachineDetectionCompleteCallback.new }
  4. 4 let(:machine_detection_complete_callback_values) { Bandwidth::MachineDetectionCompleteCallback.new({
  5. event_type: 'machineDetectionComplete',
  6. event_time: '2022-06-16T13:15:07.160Z',
  7. account_id: '9900000',
  8. application_id: '04e88489-df02-4e34-a0ee-27a91849555f',
  9. from: '+19195554321',
  10. to: '+19195551234',
  11. direction: Bandwidth::CallDirectionEnum::OUTBOUND,
  12. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  13. call_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  14. enqueued_time: '2022-06-16T13:15:07.160Z',
  15. start_time: '2022-06-16T13:15:07.160Z',
  16. answer_time: '2022-06-16T13:15:18.126Z',
  17. tag: 'custom tag',
  18. machine_detection_result: { value: 'human', duration: 'PT5S' }
  19. }) }
  20. 1 describe '#initialize' do
  21. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  22. 1 expect {
  23. 1 Bandwidth::MachineDetectionCompleteCallback.new([])
  24. }.to raise_error(ArgumentError)
  25. end
  26. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  27. 1 expect {
  28. 1 Bandwidth::MachineDetectionCompleteCallback.new({ invalid: true })
  29. }.to raise_error(ArgumentError)
  30. end
  31. end
  32. 1 describe '#acceptable_attributes' do
  33. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  34. 1 expect(Bandwidth::MachineDetectionCompleteCallback.acceptable_attributes).to eq(Bandwidth::MachineDetectionCompleteCallback.attribute_map.values)
  35. end
  36. end
  37. 1 describe '#openapi_nullable' do
  38. 1 it 'expects nullable attributes to be the set of nullable fields' do
  39. 1 expect(Bandwidth::MachineDetectionCompleteCallback.openapi_nullable).to eq(Set.new([
  40. :'enqueued_time',
  41. :'answer_time',
  42. :'tag',
  43. :'machine_detection_result'
  44. ]))
  45. end
  46. end
  47. 1 describe '#build_from_hash' do
  48. 1 it 'validates instance of MachineDetectionCompleteCallback created by the build_from_hash method' do
  49. 1 machine_detection_complete_callback_from_hash = Bandwidth::MachineDetectionCompleteCallback.build_from_hash({
  50. eventType: 'machineDetectionComplete',
  51. eventTime: '2022-06-16T13:15:07.160Z',
  52. accountId: '9900000',
  53. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  54. from: '+19195554321',
  55. to: '+19195551234',
  56. direction: Bandwidth::CallDirectionEnum::OUTBOUND,
  57. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  58. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  59. enqueuedTime: '2022-06-16T13:15:07.160Z',
  60. startTime: '2022-06-16T13:15:07.160Z',
  61. answerTime: '2022-06-16T13:15:18.126Z',
  62. tag: 'custom tag',
  63. machineDetectionResult: { value: 'human', duration: 'PT5S' }
  64. })
  65. 1 expect(machine_detection_complete_callback_from_hash).to be_instance_of(Bandwidth::MachineDetectionCompleteCallback)
  66. 1 expect(machine_detection_complete_callback_from_hash.event_type).to eq('machineDetectionComplete')
  67. 1 expect(machine_detection_complete_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  68. 1 expect(machine_detection_complete_callback_from_hash.account_id).to eq('9900000')
  69. 1 expect(machine_detection_complete_callback_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f')
  70. 1 expect(machine_detection_complete_callback_from_hash.from).to eq('+19195554321')
  71. 1 expect(machine_detection_complete_callback_from_hash.to).to eq('+19195551234')
  72. 1 expect(machine_detection_complete_callback_from_hash.direction).to eq(Bandwidth::CallDirectionEnum::OUTBOUND)
  73. 1 expect(machine_detection_complete_callback_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  74. 1 expect(machine_detection_complete_callback_from_hash.call_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  75. 1 expect(machine_detection_complete_callback_from_hash.enqueued_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  76. 1 expect(machine_detection_complete_callback_from_hash.start_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  77. 1 expect(machine_detection_complete_callback_from_hash.answer_time).to eq(Time.parse('2022-06-16T13:15:18.126Z'))
  78. 1 expect(machine_detection_complete_callback_from_hash.tag).to eq('custom tag')
  79. 1 expect(machine_detection_complete_callback_from_hash.machine_detection_result).to be_instance_of(Bandwidth::MachineDetectionResult)
  80. 1 expect(machine_detection_complete_callback_from_hash.machine_detection_result.value).to eq('human')
  81. 1 expect(machine_detection_complete_callback_from_hash.machine_detection_result.duration).to eq('PT5S')
  82. end
  83. end
  84. 1 describe '#to_s' do
  85. 1 it 'returns a string representation of the object' do
  86. 1 expect(machine_detection_complete_callback_values.to_s).to eq('{:eventType=>"machineDetectionComplete", :eventTime=>"2022-06-16T13:15:07.160Z", :accountId=>"9900000", :applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :from=>"+19195554321", :to=>"+19195551234", :direction=>"outbound", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :callUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :enqueuedTime=>"2022-06-16T13:15:07.160Z", :startTime=>"2022-06-16T13:15:07.160Z", :answerTime=>"2022-06-16T13:15:18.126Z", :tag=>"custom tag", :machineDetectionResult=>{:value=>"human", :duration=>"PT5S"}}')
  87. end
  88. end
  89. 1 describe '#eq? #==' do
  90. 1 it 'returns true/false when comparing objects' do
  91. 1 expect(machine_detection_complete_callback_default.eql?(Bandwidth::MachineDetectionCompleteCallback.new)).to be true
  92. 1 expect(machine_detection_complete_callback_default.eql?(machine_detection_complete_callback_values)).to be false
  93. end
  94. end
  95. 1 describe '#to_body #to_hash' do
  96. 1 it 'returns a hash representation of the object' do
  97. 1 expect(machine_detection_complete_callback_values.to_body).to eq({
  98. eventType: 'machineDetectionComplete',
  99. eventTime: '2022-06-16T13:15:07.160Z',
  100. accountId: '9900000',
  101. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  102. from: '+19195554321',
  103. to: '+19195551234',
  104. direction: Bandwidth::CallDirectionEnum::OUTBOUND,
  105. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  106. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  107. enqueuedTime: '2022-06-16T13:15:07.160Z',
  108. startTime: '2022-06-16T13:15:07.160Z',
  109. answerTime: '2022-06-16T13:15:18.126Z',
  110. tag: 'custom tag',
  111. machineDetectionResult: { value: 'human', duration: 'PT5S' }
  112. })
  113. end
  114. end
  115. end

spec/unit/models/machine_detection_configuration_spec.rb

100.0% lines covered

64 relevant lines. 64 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MachineDetectionConfiguration
  2. 1 describe Bandwidth::MachineDetectionConfiguration do
  3. 2 let(:machine_detection_configuration_default) { Bandwidth::MachineDetectionConfiguration.new }
  4. 4 let(:machine_detection_configuration_values) { Bandwidth::MachineDetectionConfiguration.new({
  5. mode: Bandwidth::MachineDetectionModeEnum::SYNC,
  6. detection_timeout: 20,
  7. silence_timeout: 12,
  8. speech_threshold: 8,
  9. speech_end_threshold: 4,
  10. machine_speech_end_threshold: 7,
  11. delay_result: true,
  12. callback_url: 'https://example.com/callback',
  13. callback_method: Bandwidth::CallbackMethodEnum::GET,
  14. username: 'user',
  15. password: 'pass',
  16. fallback_url: 'https://example.com/fallback',
  17. fallback_method: Bandwidth::CallbackMethodEnum::GET,
  18. fallback_username: 'fallback-user',
  19. fallback_password: 'fallback-pass'
  20. }) }
  21. 1 describe '#initialize' do
  22. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  23. 1 expect {
  24. 1 Bandwidth::MachineDetectionConfiguration.new([])
  25. }.to raise_error(ArgumentError)
  26. end
  27. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  28. 1 expect {
  29. 1 Bandwidth::MachineDetectionConfiguration.new({ invalid: true })
  30. }.to raise_error(ArgumentError)
  31. end
  32. end
  33. 1 describe '#acceptable_attributes' do
  34. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  35. 1 expect(Bandwidth::MachineDetectionConfiguration.acceptable_attributes).to eq(Bandwidth::MachineDetectionConfiguration.attribute_map.values)
  36. end
  37. end
  38. 1 describe '#openapi_nullable' do
  39. 1 it 'expects nullable attributes to be the set of nullable fields' do
  40. 1 expect(Bandwidth::MachineDetectionConfiguration.openapi_nullable).to eq(Set.new([
  41. :'detection_timeout',
  42. :'silence_timeout',
  43. :'speech_threshold',
  44. :'speech_end_threshold',
  45. :'machine_speech_end_threshold',
  46. :'delay_result',
  47. :'callback_url',
  48. :'callback_method',
  49. :'username',
  50. :'password',
  51. :'fallback_url',
  52. :'fallback_method',
  53. :'fallback_username',
  54. :'fallback_password'
  55. ]))
  56. end
  57. end
  58. 1 describe '#build_from_hash' do
  59. 1 it 'validates instance of MachineDetectionConfiguration created by the build_from_hash method' do
  60. 1 machine_detection_configuration_from_hash = Bandwidth::MachineDetectionConfiguration.build_from_hash({
  61. mode: 'sync',
  62. detectionTimeout: 20,
  63. silenceTimeout: 12,
  64. speechThreshold: 8,
  65. speechEndThreshold: 4,
  66. machineSpeechEndThreshold: 7,
  67. delayResult: true,
  68. callbackUrl: 'https://example.com/callback',
  69. callbackMethod: 'GET',
  70. username: 'user',
  71. password: 'pass',
  72. fallbackUrl: 'https://example.com/fallback',
  73. fallbackMethod: 'GET',
  74. fallbackUsername: 'fallback-user',
  75. fallbackPassword: 'fallback-pass'
  76. })
  77. 1 expect(machine_detection_configuration_from_hash).to be_instance_of(Bandwidth::MachineDetectionConfiguration)
  78. 1 expect(machine_detection_configuration_from_hash.mode).to eq('sync')
  79. 1 expect(machine_detection_configuration_from_hash.detection_timeout).to eq(20.0)
  80. 1 expect(machine_detection_configuration_from_hash.silence_timeout).to eq(12.0)
  81. 1 expect(machine_detection_configuration_from_hash.speech_threshold).to eq(8.0)
  82. 1 expect(machine_detection_configuration_from_hash.speech_end_threshold).to eq(4.0)
  83. 1 expect(machine_detection_configuration_from_hash.machine_speech_end_threshold).to eq(7.0)
  84. 1 expect(machine_detection_configuration_from_hash.delay_result).to eq(true)
  85. 1 expect(machine_detection_configuration_from_hash.callback_url).to eq('https://example.com/callback')
  86. 1 expect(machine_detection_configuration_from_hash.callback_method).to eq('GET')
  87. 1 expect(machine_detection_configuration_from_hash.username).to eq('user')
  88. 1 expect(machine_detection_configuration_from_hash.password).to eq('pass')
  89. 1 expect(machine_detection_configuration_from_hash.fallback_url).to eq('https://example.com/fallback')
  90. 1 expect(machine_detection_configuration_from_hash.fallback_method).to eq('GET')
  91. 1 expect(machine_detection_configuration_from_hash.fallback_username).to eq('fallback-user')
  92. 1 expect(machine_detection_configuration_from_hash.fallback_password).to eq('fallback-pass')
  93. end
  94. end
  95. 1 describe '#to_s' do
  96. 1 it 'returns a string representation of the object' do
  97. 1 expect(machine_detection_configuration_values.to_s).to eq('{:mode=>"sync", :detectionTimeout=>20, :silenceTimeout=>12, :speechThreshold=>8, :speechEndThreshold=>4, :machineSpeechEndThreshold=>7, :delayResult=>true, :callbackUrl=>"https://example.com/callback", :callbackMethod=>"GET", :username=>"user", :password=>"pass", :fallbackUrl=>"https://example.com/fallback", :fallbackMethod=>"GET", :fallbackUsername=>"fallback-user", :fallbackPassword=>"fallback-pass"}')
  98. end
  99. end
  100. 1 describe '#eq? #==' do
  101. 1 it 'returns true/false when comparing objects' do
  102. 1 expect(machine_detection_configuration_default.eql?(Bandwidth::MachineDetectionConfiguration.new)).to be true
  103. 1 expect(machine_detection_configuration_default.eql?(machine_detection_configuration_values)).to be false
  104. end
  105. end
  106. 1 describe '#to_body #to_hash' do
  107. 1 it 'returns a hash representation of the object' do
  108. 1 expect(machine_detection_configuration_values.to_body).to eq({
  109. mode: Bandwidth::MachineDetectionModeEnum::SYNC,
  110. detectionTimeout: 20,
  111. silenceTimeout: 12,
  112. speechThreshold: 8,
  113. speechEndThreshold: 4,
  114. machineSpeechEndThreshold: 7,
  115. delayResult: true,
  116. callbackUrl: 'https://example.com/callback',
  117. callbackMethod: Bandwidth::CallbackMethodEnum::GET,
  118. username: 'user',
  119. password: 'pass',
  120. fallbackUrl: 'https://example.com/fallback',
  121. fallbackMethod: Bandwidth::CallbackMethodEnum::GET,
  122. fallbackUsername: 'fallback-user',
  123. fallbackPassword: 'fallback-pass'
  124. })
  125. end
  126. end
  127. 1 describe 'custom attribute writers' do
  128. 1 it '#callback_url=' do
  129. 1 expect {
  130. 1 Bandwidth::MachineDetectionConfiguration.new({ callback_url: 'a' * 2049 })
  131. }.to raise_error(ArgumentError, 'invalid value for "callback_url", the character length must be smaller than or equal to 2048.')
  132. end
  133. 1 it '#username=' do
  134. 1 expect {
  135. 1 Bandwidth::MachineDetectionConfiguration.new({ username: 'a' * 1025 })
  136. }.to raise_error(ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 1024.')
  137. end
  138. 1 it '#password=' do
  139. 1 expect {
  140. 1 Bandwidth::MachineDetectionConfiguration.new({ password: 'a' * 1025 })
  141. }.to raise_error(ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 1024.')
  142. end
  143. 1 it '#fallback_url=' do
  144. 1 expect {
  145. 1 Bandwidth::MachineDetectionConfiguration.new({ fallback_url: 'a' * 2049 })
  146. }.to raise_error(ArgumentError, 'invalid value for "fallback_url", the character length must be smaller than or equal to 2048.')
  147. end
  148. 1 it '#fallback_username=' do
  149. 1 expect {
  150. 1 Bandwidth::MachineDetectionConfiguration.new({ fallback_username: 'a' * 1025 })
  151. }.to raise_error(ArgumentError, 'invalid value for "fallback_username", the character length must be smaller than or equal to 1024.')
  152. end
  153. 1 it '#fallback_password=' do
  154. 1 expect {
  155. 1 Bandwidth::MachineDetectionConfiguration.new({ fallback_password: 'a' * 1025 })
  156. }.to raise_error(ArgumentError, 'invalid value for "fallback_password", the character length must be smaller than or equal to 1024.')
  157. end
  158. end
  159. end

spec/unit/models/machine_detection_mode_enum_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MachineDetectionModeEnum
  2. 1 describe Bandwidth::MachineDetectionModeEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines SYNC' do
  5. 1 expect(Bandwidth::MachineDetectionModeEnum::SYNC).to eq('sync')
  6. end
  7. 1 it 'defines ASYNC' do
  8. 1 expect(Bandwidth::MachineDetectionModeEnum::ASYNC).to eq('async')
  9. end
  10. end
  11. 1 describe '.all_vars' do
  12. 1 it 'returns every valid enum value' do
  13. 1 expect(Bandwidth::MachineDetectionModeEnum.all_vars).to eq([
  14. 'sync',
  15. 'async'
  16. ])
  17. end
  18. end
  19. 1 describe '.build_from_hash' do
  20. 1 it 'returns the value when it matches a valid enum value' do
  21. 1 expect(Bandwidth::MachineDetectionModeEnum.build_from_hash('sync')).to eq('sync')
  22. 1 expect(Bandwidth::MachineDetectionModeEnum.build_from_hash('async')).to eq('async')
  23. end
  24. 1 it 'raises an error for an invalid enum value' do
  25. 1 expect {
  26. 1 Bandwidth::MachineDetectionModeEnum.build_from_hash('invalid')
  27. }.to raise_error(RuntimeError)
  28. end
  29. end
  30. end

spec/unit/models/machine_detection_result_spec.rb

100.0% lines covered

32 relevant lines. 32 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MachineDetectionResult
  2. 1 describe Bandwidth::MachineDetectionResult do
  3. 2 let(:machine_detection_result_default) { Bandwidth::MachineDetectionResult.new }
  4. 4 let(:machine_detection_result_values) { Bandwidth::MachineDetectionResult.new({
  5. value: 'human',
  6. duration: 'PT5S'
  7. }) }
  8. 1 describe '#initialize' do
  9. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  10. 1 expect {
  11. 1 Bandwidth::MachineDetectionResult.new([])
  12. }.to raise_error(ArgumentError)
  13. end
  14. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  15. 1 expect {
  16. 1 Bandwidth::MachineDetectionResult.new({ invalid: true })
  17. }.to raise_error(ArgumentError)
  18. end
  19. end
  20. 1 describe '#acceptable_attributes' do
  21. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  22. 1 expect(Bandwidth::MachineDetectionResult.acceptable_attributes).to eq(Bandwidth::MachineDetectionResult.attribute_map.values)
  23. end
  24. end
  25. 1 describe '#openapi_nullable' do
  26. 1 it 'expects nullable attributes to be an empty set' do
  27. 1 expect(Bandwidth::MachineDetectionResult.openapi_nullable).to eq(Set.new([]))
  28. end
  29. end
  30. 1 describe '#build_from_hash' do
  31. 1 it 'validates instance of MachineDetectionResult created by the build_from_hash method' do
  32. 1 machine_detection_result_from_hash = Bandwidth::MachineDetectionResult.build_from_hash({
  33. value: 'human',
  34. duration: 'PT5S'
  35. })
  36. 1 expect(machine_detection_result_from_hash).to be_instance_of(Bandwidth::MachineDetectionResult)
  37. 1 expect(machine_detection_result_from_hash.value).to eq('human')
  38. 1 expect(machine_detection_result_from_hash.duration).to eq('PT5S')
  39. end
  40. end
  41. 1 describe '#to_s' do
  42. 1 it 'returns a string representation of the object' do
  43. 1 expect(machine_detection_result_values.to_s).to eq('{:value=>"human", :duration=>"PT5S"}')
  44. end
  45. end
  46. 1 describe '#eq? #==' do
  47. 1 it 'returns true/false when comparing objects' do
  48. 1 expect(machine_detection_result_default.eql?(Bandwidth::MachineDetectionResult.new)).to be true
  49. 1 expect(machine_detection_result_default.eql?(machine_detection_result_values)).to be false
  50. end
  51. end
  52. 1 describe '#to_body #to_hash' do
  53. 1 it 'returns a hash representation of the object' do
  54. 1 expect(machine_detection_result_values.to_body).to eq({
  55. value: 'human',
  56. duration: 'PT5S'
  57. })
  58. end
  59. end
  60. end

spec/unit/models/media_spec.rb

100.0% lines covered

33 relevant lines. 33 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Media
  2. 1 describe Bandwidth::Media do
  3. 2 let(:media_default) { Bandwidth::Media.new }
  4. 4 let(:media_values) { Bandwidth::Media.new({
  5. content: 'https://example.com/media/1.jpg',
  6. content_length: 12345,
  7. media_name: 'image.jpg'
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::Media.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::Media.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::Media.acceptable_attributes).to eq(Bandwidth::Media.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be an empty set' do
  28. 1 expect(Bandwidth::Media.openapi_nullable).to eq(Set.new([]))
  29. end
  30. end
  31. 1 describe '#build_from_hash' do
  32. 1 it 'validates instance of Media created by the build_from_hash method' do
  33. 1 media_from_hash = Bandwidth::Media.build_from_hash({
  34. content: 'https://example.com/media/1.jpg',
  35. contentLength: 12345,
  36. mediaName: 'image.jpg'
  37. })
  38. 1 expect(media_from_hash).to be_instance_of(Bandwidth::Media)
  39. 1 expect(media_from_hash.content).to eq('https://example.com/media/1.jpg')
  40. 1 expect(media_from_hash.content_length).to eq(12345)
  41. 1 expect(media_from_hash.media_name).to eq('image.jpg')
  42. end
  43. end
  44. 1 describe '#to_s' do
  45. 1 it 'returns a string representation of the object' do
  46. 1 expect(media_values.to_s).to eq('{:content=>"https://example.com/media/1.jpg", :contentLength=>12345, :mediaName=>"image.jpg"}')
  47. end
  48. end
  49. 1 describe '#eq? #==' do
  50. 1 it 'returns true/false when comparing objects' do
  51. 1 expect(media_default.eql?(Bandwidth::Media.new)).to be true
  52. 1 expect(media_default.eql?(media_values)).to be false
  53. end
  54. end
  55. 1 describe '#to_body #to_hash' do
  56. 1 it 'returns a hash representation of the object' do
  57. 1 expect(media_values.to_body).to eq({
  58. content: 'https://example.com/media/1.jpg',
  59. contentLength: 12345,
  60. mediaName: 'image.jpg'
  61. })
  62. end
  63. end
  64. end

spec/unit/models/message_direction_enum_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MessageDirectionEnum
  2. 1 describe Bandwidth::MessageDirectionEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines IN' do
  5. 1 expect(Bandwidth::MessageDirectionEnum::IN).to eq('in')
  6. end
  7. 1 it 'defines OUT' do
  8. 1 expect(Bandwidth::MessageDirectionEnum::OUT).to eq('out')
  9. end
  10. end
  11. 1 describe '.all_vars' do
  12. 1 it 'returns every valid enum value' do
  13. 1 expect(Bandwidth::MessageDirectionEnum.all_vars).to eq([
  14. 'in',
  15. 'out'
  16. ])
  17. end
  18. end
  19. 1 describe '.build_from_hash' do
  20. 1 it 'returns the value when it matches a valid enum value' do
  21. 1 expect(Bandwidth::MessageDirectionEnum.build_from_hash('in')).to eq('in')
  22. 1 expect(Bandwidth::MessageDirectionEnum.build_from_hash('out')).to eq('out')
  23. end
  24. 1 it 'raises an error for an invalid enum value' do
  25. 1 expect {
  26. 1 Bandwidth::MessageDirectionEnum.build_from_hash('invalid')
  27. }.to raise_error(RuntimeError)
  28. end
  29. end
  30. end

spec/unit/models/message_request_spec.rb

100.0% lines covered

54 relevant lines. 54 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MessageRequest
  2. 1 describe Bandwidth::MessageRequest do
  3. 2 let(:message_request_default) { Bandwidth::MessageRequest.new({
  4. application_id: '93de2206-9669-4e07-948d-329f4b722ee2',
  5. to: ['+19195551234'],
  6. from: '+19195554321'
  7. }) }
  8. 6 let(:message_request_values) { Bandwidth::MessageRequest.new({
  9. application_id: '93de2206-9669-4e07-948d-329f4b722ee2',
  10. to: ['+19195551234'],
  11. from: '+19195554321',
  12. text: 'Hello world',
  13. media: ['https://dev.bandwidth.com/images/bandwidth-logo.png'],
  14. tag: 'custom tag',
  15. priority: Bandwidth::PriorityEnum::DEFAULT,
  16. expiration: '2022-06-16T13:45:07.160Z'
  17. }) }
  18. 1 describe '#initialize' do
  19. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  20. 1 expect {
  21. 1 Bandwidth::MessageRequest.new([])
  22. }.to raise_error(ArgumentError)
  23. end
  24. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  25. 1 expect {
  26. 1 Bandwidth::MessageRequest.new({ invalid: true })
  27. }.to raise_error(ArgumentError)
  28. end
  29. end
  30. 1 describe '#acceptable_attributes' do
  31. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  32. 1 expect(Bandwidth::MessageRequest.acceptable_attributes).to eq(Bandwidth::MessageRequest.attribute_map.values)
  33. end
  34. end
  35. 1 describe '#openapi_nullable' do
  36. 1 it 'expects nullable attributes to be an empty set' do
  37. 1 expect(Bandwidth::MessageRequest.openapi_nullable).to eq(Set.new([]))
  38. end
  39. end
  40. 1 describe '#build_from_hash' do
  41. 1 it 'validates instance of MessageRequest created by the build_from_hash method' do
  42. 1 message_request_from_hash = Bandwidth::MessageRequest.build_from_hash({
  43. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  44. to: ['+19195551234'],
  45. from: '+19195554321',
  46. text: 'Hello world',
  47. media: ['https://dev.bandwidth.com/images/bandwidth-logo.png'],
  48. tag: 'custom tag',
  49. priority: 'default',
  50. expiration: '2022-06-16T13:45:07.160Z'
  51. })
  52. 1 expect(message_request_from_hash).to be_instance_of(Bandwidth::MessageRequest)
  53. 1 expect(message_request_from_hash.application_id).to eq('93de2206-9669-4e07-948d-329f4b722ee2')
  54. 1 expect(message_request_from_hash.to).to eq(['+19195551234'])
  55. 1 expect(message_request_from_hash.from).to eq('+19195554321')
  56. 1 expect(message_request_from_hash.text).to eq('Hello world')
  57. 1 expect(message_request_from_hash.media).to eq(['https://dev.bandwidth.com/images/bandwidth-logo.png'])
  58. 1 expect(message_request_from_hash.tag).to eq('custom tag')
  59. 1 expect(message_request_from_hash.priority).to eq('default')
  60. 1 expect(message_request_from_hash.expiration).to eq(Time.parse('2022-06-16T13:45:07.160Z'))
  61. end
  62. end
  63. 1 describe '#to_s' do
  64. 1 it 'returns a string representation of the object' do
  65. 1 expect(message_request_values.to_s).to eq('{:applicationId=>"93de2206-9669-4e07-948d-329f4b722ee2", :to=>["+19195551234"], :from=>"+19195554321", :text=>"Hello world", :media=>["https://dev.bandwidth.com/images/bandwidth-logo.png"], :tag=>"custom tag", :priority=>"default", :expiration=>"2022-06-16T13:45:07.160Z"}')
  66. end
  67. end
  68. 1 describe '#eq? #==' do
  69. 1 it 'returns true/false when comparing objects' do
  70. 1 message_request_equal = Bandwidth::MessageRequest.new({
  71. application_id: '93de2206-9669-4e07-948d-329f4b722ee2',
  72. to: ['+19195551234'],
  73. from: '+19195554321'
  74. })
  75. 1 expect(message_request_default.eql?(message_request_equal)).to be true
  76. 1 expect(message_request_default.eql?(message_request_values)).to be false
  77. end
  78. end
  79. 1 describe '#to_body #to_hash' do
  80. 1 it 'returns a hash representation of the object' do
  81. 1 expect(message_request_values.to_body).to eq({
  82. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  83. to: ['+19195551234'],
  84. from: '+19195554321',
  85. text: 'Hello world',
  86. media: ['https://dev.bandwidth.com/images/bandwidth-logo.png'],
  87. tag: 'custom tag',
  88. priority: Bandwidth::PriorityEnum::DEFAULT,
  89. expiration: '2022-06-16T13:45:07.160Z'
  90. })
  91. end
  92. end
  93. 1 describe 'custom attribute writers' do
  94. 1 it '#application_id=' do
  95. 1 expect {
  96. 1 Bandwidth::MessageRequest.new({ application_id: nil })
  97. }.to raise_error(ArgumentError, 'application_id cannot be nil')
  98. end
  99. 1 it '#to=' do
  100. 1 expect {
  101. 1 message_request_values.to = nil
  102. }.to raise_error(ArgumentError, 'to cannot be nil')
  103. end
  104. 1 it '#from=' do
  105. 1 expect {
  106. 1 Bandwidth::MessageRequest.new({ application_id: 'a', to: ['+19195551234'], from: nil })
  107. }.to raise_error(ArgumentError, 'from cannot be nil')
  108. end
  109. 1 it '#text=' do
  110. 1 expect {
  111. 1 message_request_values.text = nil
  112. }.to raise_error(ArgumentError, 'text cannot be nil')
  113. 1 expect {
  114. 1 message_request_values.text = 'a' * 2049
  115. }.to raise_error(ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 2048.')
  116. end
  117. end
  118. end

spec/unit/models/message_spec.rb

100.0% lines covered

50 relevant lines. 50 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Message
  2. 1 describe Bandwidth::Message do
  3. 2 let(:message_default) { Bandwidth::Message.new }
  4. 6 let(:message_values) { Bandwidth::Message.new({
  5. id: '1589228074636lm4k2je7j7jklbn2',
  6. owner: '+19195554321',
  7. application_id: '93de2206-9669-4e07-948d-329f4b722ee2',
  8. time: '2022-06-16T13:15:07.160Z',
  9. segment_count: 2,
  10. direction: Bandwidth::MessageDirectionEnum::IN,
  11. to: ['+19195551234'],
  12. from: '+19195554321',
  13. media: ['https://dev.bandwidth.com/images/bandwidth-logo.png'],
  14. text: 'Hello world',
  15. tag: 'custom tag',
  16. priority: 'default',
  17. expiration: '2022-06-16T13:45:07.160Z'
  18. }) }
  19. 1 describe '#initialize' do
  20. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  21. 1 expect {
  22. 1 Bandwidth::Message.new([])
  23. }.to raise_error(ArgumentError)
  24. end
  25. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  26. 1 expect {
  27. 1 Bandwidth::Message.new({ invalid: true })
  28. }.to raise_error(ArgumentError)
  29. end
  30. end
  31. 1 describe '#acceptable_attributes' do
  32. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  33. 1 expect(Bandwidth::Message.acceptable_attributes).to eq(Bandwidth::Message.attribute_map.values)
  34. end
  35. end
  36. 1 describe '#openapi_nullable' do
  37. 1 it 'expects nullable attributes to be an empty set' do
  38. 1 expect(Bandwidth::Message.openapi_nullable).to eq(Set.new([]))
  39. end
  40. end
  41. 1 describe '#build_from_hash' do
  42. 1 it 'validates instance of Message created by the build_from_hash method' do
  43. 1 message_from_hash = Bandwidth::Message.build_from_hash({
  44. id: '1589228074636lm4k2je7j7jklbn2',
  45. owner: '+19195554321',
  46. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  47. time: '2022-06-16T13:15:07.160Z',
  48. segmentCount: 2,
  49. direction: Bandwidth::MessageDirectionEnum::IN,
  50. to: ['+19195551234'],
  51. from: '+19195554321',
  52. media: ['https://dev.bandwidth.com/images/bandwidth-logo.png'],
  53. text: 'Hello world',
  54. tag: 'custom tag',
  55. priority: 'default',
  56. expiration: '2022-06-16T13:45:07.160Z'
  57. })
  58. 1 expect(message_from_hash).to be_instance_of(Bandwidth::Message)
  59. 1 expect(message_from_hash.id).to eq('1589228074636lm4k2je7j7jklbn2')
  60. 1 expect(message_from_hash.owner).to eq('+19195554321')
  61. 1 expect(message_from_hash.application_id).to eq('93de2206-9669-4e07-948d-329f4b722ee2')
  62. 1 expect(message_from_hash.time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  63. 1 expect(message_from_hash.segment_count).to eq(2)
  64. 1 expect(message_from_hash.direction).to eq(Bandwidth::MessageDirectionEnum::IN)
  65. 1 expect(message_from_hash.to).to eq(['+19195551234'])
  66. 1 expect(message_from_hash.from).to eq('+19195554321')
  67. 1 expect(message_from_hash.media).to eq(['https://dev.bandwidth.com/images/bandwidth-logo.png'])
  68. 1 expect(message_from_hash.text).to eq('Hello world')
  69. 1 expect(message_from_hash.tag).to eq('custom tag')
  70. 1 expect(message_from_hash.priority).to eq('default')
  71. 1 expect(message_from_hash.expiration).to eq(Time.parse('2022-06-16T13:45:07.160Z'))
  72. end
  73. end
  74. 1 describe '#to_s' do
  75. 1 it 'returns a string representation of the object' do
  76. 1 expect(message_values.to_s).to eq('{:id=>"1589228074636lm4k2je7j7jklbn2", :owner=>"+19195554321", :applicationId=>"93de2206-9669-4e07-948d-329f4b722ee2", :time=>"2022-06-16T13:15:07.160Z", :segmentCount=>2, :direction=>"in", :to=>["+19195551234"], :from=>"+19195554321", :media=>["https://dev.bandwidth.com/images/bandwidth-logo.png"], :text=>"Hello world", :tag=>"custom tag", :priority=>"default", :expiration=>"2022-06-16T13:45:07.160Z"}')
  77. end
  78. end
  79. 1 describe '#eq? #==' do
  80. 1 it 'returns true/false when comparing objects' do
  81. 1 expect(message_default.eql?(Bandwidth::Message.new)).to be true
  82. 1 expect(message_default.eql?(message_values)).to be false
  83. end
  84. end
  85. 1 describe '#to_body #to_hash' do
  86. 1 it 'returns a hash representation of the object' do
  87. 1 expect(message_values.to_body).to eq({
  88. id: '1589228074636lm4k2je7j7jklbn2',
  89. owner: '+19195554321',
  90. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  91. time: '2022-06-16T13:15:07.160Z',
  92. segmentCount: 2,
  93. direction: Bandwidth::MessageDirectionEnum::IN,
  94. to: ['+19195551234'],
  95. from: '+19195554321',
  96. media: ['https://dev.bandwidth.com/images/bandwidth-logo.png'],
  97. text: 'Hello world',
  98. tag: 'custom tag',
  99. priority: 'default',
  100. expiration: '2022-06-16T13:45:07.160Z'
  101. })
  102. end
  103. end
  104. 1 describe 'custom attribute writers' do
  105. 1 it '#to=' do
  106. 1 expect {
  107. 1 message_values.to = nil
  108. }.to raise_error(ArgumentError, 'to cannot be nil')
  109. end
  110. 1 it '#media=' do
  111. 1 expect {
  112. 1 message_values.media = nil
  113. }.to raise_error(ArgumentError, 'media cannot be nil')
  114. end
  115. end
  116. end

spec/unit/models/message_status_enum_spec.rb

100.0% lines covered

34 relevant lines. 34 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MessageStatusEnum
  2. 1 describe Bandwidth::MessageStatusEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines RECEIVED' do
  5. 1 expect(Bandwidth::MessageStatusEnum::RECEIVED).to eq('RECEIVED')
  6. end
  7. 1 it 'defines QUEUED' do
  8. 1 expect(Bandwidth::MessageStatusEnum::QUEUED).to eq('QUEUED')
  9. end
  10. 1 it 'defines SENDING' do
  11. 1 expect(Bandwidth::MessageStatusEnum::SENDING).to eq('SENDING')
  12. end
  13. 1 it 'defines SENT' do
  14. 1 expect(Bandwidth::MessageStatusEnum::SENT).to eq('SENT')
  15. end
  16. 1 it 'defines FAILED' do
  17. 1 expect(Bandwidth::MessageStatusEnum::FAILED).to eq('FAILED')
  18. end
  19. 1 it 'defines DELIVERED' do
  20. 1 expect(Bandwidth::MessageStatusEnum::DELIVERED).to eq('DELIVERED')
  21. end
  22. 1 it 'defines ACCEPTED' do
  23. 1 expect(Bandwidth::MessageStatusEnum::ACCEPTED).to eq('ACCEPTED')
  24. end
  25. 1 it 'defines UNDELIVERED' do
  26. 1 expect(Bandwidth::MessageStatusEnum::UNDELIVERED).to eq('UNDELIVERED')
  27. end
  28. end
  29. 1 describe '.all_vars' do
  30. 1 it 'returns every valid enum value' do
  31. 1 expect(Bandwidth::MessageStatusEnum.all_vars).to eq([
  32. 'RECEIVED',
  33. 'QUEUED',
  34. 'SENDING',
  35. 'SENT',
  36. 'FAILED',
  37. 'DELIVERED',
  38. 'ACCEPTED',
  39. 'UNDELIVERED'
  40. ])
  41. end
  42. end
  43. 1 describe '.build_from_hash' do
  44. 1 it 'returns the value when it matches a valid enum value' do
  45. 1 expect(Bandwidth::MessageStatusEnum.build_from_hash('RECEIVED')).to eq('RECEIVED')
  46. 1 expect(Bandwidth::MessageStatusEnum.build_from_hash('QUEUED')).to eq('QUEUED')
  47. 1 expect(Bandwidth::MessageStatusEnum.build_from_hash('SENDING')).to eq('SENDING')
  48. 1 expect(Bandwidth::MessageStatusEnum.build_from_hash('SENT')).to eq('SENT')
  49. 1 expect(Bandwidth::MessageStatusEnum.build_from_hash('FAILED')).to eq('FAILED')
  50. 1 expect(Bandwidth::MessageStatusEnum.build_from_hash('DELIVERED')).to eq('DELIVERED')
  51. 1 expect(Bandwidth::MessageStatusEnum.build_from_hash('ACCEPTED')).to eq('ACCEPTED')
  52. 1 expect(Bandwidth::MessageStatusEnum.build_from_hash('UNDELIVERED')).to eq('UNDELIVERED')
  53. end
  54. 1 it 'raises an error for an invalid enum value' do
  55. 1 expect {
  56. 1 Bandwidth::MessageStatusEnum.build_from_hash('invalid')
  57. }.to raise_error(RuntimeError)
  58. end
  59. end
  60. end

spec/unit/models/message_type_enum_spec.rb

100.0% lines covered

19 relevant lines. 19 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MessageTypeEnum
  2. 1 describe Bandwidth::MessageTypeEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines SMS' do
  5. 1 expect(Bandwidth::MessageTypeEnum::SMS).to eq('sms')
  6. end
  7. 1 it 'defines MMS' do
  8. 1 expect(Bandwidth::MessageTypeEnum::MMS).to eq('mms')
  9. end
  10. 1 it 'defines RCS' do
  11. 1 expect(Bandwidth::MessageTypeEnum::RCS).to eq('rcs')
  12. end
  13. end
  14. 1 describe '.all_vars' do
  15. 1 it 'returns every valid enum value' do
  16. 1 expect(Bandwidth::MessageTypeEnum.all_vars).to eq([
  17. 'sms',
  18. 'mms',
  19. 'rcs'
  20. ])
  21. end
  22. end
  23. 1 describe '.build_from_hash' do
  24. 1 it 'returns the value when it matches a valid enum value' do
  25. 1 expect(Bandwidth::MessageTypeEnum.build_from_hash('sms')).to eq('sms')
  26. 1 expect(Bandwidth::MessageTypeEnum.build_from_hash('mms')).to eq('mms')
  27. 1 expect(Bandwidth::MessageTypeEnum.build_from_hash('rcs')).to eq('rcs')
  28. end
  29. 1 it 'raises an error for an invalid enum value' do
  30. 1 expect {
  31. 1 Bandwidth::MessageTypeEnum.build_from_hash('invalid')
  32. }.to raise_error(RuntimeError)
  33. end
  34. end
  35. end

spec/unit/models/messages_list_spec.rb

100.0% lines covered

35 relevant lines. 35 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MessagesList
  2. 1 describe Bandwidth::MessagesList do
  3. 4 let(:page_info) { Bandwidth::PageInfo.new({
  4. prev_page: 'https://example.com/prev',
  5. next_page: 'https://example.com/next',
  6. prev_page_token: 'prev-token',
  7. next_page_token: 'next-token'
  8. }) }
  9. 4 let(:list_message_item) { Bandwidth::ListMessageItem.new({ message_id: 'abc-123', message_length: 10 }) }
  10. 2 let(:messages_list_default) { Bandwidth::MessagesList.new }
  11. 4 let(:messages_list_values) { Bandwidth::MessagesList.new({
  12. total_count: 1,
  13. page_info: page_info,
  14. messages: [list_message_item]
  15. }) }
  16. 1 describe '#initialize' do
  17. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  18. 1 expect {
  19. 1 Bandwidth::MessagesList.new([])
  20. }.to raise_error(ArgumentError)
  21. end
  22. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  23. 1 expect {
  24. 1 Bandwidth::MessagesList.new({ invalid: true })
  25. }.to raise_error(ArgumentError)
  26. end
  27. end
  28. 1 describe '#acceptable_attributes' do
  29. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  30. 1 expect(Bandwidth::MessagesList.acceptable_attributes).to eq(Bandwidth::MessagesList.attribute_map.values)
  31. end
  32. end
  33. 1 describe '#openapi_nullable' do
  34. 1 it 'expects nullable attributes to be an empty set' do
  35. 1 expect(Bandwidth::MessagesList.openapi_nullable).to eq(Set.new([]))
  36. end
  37. end
  38. 1 describe '#build_from_hash' do
  39. 1 it 'validates instance of MessagesList created by the build_from_hash method' do
  40. 1 messages_list_from_hash = Bandwidth::MessagesList.build_from_hash({
  41. totalCount: 1,
  42. pageInfo: { prevPage: 'https://example.com/prev', nextPage: 'https://example.com/next', prevPageToken: 'prev-token', nextPageToken: 'next-token' },
  43. messages: [{ messageId: 'abc-123', messageLength: 10 }]
  44. })
  45. 1 expect(messages_list_from_hash).to be_instance_of(Bandwidth::MessagesList)
  46. 1 expect(messages_list_from_hash.total_count).to eq(1)
  47. 1 expect(messages_list_from_hash.page_info).to be_instance_of(Bandwidth::PageInfo)
  48. 1 expect(messages_list_from_hash.messages.first).to be_instance_of(Bandwidth::ListMessageItem)
  49. end
  50. end
  51. 1 describe '#to_s' do
  52. 1 it 'returns a string representation of the object' do
  53. 1 expect(messages_list_values.to_s).to eq('{:totalCount=>1, :pageInfo=>{:prevPage=>"https://example.com/prev", :nextPage=>"https://example.com/next", :prevPageToken=>"prev-token", :nextPageToken=>"next-token"}, :messages=>[{:messageId=>"abc-123", :messageLength=>10}]}')
  54. end
  55. end
  56. 1 describe '#eq? #==' do
  57. 1 it 'returns true/false when comparing objects' do
  58. 1 expect(messages_list_default.eql?(Bandwidth::MessagesList.new)).to be true
  59. 1 expect(messages_list_default.eql?(messages_list_values)).to be false
  60. end
  61. end
  62. 1 describe '#to_body #to_hash' do
  63. 1 it 'returns a hash representation of the object' do
  64. 1 expect(messages_list_values.to_body).to eq({
  65. totalCount: 1,
  66. pageInfo: { prevPage: 'https://example.com/prev', nextPage: 'https://example.com/next', prevPageToken: 'prev-token', nextPageToken: 'next-token' },
  67. messages: [{ messageId: 'abc-123', messageLength: 10 }]
  68. })
  69. end
  70. end
  71. end

spec/unit/models/messaging_code_response_spec.rb

100.0% lines covered

31 relevant lines. 31 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MessagingCodeResponse
  2. 1 describe Bandwidth::MessagingCodeResponse do
  3. 2 let(:messaging_code_response_default) { Bandwidth::MessagingCodeResponse.new }
  4. 4 let(:messaging_code_response_values) { Bandwidth::MessagingCodeResponse.new({
  5. message_id: '1589228074636lm4k2je7j7jklbn2'
  6. }) }
  7. 1 describe '#initialize' do
  8. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  9. 1 expect {
  10. 1 Bandwidth::MessagingCodeResponse.new([])
  11. }.to raise_error(ArgumentError)
  12. end
  13. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  14. 1 expect {
  15. 1 Bandwidth::MessagingCodeResponse.new({ invalid: true })
  16. }.to raise_error(ArgumentError)
  17. end
  18. end
  19. 1 describe '#acceptable_attributes' do
  20. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  21. 1 expect(Bandwidth::MessagingCodeResponse.acceptable_attributes).to eq(Bandwidth::MessagingCodeResponse.attribute_map.values)
  22. end
  23. end
  24. 1 describe '#openapi_nullable' do
  25. 1 it 'expects nullable attributes to be an empty set' do
  26. 1 expect(Bandwidth::MessagingCodeResponse.openapi_nullable).to eq(Set.new([]))
  27. end
  28. end
  29. 1 describe '#build_from_hash' do
  30. 1 it 'validates instance of MessagingCodeResponse created by the build_from_hash method' do
  31. 1 messaging_code_response_from_hash = Bandwidth::MessagingCodeResponse.build_from_hash({
  32. messageId: '1589228074636lm4k2je7j7jklbn2'
  33. })
  34. 1 expect(messaging_code_response_from_hash).to be_instance_of(Bandwidth::MessagingCodeResponse)
  35. 1 expect(messaging_code_response_from_hash.message_id).to eq('1589228074636lm4k2je7j7jklbn2')
  36. end
  37. end
  38. 1 describe '#to_s' do
  39. 1 it 'returns a string representation of the object' do
  40. 1 expect(messaging_code_response_values.to_s).to eq('{:messageId=>"1589228074636lm4k2je7j7jklbn2"}')
  41. end
  42. end
  43. 1 describe '#eq? #==' do
  44. 1 it 'returns true/false when comparing objects' do
  45. 1 expect(messaging_code_response_default.eql?(Bandwidth::MessagingCodeResponse.new)).to be true
  46. 1 expect(messaging_code_response_default.eql?(messaging_code_response_values)).to be false
  47. end
  48. end
  49. 1 describe '#to_body #to_hash' do
  50. 1 it 'returns a hash representation of the object' do
  51. 1 expect(messaging_code_response_values.to_body).to eq({
  52. messageId: '1589228074636lm4k2je7j7jklbn2'
  53. })
  54. end
  55. end
  56. end

spec/unit/models/messaging_request_error_spec.rb

100.0% lines covered

40 relevant lines. 40 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MessagingRequestError
  2. 1 describe Bandwidth::MessagingRequestError do
  3. 2 let(:messaging_request_error_default) { Bandwidth::MessagingRequestError.new({
  4. type: 'baseline',
  5. description: 'baseline description'
  6. }) }
  7. 4 let(:messaging_request_error_values) { Bandwidth::MessagingRequestError.new({
  8. type: 'validation',
  9. description: 'bad input'
  10. }) }
  11. 1 describe '#initialize' do
  12. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  13. 1 expect {
  14. 1 Bandwidth::MessagingRequestError.new([])
  15. }.to raise_error(ArgumentError)
  16. end
  17. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  18. 1 expect {
  19. 1 Bandwidth::MessagingRequestError.new({ invalid: true })
  20. }.to raise_error(ArgumentError)
  21. end
  22. end
  23. 1 describe '#acceptable_attributes' do
  24. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  25. 1 expect(Bandwidth::MessagingRequestError.acceptable_attributes).to eq(Bandwidth::MessagingRequestError.attribute_map.values)
  26. end
  27. end
  28. 1 describe '#openapi_nullable' do
  29. 1 it 'expects nullable attributes to be an empty set' do
  30. 1 expect(Bandwidth::MessagingRequestError.openapi_nullable).to eq(Set.new([]))
  31. end
  32. end
  33. 1 describe '#build_from_hash' do
  34. 1 it 'validates instance of MessagingRequestError created by the build_from_hash method' do
  35. 1 messaging_request_error_from_hash = Bandwidth::MessagingRequestError.build_from_hash({
  36. type: 'validation',
  37. description: 'bad input'
  38. })
  39. 1 expect(messaging_request_error_from_hash).to be_instance_of(Bandwidth::MessagingRequestError)
  40. 1 expect(messaging_request_error_from_hash.type).to eq('validation')
  41. 1 expect(messaging_request_error_from_hash.description).to eq('bad input')
  42. end
  43. end
  44. 1 describe '#to_s' do
  45. 1 it 'returns a string representation of the object' do
  46. 1 expect(messaging_request_error_values.to_s).to eq('{:type=>"validation", :description=>"bad input"}')
  47. end
  48. end
  49. 1 describe '#eq? #==' do
  50. 1 it 'returns true/false when comparing objects' do
  51. 1 messaging_request_error_equal = Bandwidth::MessagingRequestError.new({
  52. type: 'baseline',
  53. description: 'baseline description'
  54. })
  55. 1 expect(messaging_request_error_default.eql?(messaging_request_error_equal)).to be true
  56. 1 expect(messaging_request_error_default.eql?(messaging_request_error_values)).to be false
  57. end
  58. end
  59. 1 describe '#to_body #to_hash' do
  60. 1 it 'returns a hash representation of the object' do
  61. 1 expect(messaging_request_error_values.to_body).to eq({
  62. type: 'validation',
  63. description: 'bad input'
  64. })
  65. end
  66. end
  67. 1 describe 'custom attribute writers' do
  68. 1 it '#type=' do
  69. 1 expect {
  70. 1 Bandwidth::MessagingRequestError.new({ type: nil })
  71. }.to raise_error(ArgumentError, 'type cannot be nil')
  72. end
  73. 1 it '#description=' do
  74. 1 expect {
  75. 1 Bandwidth::MessagingRequestError.new({ type: 'a', description: nil })
  76. }.to raise_error(ArgumentError, 'description cannot be nil')
  77. end
  78. end
  79. end

spec/unit/models/mfa_forbidden_request_error_spec.rb

100.0% lines covered

31 relevant lines. 31 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MfaForbiddenRequestError
  2. 1 describe Bandwidth::MfaForbiddenRequestError do
  3. 2 let(:mfa_forbidden_request_error_default) { Bandwidth::MfaForbiddenRequestError.new }
  4. 4 let(:mfa_forbidden_request_error_values) { Bandwidth::MfaForbiddenRequestError.new({
  5. message: 'Forbidden request'
  6. }) }
  7. 1 describe '#initialize' do
  8. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  9. 1 expect {
  10. 1 Bandwidth::MfaForbiddenRequestError.new([])
  11. }.to raise_error(ArgumentError)
  12. end
  13. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  14. 1 expect {
  15. 1 Bandwidth::MfaForbiddenRequestError.new({ invalid: true })
  16. }.to raise_error(ArgumentError)
  17. end
  18. end
  19. 1 describe '#acceptable_attributes' do
  20. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  21. 1 expect(Bandwidth::MfaForbiddenRequestError.acceptable_attributes).to eq(Bandwidth::MfaForbiddenRequestError.attribute_map.values)
  22. end
  23. end
  24. 1 describe '#openapi_nullable' do
  25. 1 it 'expects nullable attributes to be an empty set' do
  26. 1 expect(Bandwidth::MfaForbiddenRequestError.openapi_nullable).to eq(Set.new([]))
  27. end
  28. end
  29. 1 describe '#build_from_hash' do
  30. 1 it 'validates instance of MfaForbiddenRequestError created by the build_from_hash method' do
  31. 1 mfa_forbidden_request_error_from_hash = Bandwidth::MfaForbiddenRequestError.build_from_hash({
  32. message: 'Forbidden request'
  33. })
  34. 1 expect(mfa_forbidden_request_error_from_hash).to be_instance_of(Bandwidth::MfaForbiddenRequestError)
  35. 1 expect(mfa_forbidden_request_error_from_hash.message).to eq('Forbidden request')
  36. end
  37. end
  38. 1 describe '#to_s' do
  39. 1 it 'returns a string representation of the object' do
  40. 1 expect(mfa_forbidden_request_error_values.to_s).to eq('{:message=>"Forbidden request"}')
  41. end
  42. end
  43. 1 describe '#eq? #==' do
  44. 1 it 'returns true/false when comparing objects' do
  45. 1 expect(mfa_forbidden_request_error_default.eql?(Bandwidth::MfaForbiddenRequestError.new)).to be true
  46. 1 expect(mfa_forbidden_request_error_default.eql?(mfa_forbidden_request_error_values)).to be false
  47. end
  48. end
  49. 1 describe '#to_body #to_hash' do
  50. 1 it 'returns a hash representation of the object' do
  51. 1 expect(mfa_forbidden_request_error_values.to_body).to eq({
  52. message: 'Forbidden request'
  53. })
  54. end
  55. end
  56. end

spec/unit/models/mfa_request_error_spec.rb

100.0% lines covered

32 relevant lines. 32 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MfaRequestError
  2. 1 describe Bandwidth::MfaRequestError do
  3. 2 let(:mfa_request_error_default) { Bandwidth::MfaRequestError.new }
  4. 4 let(:mfa_request_error_values) { Bandwidth::MfaRequestError.new({
  5. error: 'Invalid request',
  6. request_id: 'req-abc-123'
  7. }) }
  8. 1 describe '#initialize' do
  9. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  10. 1 expect {
  11. 1 Bandwidth::MfaRequestError.new([])
  12. }.to raise_error(ArgumentError)
  13. end
  14. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  15. 1 expect {
  16. 1 Bandwidth::MfaRequestError.new({ invalid: true })
  17. }.to raise_error(ArgumentError)
  18. end
  19. end
  20. 1 describe '#acceptable_attributes' do
  21. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  22. 1 expect(Bandwidth::MfaRequestError.acceptable_attributes).to eq(Bandwidth::MfaRequestError.attribute_map.values)
  23. end
  24. end
  25. 1 describe '#openapi_nullable' do
  26. 1 it 'expects nullable attributes to be an empty set' do
  27. 1 expect(Bandwidth::MfaRequestError.openapi_nullable).to eq(Set.new([]))
  28. end
  29. end
  30. 1 describe '#build_from_hash' do
  31. 1 it 'validates instance of MfaRequestError created by the build_from_hash method' do
  32. 1 mfa_request_error_from_hash = Bandwidth::MfaRequestError.build_from_hash({
  33. error: 'Invalid request',
  34. requestId: 'req-abc-123'
  35. })
  36. 1 expect(mfa_request_error_from_hash).to be_instance_of(Bandwidth::MfaRequestError)
  37. 1 expect(mfa_request_error_from_hash.error).to eq('Invalid request')
  38. 1 expect(mfa_request_error_from_hash.request_id).to eq('req-abc-123')
  39. end
  40. end
  41. 1 describe '#to_s' do
  42. 1 it 'returns a string representation of the object' do
  43. 1 expect(mfa_request_error_values.to_s).to eq('{:error=>"Invalid request", :requestId=>"req-abc-123"}')
  44. end
  45. end
  46. 1 describe '#eq? #==' do
  47. 1 it 'returns true/false when comparing objects' do
  48. 1 expect(mfa_request_error_default.eql?(Bandwidth::MfaRequestError.new)).to be true
  49. 1 expect(mfa_request_error_default.eql?(mfa_request_error_values)).to be false
  50. end
  51. end
  52. 1 describe '#to_body #to_hash' do
  53. 1 it 'returns a hash representation of the object' do
  54. 1 expect(mfa_request_error_values.to_body).to eq({
  55. error: 'Invalid request',
  56. requestId: 'req-abc-123'
  57. })
  58. end
  59. end
  60. end

spec/unit/models/mfa_unauthorized_request_error_spec.rb

100.0% lines covered

31 relevant lines. 31 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MfaUnauthorizedRequestError
  2. 1 describe Bandwidth::MfaUnauthorizedRequestError do
  3. 2 let(:mfa_unauthorized_request_error_default) { Bandwidth::MfaUnauthorizedRequestError.new }
  4. 4 let(:mfa_unauthorized_request_error_values) { Bandwidth::MfaUnauthorizedRequestError.new({
  5. message: 'Unauthorized'
  6. }) }
  7. 1 describe '#initialize' do
  8. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  9. 1 expect {
  10. 1 Bandwidth::MfaUnauthorizedRequestError.new([])
  11. }.to raise_error(ArgumentError)
  12. end
  13. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  14. 1 expect {
  15. 1 Bandwidth::MfaUnauthorizedRequestError.new({ invalid: true })
  16. }.to raise_error(ArgumentError)
  17. end
  18. end
  19. 1 describe '#acceptable_attributes' do
  20. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  21. 1 expect(Bandwidth::MfaUnauthorizedRequestError.acceptable_attributes).to eq(Bandwidth::MfaUnauthorizedRequestError.attribute_map.values)
  22. end
  23. end
  24. 1 describe '#openapi_nullable' do
  25. 1 it 'expects nullable attributes to be an empty set' do
  26. 1 expect(Bandwidth::MfaUnauthorizedRequestError.openapi_nullable).to eq(Set.new([]))
  27. end
  28. end
  29. 1 describe '#build_from_hash' do
  30. 1 it 'validates instance of MfaUnauthorizedRequestError created by the build_from_hash method' do
  31. 1 mfa_unauthorized_request_error_from_hash = Bandwidth::MfaUnauthorizedRequestError.build_from_hash({
  32. message: 'Unauthorized'
  33. })
  34. 1 expect(mfa_unauthorized_request_error_from_hash).to be_instance_of(Bandwidth::MfaUnauthorizedRequestError)
  35. 1 expect(mfa_unauthorized_request_error_from_hash.message).to eq('Unauthorized')
  36. end
  37. end
  38. 1 describe '#to_s' do
  39. 1 it 'returns a string representation of the object' do
  40. 1 expect(mfa_unauthorized_request_error_values.to_s).to eq('{:message=>"Unauthorized"}')
  41. end
  42. end
  43. 1 describe '#eq? #==' do
  44. 1 it 'returns true/false when comparing objects' do
  45. 1 expect(mfa_unauthorized_request_error_default.eql?(Bandwidth::MfaUnauthorizedRequestError.new)).to be true
  46. 1 expect(mfa_unauthorized_request_error_default.eql?(mfa_unauthorized_request_error_values)).to be false
  47. end
  48. end
  49. 1 describe '#to_body #to_hash' do
  50. 1 it 'returns a hash representation of the object' do
  51. 1 expect(mfa_unauthorized_request_error_values.to_body).to eq({
  52. message: 'Unauthorized'
  53. })
  54. end
  55. end
  56. end

spec/unit/models/mms_message_content_file_spec.rb

100.0% lines covered

38 relevant lines. 38 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MmsMessageContentFile
  2. 1 describe Bandwidth::MmsMessageContentFile do
  3. 2 let(:mms_message_content_file_default) { Bandwidth::MmsMessageContentFile.new({
  4. file_url: 'https://example.com/baseline.jpg'
  5. }) }
  6. 4 let(:mms_message_content_file_values) { Bandwidth::MmsMessageContentFile.new({
  7. file_url: 'https://example.com/image.jpg'
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::MmsMessageContentFile.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::MmsMessageContentFile.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::MmsMessageContentFile.acceptable_attributes).to eq(Bandwidth::MmsMessageContentFile.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be an empty set' do
  28. 1 expect(Bandwidth::MmsMessageContentFile.openapi_nullable).to eq(Set.new([]))
  29. end
  30. end
  31. 1 describe '#build_from_hash' do
  32. 1 it 'validates instance of MmsMessageContentFile created by the build_from_hash method' do
  33. 1 mms_message_content_file_from_hash = Bandwidth::MmsMessageContentFile.build_from_hash({
  34. fileUrl: 'https://example.com/image.jpg'
  35. })
  36. 1 expect(mms_message_content_file_from_hash).to be_instance_of(Bandwidth::MmsMessageContentFile)
  37. 1 expect(mms_message_content_file_from_hash.file_url).to eq('https://example.com/image.jpg')
  38. end
  39. end
  40. 1 describe '#to_s' do
  41. 1 it 'returns a string representation of the object' do
  42. 1 expect(mms_message_content_file_values.to_s).to eq('{:fileUrl=>"https://example.com/image.jpg"}')
  43. end
  44. end
  45. 1 describe '#eq? #==' do
  46. 1 it 'returns true/false when comparing objects' do
  47. 1 mms_message_content_file_equal = Bandwidth::MmsMessageContentFile.new({
  48. file_url: 'https://example.com/baseline.jpg'
  49. })
  50. 1 expect(mms_message_content_file_default.eql?(mms_message_content_file_equal)).to be true
  51. 1 expect(mms_message_content_file_default.eql?(mms_message_content_file_values)).to be false
  52. end
  53. end
  54. 1 describe '#to_body #to_hash' do
  55. 1 it 'returns a hash representation of the object' do
  56. 1 expect(mms_message_content_file_values.to_body).to eq({
  57. fileUrl: 'https://example.com/image.jpg'
  58. })
  59. end
  60. end
  61. 1 describe 'custom attribute writers' do
  62. 1 it '#file_url=' do
  63. 1 expect {
  64. 1 Bandwidth::MmsMessageContentFile.new({ file_url: nil })
  65. }.to raise_error(ArgumentError, 'file_url cannot be nil')
  66. 1 expect {
  67. 1 Bandwidth::MmsMessageContentFile.new({ file_url: 'a' * 1001 })
  68. }.to raise_error(ArgumentError, 'invalid value for "file_url", the character length must be smaller than or equal to 1000.')
  69. end
  70. end
  71. end

spec/unit/models/mms_message_content_spec.rb

100.0% lines covered

40 relevant lines. 40 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MmsMessageContent
  2. 1 describe Bandwidth::MmsMessageContent do
  3. 2 let(:mms_message_content_default) { Bandwidth::MmsMessageContent.new }
  4. 4 let(:mms_message_content_values) { Bandwidth::MmsMessageContent.new({
  5. text: 'Hello world',
  6. media: [Bandwidth::MmsMessageContentFile.new({ file_url: 'https://dev.bandwidth.com/images/bandwidth-logo.png' })]
  7. }) }
  8. 1 describe '#initialize' do
  9. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  10. 1 expect {
  11. 1 Bandwidth::MmsMessageContent.new([])
  12. }.to raise_error(ArgumentError)
  13. end
  14. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  15. 1 expect {
  16. 1 Bandwidth::MmsMessageContent.new({ invalid: true })
  17. }.to raise_error(ArgumentError)
  18. end
  19. end
  20. 1 describe '#acceptable_attributes' do
  21. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  22. 1 expect(Bandwidth::MmsMessageContent.acceptable_attributes).to eq(Bandwidth::MmsMessageContent.attribute_map.values)
  23. end
  24. end
  25. 1 describe '#openapi_nullable' do
  26. 1 it 'expects nullable attributes to be an empty set' do
  27. 1 expect(Bandwidth::MmsMessageContent.openapi_nullable).to eq(Set.new([]))
  28. end
  29. end
  30. 1 describe '#build_from_hash' do
  31. 1 it 'validates instance of MmsMessageContent created by the build_from_hash method' do
  32. 1 mms_message_content_from_hash = Bandwidth::MmsMessageContent.build_from_hash({
  33. text: 'Hello world',
  34. media: [{ fileUrl: 'https://dev.bandwidth.com/images/bandwidth-logo.png' }]
  35. })
  36. 1 expect(mms_message_content_from_hash).to be_instance_of(Bandwidth::MmsMessageContent)
  37. 1 expect(mms_message_content_from_hash.text).to eq('Hello world')
  38. 1 expect(mms_message_content_from_hash.media).to be_instance_of(Array)
  39. 1 expect(mms_message_content_from_hash.media.first).to be_instance_of(Bandwidth::MmsMessageContentFile)
  40. 1 expect(mms_message_content_from_hash.media.first.file_url).to eq('https://dev.bandwidth.com/images/bandwidth-logo.png')
  41. end
  42. end
  43. 1 describe '#to_s' do
  44. 1 it 'returns a string representation of the object' do
  45. 1 expect(mms_message_content_values.to_s).to eq('{:text=>"Hello world", :media=>[{:fileUrl=>"https://dev.bandwidth.com/images/bandwidth-logo.png"}]}')
  46. end
  47. end
  48. 1 describe '#eq? #==' do
  49. 1 it 'returns true/false when comparing objects' do
  50. 1 expect(mms_message_content_default.eql?(Bandwidth::MmsMessageContent.new)).to be true
  51. 1 expect(mms_message_content_default.eql?(mms_message_content_values)).to be false
  52. end
  53. end
  54. 1 describe '#to_body #to_hash' do
  55. 1 it 'returns a hash representation of the object' do
  56. 1 expect(mms_message_content_values.to_body).to eq({
  57. text: 'Hello world',
  58. media: [{ fileUrl: 'https://dev.bandwidth.com/images/bandwidth-logo.png' }]
  59. })
  60. end
  61. end
  62. 1 describe 'custom attribute writers' do
  63. 1 it '#text=' do
  64. 1 expect {
  65. 1 Bandwidth::MmsMessageContent.new({ text: nil })
  66. }.to raise_error(ArgumentError, 'text cannot be nil')
  67. 1 expect {
  68. 1 Bandwidth::MmsMessageContent.new({ text: 'a' * 2049 })
  69. }.to raise_error(ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 2048.')
  70. end
  71. end
  72. end

spec/unit/models/multi_channel_action_calendar_event_spec.rb

100.0% lines covered

68 relevant lines. 68 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MultiChannelActionCalendarEvent
  2. 1 describe Bandwidth::MultiChannelActionCalendarEvent do
  3. 2 let(:multi_channel_action_calendar_event_default) { Bandwidth::MultiChannelActionCalendarEvent.new({
  4. type: Bandwidth::RbmActionTypeEnum::CREATE_CALENDAR_EVENT,
  5. text: 'baseline',
  6. postback_data: 'baseline_postback',
  7. title: 'Baseline Event',
  8. start_time: '2024-01-01T00:00:00Z',
  9. end_time: '2024-01-01T01:00:00Z'
  10. }) }
  11. 5 let(:multi_channel_action_calendar_event_values) { Bandwidth::MultiChannelActionCalendarEvent.new({
  12. type: Bandwidth::RbmActionTypeEnum::CREATE_CALENDAR_EVENT,
  13. text: 'Add to calendar',
  14. postback_data: 'calendar_postback',
  15. title: 'Bandwidth Demo',
  16. start_time: '2024-06-16T13:15:07.160Z',
  17. end_time: '2024-06-16T14:15:07.160Z',
  18. description: 'A demo of the Bandwidth API'
  19. }) }
  20. 1 describe '#initialize' do
  21. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  22. 1 expect {
  23. 1 Bandwidth::MultiChannelActionCalendarEvent.new([])
  24. }.to raise_error(ArgumentError)
  25. end
  26. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  27. 1 expect {
  28. 1 Bandwidth::MultiChannelActionCalendarEvent.new({ invalid: true })
  29. }.to raise_error(ArgumentError)
  30. end
  31. end
  32. 1 describe '#acceptable_attributes' do
  33. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  34. 1 expect(Bandwidth::MultiChannelActionCalendarEvent.acceptable_attributes).to eq(Bandwidth::MultiChannelActionCalendarEvent.attribute_map.values)
  35. end
  36. end
  37. 1 describe '#openapi_nullable' do
  38. 1 it 'expects nullable attributes to be an empty set' do
  39. 1 expect(Bandwidth::MultiChannelActionCalendarEvent.openapi_nullable).to eq(Set.new([]))
  40. end
  41. end
  42. 1 describe '#build_from_hash' do
  43. 1 it 'validates instance of MultiChannelActionCalendarEvent created by the build_from_hash method' do
  44. 1 multi_channel_action_calendar_event_from_hash = Bandwidth::MultiChannelActionCalendarEvent.build_from_hash({
  45. type: Bandwidth::RbmActionTypeEnum::CREATE_CALENDAR_EVENT,
  46. text: 'Add to calendar',
  47. postbackData: 'calendar_postback',
  48. title: 'Bandwidth Demo',
  49. startTime: '2024-06-16T13:15:07.160Z',
  50. endTime: '2024-06-16T14:15:07.160Z',
  51. description: 'A demo of the Bandwidth API'
  52. })
  53. 1 expect(multi_channel_action_calendar_event_from_hash).to be_instance_of(Bandwidth::MultiChannelActionCalendarEvent)
  54. 1 expect(multi_channel_action_calendar_event_from_hash.type).to eq(Bandwidth::RbmActionTypeEnum::CREATE_CALENDAR_EVENT)
  55. 1 expect(multi_channel_action_calendar_event_from_hash.text).to eq('Add to calendar')
  56. 1 expect(multi_channel_action_calendar_event_from_hash.postback_data).to eq('calendar_postback')
  57. 1 expect(multi_channel_action_calendar_event_from_hash.title).to eq('Bandwidth Demo')
  58. 1 expect(multi_channel_action_calendar_event_from_hash.start_time).to eq(Time.parse('2024-06-16T13:15:07.160Z'))
  59. 1 expect(multi_channel_action_calendar_event_from_hash.end_time).to eq(Time.parse('2024-06-16T14:15:07.160Z'))
  60. 1 expect(multi_channel_action_calendar_event_from_hash.description).to eq('A demo of the Bandwidth API')
  61. end
  62. end
  63. 1 describe '#to_s' do
  64. 1 it 'returns a string representation of the object' do
  65. 1 expect(multi_channel_action_calendar_event_values.to_s).to eq('{:type=>"CREATE_CALENDAR_EVENT", :text=>"Add to calendar", :postbackData=>"calendar_postback", :title=>"Bandwidth Demo", :startTime=>"2024-06-16T13:15:07.160Z", :endTime=>"2024-06-16T14:15:07.160Z", :description=>"A demo of the Bandwidth API"}')
  66. end
  67. end
  68. 1 describe '#eq? #==' do
  69. 1 it 'returns true/false when comparing objects' do
  70. 1 multi_channel_action_calendar_event_equal = Bandwidth::MultiChannelActionCalendarEvent.new({
  71. type: Bandwidth::RbmActionTypeEnum::CREATE_CALENDAR_EVENT,
  72. text: 'baseline',
  73. postback_data: 'baseline_postback',
  74. title: 'Baseline Event',
  75. start_time: '2024-01-01T00:00:00Z',
  76. end_time: '2024-01-01T01:00:00Z'
  77. })
  78. 1 expect(multi_channel_action_calendar_event_default.eql?(multi_channel_action_calendar_event_equal)).to be true
  79. 1 expect(multi_channel_action_calendar_event_default.eql?(multi_channel_action_calendar_event_values)).to be false
  80. end
  81. end
  82. 1 describe '#to_body #to_hash' do
  83. 1 it 'returns a hash representation of the object' do
  84. 1 expect(multi_channel_action_calendar_event_values.to_body).to eq({
  85. type: Bandwidth::RbmActionTypeEnum::CREATE_CALENDAR_EVENT,
  86. text: 'Add to calendar',
  87. postbackData: 'calendar_postback',
  88. title: 'Bandwidth Demo',
  89. startTime: '2024-06-16T13:15:07.160Z',
  90. endTime: '2024-06-16T14:15:07.160Z',
  91. description: 'A demo of the Bandwidth API'
  92. })
  93. end
  94. end
  95. 1 describe 'custom attribute writers' do
  96. 1 it '#type=' do
  97. 1 expect {
  98. 1 Bandwidth::MultiChannelActionCalendarEvent.new({ type: nil })
  99. }.to raise_error(ArgumentError, 'type cannot be nil')
  100. end
  101. 1 it '#text=' do
  102. 1 expect {
  103. 1 Bandwidth::MultiChannelActionCalendarEvent.new({ type: 'CREATE_CALENDAR_EVENT', text: nil })
  104. }.to raise_error(ArgumentError, 'text cannot be nil')
  105. 1 expect {
  106. 1 Bandwidth::MultiChannelActionCalendarEvent.new({ type: 'CREATE_CALENDAR_EVENT', text: 'a' * 26 })
  107. }.to raise_error(ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 25.')
  108. end
  109. 1 it '#postback_data=' do
  110. 1 expect {
  111. 1 Bandwidth::MultiChannelActionCalendarEvent.new({ type: 'CREATE_CALENDAR_EVENT', text: 'a', postback_data: nil })
  112. }.to raise_error(ArgumentError, 'postback_data cannot be nil')
  113. 1 expect {
  114. 1 Bandwidth::MultiChannelActionCalendarEvent.new({ type: 'CREATE_CALENDAR_EVENT', text: 'a', postback_data: 'a' * 2049 })
  115. }.to raise_error(ArgumentError, 'invalid value for "postback_data", the character length must be smaller than or equal to 2048.')
  116. end
  117. 1 it '#title=' do
  118. 1 expect {
  119. 1 Bandwidth::MultiChannelActionCalendarEvent.new({ type: 'CREATE_CALENDAR_EVENT', text: 'a', postback_data: 'a', title: nil })
  120. }.to raise_error(ArgumentError, 'title cannot be nil')
  121. 1 expect {
  122. 1 Bandwidth::MultiChannelActionCalendarEvent.new({ type: 'CREATE_CALENDAR_EVENT', text: 'a', postback_data: 'a', title: 'a' * 101 })
  123. }.to raise_error(ArgumentError, 'invalid value for "title", the character length must be smaller than or equal to 100.')
  124. end
  125. 1 it '#start_time=' do
  126. 1 expect {
  127. 1 Bandwidth::MultiChannelActionCalendarEvent.new({ type: 'CREATE_CALENDAR_EVENT', text: 'a', postback_data: 'a', title: 'a', start_time: nil })
  128. }.to raise_error(ArgumentError, 'start_time cannot be nil')
  129. end
  130. 1 it '#end_time=' do
  131. 1 expect {
  132. 1 Bandwidth::MultiChannelActionCalendarEvent.new({ type: 'CREATE_CALENDAR_EVENT', text: 'a', postback_data: 'a', title: 'a', start_time: '2024-01-01T00:00:00Z', end_time: nil })
  133. }.to raise_error(ArgumentError, 'end_time cannot be nil')
  134. end
  135. 1 it '#description=' do
  136. 1 expect {
  137. 1 multi_channel_action_calendar_event_values.description = nil
  138. }.to raise_error(ArgumentError, 'description cannot be nil')
  139. 1 expect {
  140. 1 multi_channel_action_calendar_event_values.description = 'a' * 501
  141. }.to raise_error(ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 500.')
  142. end
  143. end
  144. end

spec/unit/models/multi_channel_action_spec.rb

100.0% lines covered

48 relevant lines. 48 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MultiChannelAction
  2. 1 describe Bandwidth::MultiChannelAction do
  3. 1 describe '.openapi_any_of' do
  4. 1 it 'lists the classes defined in anyOf' do
  5. 1 expect(Bandwidth::MultiChannelAction.openapi_any_of).to eq([
  6. :'MultiChannelActionCalendarEvent',
  7. :'RbmActionBase',
  8. :'RbmActionDial',
  9. :'RbmActionOpenUrl',
  10. :'RbmActionViewLocation'
  11. ])
  12. end
  13. end
  14. 1 describe '.openapi_discriminator_name' do
  15. 1 it 'returns the discriminator property name' do
  16. 1 expect(Bandwidth::MultiChannelAction.openapi_discriminator_name).to eq(:'type')
  17. end
  18. end
  19. 1 describe '.openapi_discriminator_mapping' do
  20. 1 it 'maps every discriminator value to an anyOf class' do
  21. 1 expect(Bandwidth::MultiChannelAction.openapi_discriminator_mapping).to eq({
  22. :'CREATE_CALENDAR_EVENT' => :'MultiChannelActionCalendarEvent',
  23. :'DIAL_PHONE' => :'RbmActionDial',
  24. :'OPEN_URL' => :'RbmActionOpenUrl',
  25. :'REPLY' => :'RbmActionBase',
  26. :'REQUEST_LOCATION' => :'RbmActionBase',
  27. :'SHOW_LOCATION' => :'RbmActionViewLocation'
  28. })
  29. end
  30. 1 it 'maps only to classes listed in openapi_any_of' do
  31. 1 mapping_targets = Bandwidth::MultiChannelAction.openapi_discriminator_mapping.values.uniq.sort
  32. 1 expect(mapping_targets).to eq(Bandwidth::MultiChannelAction.openapi_any_of.sort)
  33. end
  34. end
  35. 1 describe '.build' do
  36. 1 it 'routes MultiChannelActionCalendarEvent discriminator values to MultiChannelActionCalendarEvent.build_from_hash' do
  37. 1 Bandwidth::MultiChannelAction.openapi_discriminator_mapping.each do |discriminator, klass|
  38. 6 next unless klass == :'MultiChannelActionCalendarEvent'
  39. 1 data = { type: discriminator.to_s }
  40. 1 expect(Bandwidth::MultiChannelActionCalendarEvent).to receive(:build_from_hash).with(data).and_return(:calendar_event_result)
  41. 1 expect(Bandwidth::MultiChannelAction.build(data)).to eq(:calendar_event_result)
  42. end
  43. end
  44. 1 it 'routes RbmActionBase discriminator values to RbmActionBase.build_from_hash' do
  45. 1 Bandwidth::MultiChannelAction.openapi_discriminator_mapping.each do |discriminator, klass|
  46. 6 next unless klass == :'RbmActionBase'
  47. 2 data = { type: discriminator.to_s }
  48. 2 expect(Bandwidth::RbmActionBase).to receive(:build_from_hash).with(data).and_return(:base_result)
  49. 2 expect(Bandwidth::MultiChannelAction.build(data)).to eq(:base_result)
  50. end
  51. end
  52. 1 it 'routes RbmActionDial discriminator values to RbmActionDial.build_from_hash' do
  53. 1 Bandwidth::MultiChannelAction.openapi_discriminator_mapping.each do |discriminator, klass|
  54. 6 next unless klass == :'RbmActionDial'
  55. 1 data = { type: discriminator.to_s }
  56. 1 expect(Bandwidth::RbmActionDial).to receive(:build_from_hash).with(data).and_return(:dial_result)
  57. 1 expect(Bandwidth::MultiChannelAction.build(data)).to eq(:dial_result)
  58. end
  59. end
  60. 1 it 'routes RbmActionOpenUrl discriminator values to RbmActionOpenUrl.build_from_hash' do
  61. 1 Bandwidth::MultiChannelAction.openapi_discriminator_mapping.each do |discriminator, klass|
  62. 6 next unless klass == :'RbmActionOpenUrl'
  63. 1 data = { type: discriminator.to_s }
  64. 1 expect(Bandwidth::RbmActionOpenUrl).to receive(:build_from_hash).with(data).and_return(:open_url_result)
  65. 1 expect(Bandwidth::MultiChannelAction.build(data)).to eq(:open_url_result)
  66. end
  67. end
  68. 1 it 'routes RbmActionViewLocation discriminator values to RbmActionViewLocation.build_from_hash' do
  69. 1 Bandwidth::MultiChannelAction.openapi_discriminator_mapping.each do |discriminator, klass|
  70. 6 next unless klass == :'RbmActionViewLocation'
  71. 1 data = { type: discriminator.to_s }
  72. 1 expect(Bandwidth::RbmActionViewLocation).to receive(:build_from_hash).with(data).and_return(:view_location_result)
  73. 1 expect(Bandwidth::MultiChannelAction.build(data)).to eq(:view_location_result)
  74. end
  75. end
  76. 1 it 'returns nil when the discriminator value is missing' do
  77. 1 expect(Bandwidth::MultiChannelAction.build({})).to be_nil
  78. end
  79. 1 it 'returns nil when the discriminator value does not match any mapping' do
  80. 1 expect(Bandwidth::MultiChannelAction.build({ type: 'unknown' })).to be_nil
  81. end
  82. end
  83. end

spec/unit/models/multi_channel_channel_list_mms_object_spec.rb

100.0% lines covered

49 relevant lines. 49 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MultiChannelChannelListMMSObject
  2. 1 describe Bandwidth::MultiChannelChannelListMMSObject do
  3. 2 let(:multi_channel_channel_list_mms_object_default) { Bandwidth::MultiChannelChannelListMMSObject.new({
  4. from: '+15554443333',
  5. application_id: 'baseline-app-id',
  6. channel: Bandwidth::MultiChannelMessageChannelEnum::MMS,
  7. content: Bandwidth::MmsMessageContent.new({ text: 'baseline' })
  8. }) }
  9. 4 let(:multi_channel_channel_list_mms_object_values) { Bandwidth::MultiChannelChannelListMMSObject.new({
  10. from: '+19195554321',
  11. application_id: '93de2206-9669-4e07-948d-329f4b722ee2',
  12. channel: Bandwidth::MultiChannelMessageChannelEnum::MMS,
  13. content: Bandwidth::MmsMessageContent.new({ text: 'Hello world' })
  14. }) }
  15. 1 describe '#initialize' do
  16. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  17. 1 expect {
  18. 1 Bandwidth::MultiChannelChannelListMMSObject.new([])
  19. }.to raise_error(ArgumentError)
  20. end
  21. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  22. 1 expect {
  23. 1 Bandwidth::MultiChannelChannelListMMSObject.new({ invalid: true })
  24. }.to raise_error(ArgumentError)
  25. end
  26. end
  27. 1 describe '#acceptable_attributes' do
  28. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  29. 1 expect(Bandwidth::MultiChannelChannelListMMSObject.acceptable_attributes).to eq(Bandwidth::MultiChannelChannelListMMSObject.attribute_map.values)
  30. end
  31. end
  32. 1 describe '#openapi_nullable' do
  33. 1 it 'expects nullable attributes to be an empty set' do
  34. 1 expect(Bandwidth::MultiChannelChannelListMMSObject.openapi_nullable).to eq(Set.new([]))
  35. end
  36. end
  37. 1 describe '#build_from_hash' do
  38. 1 it 'validates instance of MultiChannelChannelListMMSObject created by the build_from_hash method' do
  39. 1 multi_channel_channel_list_mms_object_from_hash = Bandwidth::MultiChannelChannelListMMSObject.build_from_hash({
  40. from: '+19195554321',
  41. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  42. channel: Bandwidth::MultiChannelMessageChannelEnum::MMS,
  43. content: { text: 'Hello world' }
  44. })
  45. 1 expect(multi_channel_channel_list_mms_object_from_hash).to be_instance_of(Bandwidth::MultiChannelChannelListMMSObject)
  46. 1 expect(multi_channel_channel_list_mms_object_from_hash.from).to eq('+19195554321')
  47. 1 expect(multi_channel_channel_list_mms_object_from_hash.application_id).to eq('93de2206-9669-4e07-948d-329f4b722ee2')
  48. 1 expect(multi_channel_channel_list_mms_object_from_hash.channel).to eq(Bandwidth::MultiChannelMessageChannelEnum::MMS)
  49. 1 expect(multi_channel_channel_list_mms_object_from_hash.content).to be_instance_of(Bandwidth::MmsMessageContent)
  50. 1 expect(multi_channel_channel_list_mms_object_from_hash.content.text).to eq('Hello world')
  51. end
  52. end
  53. 1 describe '#to_s' do
  54. 1 it 'returns a string representation of the object' do
  55. 1 expect(multi_channel_channel_list_mms_object_values.to_s).to eq('{:from=>"+19195554321", :applicationId=>"93de2206-9669-4e07-948d-329f4b722ee2", :channel=>"MMS", :content=>{:text=>"Hello world"}}')
  56. end
  57. end
  58. 1 describe '#eq? #==' do
  59. 1 it 'returns true/false when comparing objects' do
  60. 1 multi_channel_channel_list_mms_object_equal = Bandwidth::MultiChannelChannelListMMSObject.new({
  61. from: '+15554443333',
  62. application_id: 'baseline-app-id',
  63. channel: Bandwidth::MultiChannelMessageChannelEnum::MMS,
  64. content: Bandwidth::MmsMessageContent.new({ text: 'baseline' })
  65. })
  66. 1 expect(multi_channel_channel_list_mms_object_default.eql?(multi_channel_channel_list_mms_object_equal)).to be true
  67. 1 expect(multi_channel_channel_list_mms_object_default.eql?(multi_channel_channel_list_mms_object_values)).to be false
  68. end
  69. end
  70. 1 describe '#to_body #to_hash' do
  71. 1 it 'returns a hash representation of the object' do
  72. 1 expect(multi_channel_channel_list_mms_object_values.to_body).to eq({
  73. from: '+19195554321',
  74. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  75. channel: Bandwidth::MultiChannelMessageChannelEnum::MMS,
  76. content: { text: 'Hello world' }
  77. })
  78. end
  79. end
  80. 1 describe 'custom attribute writers' do
  81. 1 it '#from=' do
  82. 1 expect {
  83. 1 Bandwidth::MultiChannelChannelListMMSObject.new({ from: nil })
  84. }.to raise_error(ArgumentError, 'from cannot be nil')
  85. end
  86. 1 it '#application_id=' do
  87. 1 expect {
  88. 1 Bandwidth::MultiChannelChannelListMMSObject.new({ from: '+15554443333', application_id: nil })
  89. }.to raise_error(ArgumentError, 'application_id cannot be nil')
  90. end
  91. 1 it '#channel=' do
  92. 1 expect {
  93. 1 Bandwidth::MultiChannelChannelListMMSObject.new({ from: '+15554443333', application_id: 'a', channel: nil })
  94. }.to raise_error(ArgumentError, 'channel cannot be nil')
  95. end
  96. 1 it '#content=' do
  97. 1 expect {
  98. 1 Bandwidth::MultiChannelChannelListMMSObject.new({ from: '+15554443333', application_id: 'a', channel: 'MMS', content: nil })
  99. }.to raise_error(ArgumentError, 'content cannot be nil')
  100. end
  101. end
  102. end

spec/unit/models/multi_channel_channel_list_mms_response_object_spec.rb

100.0% lines covered

53 relevant lines. 53 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MultiChannelChannelListMMSResponseObject
  2. 1 describe Bandwidth::MultiChannelChannelListMMSResponseObject do
  3. 2 let(:multi_channel_channel_list_mms_response_object_default) { Bandwidth::MultiChannelChannelListMMSResponseObject.new({
  4. from: '+15554443333',
  5. application_id: 'baseline-app-id',
  6. channel: Bandwidth::MultiChannelMessageChannelEnum::MMS,
  7. content: Bandwidth::MmsMessageContent.new({ text: 'baseline' }),
  8. owner: '+15554443333'
  9. }) }
  10. 4 let(:multi_channel_channel_list_mms_response_object_values) { Bandwidth::MultiChannelChannelListMMSResponseObject.new({
  11. from: '+19195554321',
  12. application_id: '93de2206-9669-4e07-948d-329f4b722ee2',
  13. channel: Bandwidth::MultiChannelMessageChannelEnum::MMS,
  14. content: Bandwidth::MmsMessageContent.new({ text: 'Hello world' }),
  15. owner: '+19195554321'
  16. }) }
  17. 1 describe '#initialize' do
  18. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  19. 1 expect {
  20. 1 Bandwidth::MultiChannelChannelListMMSResponseObject.new([])
  21. }.to raise_error(ArgumentError)
  22. end
  23. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  24. 1 expect {
  25. 1 Bandwidth::MultiChannelChannelListMMSResponseObject.new({ invalid: true })
  26. }.to raise_error(ArgumentError)
  27. end
  28. end
  29. 1 describe '#acceptable_attributes' do
  30. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  31. 1 expect(Bandwidth::MultiChannelChannelListMMSResponseObject.acceptable_attributes).to eq(Bandwidth::MultiChannelChannelListMMSResponseObject.attribute_map.values)
  32. end
  33. end
  34. 1 describe '#openapi_nullable' do
  35. 1 it 'expects nullable attributes to be an empty set' do
  36. 1 expect(Bandwidth::MultiChannelChannelListMMSResponseObject.openapi_nullable).to eq(Set.new([]))
  37. end
  38. end
  39. 1 describe '#build_from_hash' do
  40. 1 it 'validates instance of MultiChannelChannelListMMSResponseObject created by the build_from_hash method' do
  41. 1 multi_channel_channel_list_mms_response_object_from_hash = Bandwidth::MultiChannelChannelListMMSResponseObject.build_from_hash({
  42. from: '+19195554321',
  43. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  44. channel: Bandwidth::MultiChannelMessageChannelEnum::MMS,
  45. content: { text: 'Hello world' },
  46. owner: '+19195554321'
  47. })
  48. 1 expect(multi_channel_channel_list_mms_response_object_from_hash).to be_instance_of(Bandwidth::MultiChannelChannelListMMSResponseObject)
  49. 1 expect(multi_channel_channel_list_mms_response_object_from_hash.from).to eq('+19195554321')
  50. 1 expect(multi_channel_channel_list_mms_response_object_from_hash.application_id).to eq('93de2206-9669-4e07-948d-329f4b722ee2')
  51. 1 expect(multi_channel_channel_list_mms_response_object_from_hash.channel).to eq(Bandwidth::MultiChannelMessageChannelEnum::MMS)
  52. 1 expect(multi_channel_channel_list_mms_response_object_from_hash.content).to be_instance_of(Bandwidth::MmsMessageContent)
  53. 1 expect(multi_channel_channel_list_mms_response_object_from_hash.content.text).to eq('Hello world')
  54. 1 expect(multi_channel_channel_list_mms_response_object_from_hash.owner).to eq('+19195554321')
  55. end
  56. end
  57. 1 describe '#to_s' do
  58. 1 it 'returns a string representation of the object' do
  59. 1 expect(multi_channel_channel_list_mms_response_object_values.to_s).to eq('{:from=>"+19195554321", :applicationId=>"93de2206-9669-4e07-948d-329f4b722ee2", :channel=>"MMS", :content=>{:text=>"Hello world"}, :owner=>"+19195554321"}')
  60. end
  61. end
  62. 1 describe '#eq? #==' do
  63. 1 it 'returns true/false when comparing objects' do
  64. 1 multi_channel_channel_list_mms_response_object_equal = Bandwidth::MultiChannelChannelListMMSResponseObject.new({
  65. from: '+15554443333',
  66. application_id: 'baseline-app-id',
  67. channel: Bandwidth::MultiChannelMessageChannelEnum::MMS,
  68. content: Bandwidth::MmsMessageContent.new({ text: 'baseline' }),
  69. owner: '+15554443333'
  70. })
  71. 1 expect(multi_channel_channel_list_mms_response_object_default.eql?(multi_channel_channel_list_mms_response_object_equal)).to be true
  72. 1 expect(multi_channel_channel_list_mms_response_object_default.eql?(multi_channel_channel_list_mms_response_object_values)).to be false
  73. end
  74. end
  75. 1 describe '#to_body #to_hash' do
  76. 1 it 'returns a hash representation of the object' do
  77. 1 expect(multi_channel_channel_list_mms_response_object_values.to_body).to eq({
  78. from: '+19195554321',
  79. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  80. channel: Bandwidth::MultiChannelMessageChannelEnum::MMS,
  81. content: { text: 'Hello world' },
  82. owner: '+19195554321'
  83. })
  84. end
  85. end
  86. 1 describe 'custom attribute writers' do
  87. 1 it '#from=' do
  88. 1 expect {
  89. 1 Bandwidth::MultiChannelChannelListMMSResponseObject.new({ from: nil })
  90. }.to raise_error(ArgumentError, 'from cannot be nil')
  91. end
  92. 1 it '#application_id=' do
  93. 1 expect {
  94. 1 Bandwidth::MultiChannelChannelListMMSResponseObject.new({ from: '+15554443333', application_id: nil })
  95. }.to raise_error(ArgumentError, 'application_id cannot be nil')
  96. end
  97. 1 it '#channel=' do
  98. 1 expect {
  99. 1 Bandwidth::MultiChannelChannelListMMSResponseObject.new({ from: '+15554443333', application_id: 'a', channel: nil })
  100. }.to raise_error(ArgumentError, 'channel cannot be nil')
  101. end
  102. 1 it '#content=' do
  103. 1 expect {
  104. 1 Bandwidth::MultiChannelChannelListMMSResponseObject.new({ from: '+15554443333', application_id: 'a', channel: 'MMS', content: nil })
  105. }.to raise_error(ArgumentError, 'content cannot be nil')
  106. end
  107. 1 it '#owner=' do
  108. 1 expect {
  109. 1 Bandwidth::MultiChannelChannelListMMSResponseObject.new({ from: '+15554443333', application_id: 'a', channel: 'MMS', content: 'c', owner: nil })
  110. }.to raise_error(ArgumentError, 'owner cannot be nil')
  111. end
  112. end
  113. end

spec/unit/models/multi_channel_channel_list_object_base_spec.rb

100.0% lines covered

44 relevant lines. 44 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MultiChannelChannelListObjectBase
  2. 1 describe Bandwidth::MultiChannelChannelListObjectBase do
  3. 2 let(:multi_channel_channel_list_object_base_default) { Bandwidth::MultiChannelChannelListObjectBase.new({
  4. from: '+15554443333',
  5. application_id: 'baseline-app-id',
  6. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS
  7. }) }
  8. 4 let(:multi_channel_channel_list_object_base_values) { Bandwidth::MultiChannelChannelListObjectBase.new({
  9. from: '+19195554321',
  10. application_id: '93de2206-9669-4e07-948d-329f4b722ee2',
  11. channel: Bandwidth::MultiChannelMessageChannelEnum::MMS
  12. }) }
  13. 1 describe '#initialize' do
  14. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  15. 1 expect {
  16. 1 Bandwidth::MultiChannelChannelListObjectBase.new([])
  17. }.to raise_error(ArgumentError)
  18. end
  19. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  20. 1 expect {
  21. 1 Bandwidth::MultiChannelChannelListObjectBase.new({ invalid: true })
  22. }.to raise_error(ArgumentError)
  23. end
  24. end
  25. 1 describe '#acceptable_attributes' do
  26. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  27. 1 expect(Bandwidth::MultiChannelChannelListObjectBase.acceptable_attributes).to eq(Bandwidth::MultiChannelChannelListObjectBase.attribute_map.values)
  28. end
  29. end
  30. 1 describe '#openapi_nullable' do
  31. 1 it 'expects nullable attributes to be an empty set' do
  32. 1 expect(Bandwidth::MultiChannelChannelListObjectBase.openapi_nullable).to eq(Set.new([]))
  33. end
  34. end
  35. 1 describe '#build_from_hash' do
  36. 1 it 'validates instance of MultiChannelChannelListObjectBase created by the build_from_hash method' do
  37. 1 multi_channel_channel_list_object_base_from_hash = Bandwidth::MultiChannelChannelListObjectBase.build_from_hash({
  38. from: '+19195554321',
  39. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  40. channel: Bandwidth::MultiChannelMessageChannelEnum::MMS
  41. })
  42. 1 expect(multi_channel_channel_list_object_base_from_hash).to be_instance_of(Bandwidth::MultiChannelChannelListObjectBase)
  43. 1 expect(multi_channel_channel_list_object_base_from_hash.from).to eq('+19195554321')
  44. 1 expect(multi_channel_channel_list_object_base_from_hash.application_id).to eq('93de2206-9669-4e07-948d-329f4b722ee2')
  45. 1 expect(multi_channel_channel_list_object_base_from_hash.channel).to eq(Bandwidth::MultiChannelMessageChannelEnum::MMS)
  46. end
  47. end
  48. 1 describe '#to_s' do
  49. 1 it 'returns a string representation of the object' do
  50. 1 expect(multi_channel_channel_list_object_base_values.to_s).to eq('{:from=>"+19195554321", :applicationId=>"93de2206-9669-4e07-948d-329f4b722ee2", :channel=>"MMS"}')
  51. end
  52. end
  53. 1 describe '#eq? #==' do
  54. 1 it 'returns true/false when comparing objects' do
  55. 1 multi_channel_channel_list_object_base_equal = Bandwidth::MultiChannelChannelListObjectBase.new({
  56. from: '+15554443333',
  57. application_id: 'baseline-app-id',
  58. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS
  59. })
  60. 1 expect(multi_channel_channel_list_object_base_default.eql?(multi_channel_channel_list_object_base_equal)).to be true
  61. 1 expect(multi_channel_channel_list_object_base_default.eql?(multi_channel_channel_list_object_base_values)).to be false
  62. end
  63. end
  64. 1 describe '#to_body #to_hash' do
  65. 1 it 'returns a hash representation of the object' do
  66. 1 expect(multi_channel_channel_list_object_base_values.to_body).to eq({
  67. from: '+19195554321',
  68. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  69. channel: Bandwidth::MultiChannelMessageChannelEnum::MMS
  70. })
  71. end
  72. end
  73. 1 describe 'custom attribute writers' do
  74. 1 it '#from=' do
  75. 1 expect {
  76. 1 Bandwidth::MultiChannelChannelListObjectBase.new({ from: nil })
  77. }.to raise_error(ArgumentError, 'from cannot be nil')
  78. end
  79. 1 it '#application_id=' do
  80. 1 expect {
  81. 1 Bandwidth::MultiChannelChannelListObjectBase.new({ from: '+15554443333', application_id: nil })
  82. }.to raise_error(ArgumentError, 'application_id cannot be nil')
  83. end
  84. 1 it '#channel=' do
  85. 1 expect {
  86. 1 Bandwidth::MultiChannelChannelListObjectBase.new({ from: '+15554443333', application_id: 'a', channel: nil })
  87. }.to raise_error(ArgumentError, 'channel cannot be nil')
  88. end
  89. end
  90. end

spec/unit/models/multi_channel_channel_list_owner_object_spec.rb

100.0% lines covered

36 relevant lines. 36 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MultiChannelChannelListOwnerObject
  2. 1 describe Bandwidth::MultiChannelChannelListOwnerObject do
  3. 2 let(:multi_channel_channel_list_owner_object_default) { Bandwidth::MultiChannelChannelListOwnerObject.new({
  4. owner: '+15554443333'
  5. }) }
  6. 4 let(:multi_channel_channel_list_owner_object_values) { Bandwidth::MultiChannelChannelListOwnerObject.new({
  7. owner: '+19195554321'
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::MultiChannelChannelListOwnerObject.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::MultiChannelChannelListOwnerObject.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::MultiChannelChannelListOwnerObject.acceptable_attributes).to eq(Bandwidth::MultiChannelChannelListOwnerObject.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be an empty set' do
  28. 1 expect(Bandwidth::MultiChannelChannelListOwnerObject.openapi_nullable).to eq(Set.new([]))
  29. end
  30. end
  31. 1 describe '#build_from_hash' do
  32. 1 it 'validates instance of MultiChannelChannelListOwnerObject created by the build_from_hash method' do
  33. 1 multi_channel_channel_list_owner_object_from_hash = Bandwidth::MultiChannelChannelListOwnerObject.build_from_hash({
  34. owner: '+19195554321'
  35. })
  36. 1 expect(multi_channel_channel_list_owner_object_from_hash).to be_instance_of(Bandwidth::MultiChannelChannelListOwnerObject)
  37. 1 expect(multi_channel_channel_list_owner_object_from_hash.owner).to eq('+19195554321')
  38. end
  39. end
  40. 1 describe '#to_s' do
  41. 1 it 'returns a string representation of the object' do
  42. 1 expect(multi_channel_channel_list_owner_object_values.to_s).to eq('{:owner=>"+19195554321"}')
  43. end
  44. end
  45. 1 describe '#eq? #==' do
  46. 1 it 'returns true/false when comparing objects' do
  47. 1 multi_channel_channel_list_owner_object_equal = Bandwidth::MultiChannelChannelListOwnerObject.new({
  48. owner: '+15554443333'
  49. })
  50. 1 expect(multi_channel_channel_list_owner_object_default.eql?(multi_channel_channel_list_owner_object_equal)).to be true
  51. 1 expect(multi_channel_channel_list_owner_object_default.eql?(multi_channel_channel_list_owner_object_values)).to be false
  52. end
  53. end
  54. 1 describe '#to_body #to_hash' do
  55. 1 it 'returns a hash representation of the object' do
  56. 1 expect(multi_channel_channel_list_owner_object_values.to_body).to eq({
  57. owner: '+19195554321'
  58. })
  59. end
  60. end
  61. 1 describe 'custom attribute writers' do
  62. 1 it '#owner=' do
  63. 1 expect {
  64. 1 Bandwidth::MultiChannelChannelListOwnerObject.new({ owner: nil })
  65. }.to raise_error(ArgumentError, 'owner cannot be nil')
  66. end
  67. end
  68. end

spec/unit/models/multi_channel_channel_list_rbm_object_all_of_content_spec.rb

100.0% lines covered

13 relevant lines. 13 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MultiChannelChannelListRBMObjectAllOfContent
  2. 1 describe Bandwidth::MultiChannelChannelListRBMObjectAllOfContent do
  3. 1 describe '.openapi_one_of' do
  4. 1 it 'lists the classes defined in oneOf' do
  5. 1 expect(Bandwidth::MultiChannelChannelListRBMObjectAllOfContent.openapi_one_of).to eq([
  6. :'RbmMessageContentRichCard',
  7. :'RbmMessageContentText',
  8. :'RbmMessageMedia'
  9. ])
  10. end
  11. end
  12. 1 describe '.build' do
  13. 1 it 'routes payloads matching RbmMessageContentText attributes to RbmMessageContentText.build_from_hash' do
  14. 1 data = { text: 'Hello world' }
  15. 1 expect(Bandwidth::MultiChannelChannelListRBMObjectAllOfContent.build(data)).to be_instance_of(Bandwidth::RbmMessageContentText)
  16. end
  17. 1 it 'routes payloads matching RbmMessageMedia attributes to RbmMessageMedia.build_from_hash' do
  18. 1 data = { media: [{ fileUrl: 'https://example.com/image.png' }] }
  19. 1 expect(Bandwidth::MultiChannelChannelListRBMObjectAllOfContent.build(data)).to be_instance_of(Bandwidth::RbmMessageMedia)
  20. end
  21. 1 it 'returns nil when the payload does not match any oneOf schema' do
  22. 1 expect(Bandwidth::MultiChannelChannelListRBMObjectAllOfContent.build({ unknown: 'value' })).to be_nil
  23. end
  24. end
  25. end

spec/unit/models/multi_channel_channel_list_rbm_object_spec.rb

100.0% lines covered

49 relevant lines. 49 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MultiChannelChannelListRBMObject
  2. 1 describe Bandwidth::MultiChannelChannelListRBMObject do
  3. 2 let(:multi_channel_channel_list_rbm_object_default) { Bandwidth::MultiChannelChannelListRBMObject.new({
  4. from: 'BANDWIDTH',
  5. application_id: 'baseline-app-id',
  6. channel: Bandwidth::MultiChannelMessageChannelEnum::RBM,
  7. content: Bandwidth::RbmMessageContentText.new({ text: 'baseline' })
  8. }) }
  9. 4 let(:multi_channel_channel_list_rbm_object_values) { Bandwidth::MultiChannelChannelListRBMObject.new({
  10. from: 'BANDWIDTH',
  11. application_id: '93de2206-9669-4e07-948d-329f4b722ee2',
  12. channel: Bandwidth::MultiChannelMessageChannelEnum::RBM,
  13. content: Bandwidth::RbmMessageContentText.new({ text: 'Hello world' })
  14. }) }
  15. 1 describe '#initialize' do
  16. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  17. 1 expect {
  18. 1 Bandwidth::MultiChannelChannelListRBMObject.new([])
  19. }.to raise_error(ArgumentError)
  20. end
  21. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  22. 1 expect {
  23. 1 Bandwidth::MultiChannelChannelListRBMObject.new({ invalid: true })
  24. }.to raise_error(ArgumentError)
  25. end
  26. end
  27. 1 describe '#acceptable_attributes' do
  28. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  29. 1 expect(Bandwidth::MultiChannelChannelListRBMObject.acceptable_attributes).to eq(Bandwidth::MultiChannelChannelListRBMObject.attribute_map.values)
  30. end
  31. end
  32. 1 describe '#openapi_nullable' do
  33. 1 it 'expects nullable attributes to be an empty set' do
  34. 1 expect(Bandwidth::MultiChannelChannelListRBMObject.openapi_nullable).to eq(Set.new([]))
  35. end
  36. end
  37. 1 describe '#build_from_hash' do
  38. 1 it 'validates instance of MultiChannelChannelListRBMObject created by the build_from_hash method' do
  39. 1 multi_channel_channel_list_rbm_object_from_hash = Bandwidth::MultiChannelChannelListRBMObject.build_from_hash({
  40. from: 'BANDWIDTH',
  41. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  42. channel: Bandwidth::MultiChannelMessageChannelEnum::RBM,
  43. content: { text: 'Hello world' }
  44. })
  45. 1 expect(multi_channel_channel_list_rbm_object_from_hash).to be_instance_of(Bandwidth::MultiChannelChannelListRBMObject)
  46. 1 expect(multi_channel_channel_list_rbm_object_from_hash.from).to eq('BANDWIDTH')
  47. 1 expect(multi_channel_channel_list_rbm_object_from_hash.application_id).to eq('93de2206-9669-4e07-948d-329f4b722ee2')
  48. 1 expect(multi_channel_channel_list_rbm_object_from_hash.channel).to eq(Bandwidth::MultiChannelMessageChannelEnum::RBM)
  49. 1 expect(multi_channel_channel_list_rbm_object_from_hash.content).to be_instance_of(Bandwidth::RbmMessageContentText)
  50. 1 expect(multi_channel_channel_list_rbm_object_from_hash.content.text).to eq('Hello world')
  51. end
  52. end
  53. 1 describe '#to_s' do
  54. 1 it 'returns a string representation of the object' do
  55. 1 expect(multi_channel_channel_list_rbm_object_values.to_s).to eq('{:from=>"BANDWIDTH", :applicationId=>"93de2206-9669-4e07-948d-329f4b722ee2", :channel=>"RBM", :content=>{:text=>"Hello world"}}')
  56. end
  57. end
  58. 1 describe '#eq? #==' do
  59. 1 it 'returns true/false when comparing objects' do
  60. 1 multi_channel_channel_list_rbm_object_equal = Bandwidth::MultiChannelChannelListRBMObject.new({
  61. from: 'BANDWIDTH',
  62. application_id: 'baseline-app-id',
  63. channel: Bandwidth::MultiChannelMessageChannelEnum::RBM,
  64. content: Bandwidth::RbmMessageContentText.new({ text: 'baseline' })
  65. })
  66. 1 expect(multi_channel_channel_list_rbm_object_default.eql?(multi_channel_channel_list_rbm_object_equal)).to be true
  67. 1 expect(multi_channel_channel_list_rbm_object_default.eql?(multi_channel_channel_list_rbm_object_values)).to be false
  68. end
  69. end
  70. 1 describe '#to_body #to_hash' do
  71. 1 it 'returns a hash representation of the object' do
  72. 1 expect(multi_channel_channel_list_rbm_object_values.to_body).to eq({
  73. from: 'BANDWIDTH',
  74. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  75. channel: Bandwidth::MultiChannelMessageChannelEnum::RBM,
  76. content: { text: 'Hello world' }
  77. })
  78. end
  79. end
  80. 1 describe 'custom attribute writers' do
  81. 1 it '#from=' do
  82. 1 expect {
  83. 1 Bandwidth::MultiChannelChannelListRBMObject.new({ from: nil })
  84. }.to raise_error(ArgumentError, 'from cannot be nil')
  85. end
  86. 1 it '#application_id=' do
  87. 1 expect {
  88. 1 Bandwidth::MultiChannelChannelListRBMObject.new({ from: 'BANDWIDTH', application_id: nil })
  89. }.to raise_error(ArgumentError, 'application_id cannot be nil')
  90. end
  91. 1 it '#channel=' do
  92. 1 expect {
  93. 1 Bandwidth::MultiChannelChannelListRBMObject.new({ from: 'BANDWIDTH', application_id: 'a', channel: nil })
  94. }.to raise_error(ArgumentError, 'channel cannot be nil')
  95. end
  96. 1 it '#content=' do
  97. 1 expect {
  98. 1 Bandwidth::MultiChannelChannelListRBMObject.new({ from: 'BANDWIDTH', application_id: 'a', channel: 'RBM', content: nil })
  99. }.to raise_error(ArgumentError, 'content cannot be nil')
  100. end
  101. end
  102. end

spec/unit/models/multi_channel_channel_list_rbm_response_object_spec.rb

100.0% lines covered

53 relevant lines. 53 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MultiChannelChannelListRBMResponseObject
  2. 1 describe Bandwidth::MultiChannelChannelListRBMResponseObject do
  3. 2 let(:multi_channel_channel_list_rbm_response_object_default) { Bandwidth::MultiChannelChannelListRBMResponseObject.new({
  4. from: 'BANDWIDTH',
  5. application_id: 'baseline-app-id',
  6. channel: Bandwidth::MultiChannelMessageChannelEnum::RBM,
  7. content: Bandwidth::RbmMessageContentText.new({ text: 'baseline' }),
  8. owner: 'BANDWIDTH'
  9. }) }
  10. 4 let(:multi_channel_channel_list_rbm_response_object_values) { Bandwidth::MultiChannelChannelListRBMResponseObject.new({
  11. from: 'BANDWIDTH',
  12. application_id: '93de2206-9669-4e07-948d-329f4b722ee2',
  13. channel: Bandwidth::MultiChannelMessageChannelEnum::RBM,
  14. content: Bandwidth::RbmMessageContentText.new({ text: 'Hello world' }),
  15. owner: 'BANDWIDTH'
  16. }) }
  17. 1 describe '#initialize' do
  18. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  19. 1 expect {
  20. 1 Bandwidth::MultiChannelChannelListRBMResponseObject.new([])
  21. }.to raise_error(ArgumentError)
  22. end
  23. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  24. 1 expect {
  25. 1 Bandwidth::MultiChannelChannelListRBMResponseObject.new({ invalid: true })
  26. }.to raise_error(ArgumentError)
  27. end
  28. end
  29. 1 describe '#acceptable_attributes' do
  30. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  31. 1 expect(Bandwidth::MultiChannelChannelListRBMResponseObject.acceptable_attributes).to eq(Bandwidth::MultiChannelChannelListRBMResponseObject.attribute_map.values)
  32. end
  33. end
  34. 1 describe '#openapi_nullable' do
  35. 1 it 'expects nullable attributes to be an empty set' do
  36. 1 expect(Bandwidth::MultiChannelChannelListRBMResponseObject.openapi_nullable).to eq(Set.new([]))
  37. end
  38. end
  39. 1 describe '#build_from_hash' do
  40. 1 it 'validates instance of MultiChannelChannelListRBMResponseObject created by the build_from_hash method' do
  41. 1 multi_channel_channel_list_rbm_response_object_from_hash = Bandwidth::MultiChannelChannelListRBMResponseObject.build_from_hash({
  42. from: 'BANDWIDTH',
  43. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  44. channel: Bandwidth::MultiChannelMessageChannelEnum::RBM,
  45. content: { text: 'Hello world' },
  46. owner: 'BANDWIDTH'
  47. })
  48. 1 expect(multi_channel_channel_list_rbm_response_object_from_hash).to be_instance_of(Bandwidth::MultiChannelChannelListRBMResponseObject)
  49. 1 expect(multi_channel_channel_list_rbm_response_object_from_hash.from).to eq('BANDWIDTH')
  50. 1 expect(multi_channel_channel_list_rbm_response_object_from_hash.application_id).to eq('93de2206-9669-4e07-948d-329f4b722ee2')
  51. 1 expect(multi_channel_channel_list_rbm_response_object_from_hash.channel).to eq(Bandwidth::MultiChannelMessageChannelEnum::RBM)
  52. 1 expect(multi_channel_channel_list_rbm_response_object_from_hash.content).to be_instance_of(Bandwidth::RbmMessageContentText)
  53. 1 expect(multi_channel_channel_list_rbm_response_object_from_hash.content.text).to eq('Hello world')
  54. 1 expect(multi_channel_channel_list_rbm_response_object_from_hash.owner).to eq('BANDWIDTH')
  55. end
  56. end
  57. 1 describe '#to_s' do
  58. 1 it 'returns a string representation of the object' do
  59. 1 expect(multi_channel_channel_list_rbm_response_object_values.to_s).to eq('{:from=>"BANDWIDTH", :applicationId=>"93de2206-9669-4e07-948d-329f4b722ee2", :channel=>"RBM", :content=>{:text=>"Hello world"}, :owner=>"BANDWIDTH"}')
  60. end
  61. end
  62. 1 describe '#eq? #==' do
  63. 1 it 'returns true/false when comparing objects' do
  64. 1 multi_channel_channel_list_rbm_response_object_equal = Bandwidth::MultiChannelChannelListRBMResponseObject.new({
  65. from: 'BANDWIDTH',
  66. application_id: 'baseline-app-id',
  67. channel: Bandwidth::MultiChannelMessageChannelEnum::RBM,
  68. content: Bandwidth::RbmMessageContentText.new({ text: 'baseline' }),
  69. owner: 'BANDWIDTH'
  70. })
  71. 1 expect(multi_channel_channel_list_rbm_response_object_default.eql?(multi_channel_channel_list_rbm_response_object_equal)).to be true
  72. 1 expect(multi_channel_channel_list_rbm_response_object_default.eql?(multi_channel_channel_list_rbm_response_object_values)).to be false
  73. end
  74. end
  75. 1 describe '#to_body #to_hash' do
  76. 1 it 'returns a hash representation of the object' do
  77. 1 expect(multi_channel_channel_list_rbm_response_object_values.to_body).to eq({
  78. from: 'BANDWIDTH',
  79. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  80. channel: Bandwidth::MultiChannelMessageChannelEnum::RBM,
  81. content: { text: 'Hello world' },
  82. owner: 'BANDWIDTH'
  83. })
  84. end
  85. end
  86. 1 describe 'custom attribute writers' do
  87. 1 it '#from=' do
  88. 1 expect {
  89. 1 Bandwidth::MultiChannelChannelListRBMResponseObject.new({ from: nil })
  90. }.to raise_error(ArgumentError, 'from cannot be nil')
  91. end
  92. 1 it '#application_id=' do
  93. 1 expect {
  94. 1 Bandwidth::MultiChannelChannelListRBMResponseObject.new({ from: 'BANDWIDTH', application_id: nil })
  95. }.to raise_error(ArgumentError, 'application_id cannot be nil')
  96. end
  97. 1 it '#channel=' do
  98. 1 expect {
  99. 1 Bandwidth::MultiChannelChannelListRBMResponseObject.new({ from: 'BANDWIDTH', application_id: 'a', channel: nil })
  100. }.to raise_error(ArgumentError, 'channel cannot be nil')
  101. end
  102. 1 it '#content=' do
  103. 1 expect {
  104. 1 Bandwidth::MultiChannelChannelListRBMResponseObject.new({ from: 'BANDWIDTH', application_id: 'a', channel: 'RBM', content: nil })
  105. }.to raise_error(ArgumentError, 'content cannot be nil')
  106. end
  107. 1 it '#owner=' do
  108. 1 expect {
  109. 1 Bandwidth::MultiChannelChannelListRBMResponseObject.new({ from: 'BANDWIDTH', application_id: 'a', channel: 'RBM', content: 'c', owner: nil })
  110. }.to raise_error(ArgumentError, 'owner cannot be nil')
  111. end
  112. end
  113. end

spec/unit/models/multi_channel_channel_list_request_object_spec.rb

100.0% lines covered

36 relevant lines. 36 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MultiChannelChannelListRequestObject
  2. 1 describe Bandwidth::MultiChannelChannelListRequestObject do
  3. 1 describe '.openapi_any_of' do
  4. 1 it 'lists the classes defined in anyOf' do
  5. 1 expect(Bandwidth::MultiChannelChannelListRequestObject.openapi_any_of).to eq([
  6. :'MultiChannelChannelListMMSObject',
  7. :'MultiChannelChannelListRBMObject',
  8. :'MultiChannelChannelListSMSObject'
  9. ])
  10. end
  11. end
  12. 1 describe '.openapi_discriminator_name' do
  13. 1 it 'returns the discriminator property name' do
  14. 1 expect(Bandwidth::MultiChannelChannelListRequestObject.openapi_discriminator_name).to eq(:'channel')
  15. end
  16. end
  17. 1 describe '.openapi_discriminator_mapping' do
  18. 1 it 'maps every discriminator value to an anyOf class' do
  19. 1 expect(Bandwidth::MultiChannelChannelListRequestObject.openapi_discriminator_mapping).to eq({
  20. :'MMS' => :'MultiChannelChannelListMMSObject',
  21. :'RBM' => :'MultiChannelChannelListRBMObject',
  22. :'SMS' => :'MultiChannelChannelListSMSObject'
  23. })
  24. end
  25. 1 it 'maps only to classes listed in openapi_any_of' do
  26. 1 mapping_targets = Bandwidth::MultiChannelChannelListRequestObject.openapi_discriminator_mapping.values.uniq.sort
  27. 1 expect(mapping_targets).to eq(Bandwidth::MultiChannelChannelListRequestObject.openapi_any_of.sort)
  28. end
  29. end
  30. 1 describe '.build' do
  31. 1 it 'routes MultiChannelChannelListMMSObject discriminator values to MultiChannelChannelListMMSObject.build_from_hash' do
  32. 1 Bandwidth::MultiChannelChannelListRequestObject.openapi_discriminator_mapping.each do |discriminator, klass|
  33. 3 next unless klass == :'MultiChannelChannelListMMSObject'
  34. 1 data = { channel: discriminator.to_s }
  35. 1 expect(Bandwidth::MultiChannelChannelListMMSObject).to receive(:build_from_hash).with(data).and_return(:mms_result)
  36. 1 expect(Bandwidth::MultiChannelChannelListRequestObject.build(data)).to eq(:mms_result)
  37. end
  38. end
  39. 1 it 'routes MultiChannelChannelListRBMObject discriminator values to MultiChannelChannelListRBMObject.build_from_hash' do
  40. 1 Bandwidth::MultiChannelChannelListRequestObject.openapi_discriminator_mapping.each do |discriminator, klass|
  41. 3 next unless klass == :'MultiChannelChannelListRBMObject'
  42. 1 data = { channel: discriminator.to_s }
  43. 1 expect(Bandwidth::MultiChannelChannelListRBMObject).to receive(:build_from_hash).with(data).and_return(:rbm_result)
  44. 1 expect(Bandwidth::MultiChannelChannelListRequestObject.build(data)).to eq(:rbm_result)
  45. end
  46. end
  47. 1 it 'routes MultiChannelChannelListSMSObject discriminator values to MultiChannelChannelListSMSObject.build_from_hash' do
  48. 1 Bandwidth::MultiChannelChannelListRequestObject.openapi_discriminator_mapping.each do |discriminator, klass|
  49. 3 next unless klass == :'MultiChannelChannelListSMSObject'
  50. 1 data = { channel: discriminator.to_s }
  51. 1 expect(Bandwidth::MultiChannelChannelListSMSObject).to receive(:build_from_hash).with(data).and_return(:sms_result)
  52. 1 expect(Bandwidth::MultiChannelChannelListRequestObject.build(data)).to eq(:sms_result)
  53. end
  54. end
  55. 1 it 'returns nil when the discriminator value is missing' do
  56. 1 expect(Bandwidth::MultiChannelChannelListRequestObject.build({})).to be_nil
  57. end
  58. 1 it 'returns nil when the discriminator value does not match any mapping' do
  59. 1 expect(Bandwidth::MultiChannelChannelListRequestObject.build({ channel: 'unknown' })).to be_nil
  60. end
  61. end
  62. end

spec/unit/models/multi_channel_channel_list_response_object_spec.rb

100.0% lines covered

36 relevant lines. 36 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MultiChannelChannelListResponseObject
  2. 1 describe Bandwidth::MultiChannelChannelListResponseObject do
  3. 1 describe '.openapi_any_of' do
  4. 1 it 'lists the classes defined in anyOf' do
  5. 1 expect(Bandwidth::MultiChannelChannelListResponseObject.openapi_any_of).to eq([
  6. :'MultiChannelChannelListMMSResponseObject',
  7. :'MultiChannelChannelListRBMResponseObject',
  8. :'MultiChannelChannelListSMSResponseObject'
  9. ])
  10. end
  11. end
  12. 1 describe '.openapi_discriminator_name' do
  13. 1 it 'returns the discriminator property name' do
  14. 1 expect(Bandwidth::MultiChannelChannelListResponseObject.openapi_discriminator_name).to eq(:'channel')
  15. end
  16. end
  17. 1 describe '.openapi_discriminator_mapping' do
  18. 1 it 'maps every discriminator value to an anyOf class' do
  19. 1 expect(Bandwidth::MultiChannelChannelListResponseObject.openapi_discriminator_mapping).to eq({
  20. :'MMS' => :'MultiChannelChannelListMMSResponseObject',
  21. :'RBM' => :'MultiChannelChannelListRBMResponseObject',
  22. :'SMS' => :'MultiChannelChannelListSMSResponseObject'
  23. })
  24. end
  25. 1 it 'maps only to classes listed in openapi_any_of' do
  26. 1 mapping_targets = Bandwidth::MultiChannelChannelListResponseObject.openapi_discriminator_mapping.values.uniq.sort
  27. 1 expect(mapping_targets).to eq(Bandwidth::MultiChannelChannelListResponseObject.openapi_any_of.sort)
  28. end
  29. end
  30. 1 describe '.build' do
  31. 1 it 'routes MultiChannelChannelListMMSResponseObject discriminator values to MultiChannelChannelListMMSResponseObject.build_from_hash' do
  32. 1 Bandwidth::MultiChannelChannelListResponseObject.openapi_discriminator_mapping.each do |discriminator, klass|
  33. 3 next unless klass == :'MultiChannelChannelListMMSResponseObject'
  34. 1 data = { channel: discriminator.to_s }
  35. 1 expect(Bandwidth::MultiChannelChannelListMMSResponseObject).to receive(:build_from_hash).with(data).and_return(:mms_result)
  36. 1 expect(Bandwidth::MultiChannelChannelListResponseObject.build(data)).to eq(:mms_result)
  37. end
  38. end
  39. 1 it 'routes MultiChannelChannelListRBMResponseObject discriminator values to MultiChannelChannelListRBMResponseObject.build_from_hash' do
  40. 1 Bandwidth::MultiChannelChannelListResponseObject.openapi_discriminator_mapping.each do |discriminator, klass|
  41. 3 next unless klass == :'MultiChannelChannelListRBMResponseObject'
  42. 1 data = { channel: discriminator.to_s }
  43. 1 expect(Bandwidth::MultiChannelChannelListRBMResponseObject).to receive(:build_from_hash).with(data).and_return(:rbm_result)
  44. 1 expect(Bandwidth::MultiChannelChannelListResponseObject.build(data)).to eq(:rbm_result)
  45. end
  46. end
  47. 1 it 'routes MultiChannelChannelListSMSResponseObject discriminator values to MultiChannelChannelListSMSResponseObject.build_from_hash' do
  48. 1 Bandwidth::MultiChannelChannelListResponseObject.openapi_discriminator_mapping.each do |discriminator, klass|
  49. 3 next unless klass == :'MultiChannelChannelListSMSResponseObject'
  50. 1 data = { channel: discriminator.to_s }
  51. 1 expect(Bandwidth::MultiChannelChannelListSMSResponseObject).to receive(:build_from_hash).with(data).and_return(:sms_result)
  52. 1 expect(Bandwidth::MultiChannelChannelListResponseObject.build(data)).to eq(:sms_result)
  53. end
  54. end
  55. 1 it 'returns nil when the discriminator value is missing' do
  56. 1 expect(Bandwidth::MultiChannelChannelListResponseObject.build({})).to be_nil
  57. end
  58. 1 it 'returns nil when the discriminator value does not match any mapping' do
  59. 1 expect(Bandwidth::MultiChannelChannelListResponseObject.build({ channel: 'unknown' })).to be_nil
  60. end
  61. end
  62. end

spec/unit/models/multi_channel_channel_list_sms_object_spec.rb

100.0% lines covered

49 relevant lines. 49 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MultiChannelChannelListSMSObject
  2. 1 describe Bandwidth::MultiChannelChannelListSMSObject do
  3. 2 let(:multi_channel_channel_list_sms_object_default) { Bandwidth::MultiChannelChannelListSMSObject.new({
  4. from: '+15554443333',
  5. application_id: 'baseline-app-id',
  6. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS,
  7. content: Bandwidth::SmsMessageContent.new({ text: 'baseline' })
  8. }) }
  9. 4 let(:multi_channel_channel_list_sms_object_values) { Bandwidth::MultiChannelChannelListSMSObject.new({
  10. from: '+19195554321',
  11. application_id: '93de2206-9669-4e07-948d-329f4b722ee2',
  12. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS,
  13. content: Bandwidth::SmsMessageContent.new({ text: 'Hello world' })
  14. }) }
  15. 1 describe '#initialize' do
  16. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  17. 1 expect {
  18. 1 Bandwidth::MultiChannelChannelListSMSObject.new([])
  19. }.to raise_error(ArgumentError)
  20. end
  21. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  22. 1 expect {
  23. 1 Bandwidth::MultiChannelChannelListSMSObject.new({ invalid: true })
  24. }.to raise_error(ArgumentError)
  25. end
  26. end
  27. 1 describe '#acceptable_attributes' do
  28. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  29. 1 expect(Bandwidth::MultiChannelChannelListSMSObject.acceptable_attributes).to eq(Bandwidth::MultiChannelChannelListSMSObject.attribute_map.values)
  30. end
  31. end
  32. 1 describe '#openapi_nullable' do
  33. 1 it 'expects nullable attributes to be an empty set' do
  34. 1 expect(Bandwidth::MultiChannelChannelListSMSObject.openapi_nullable).to eq(Set.new([]))
  35. end
  36. end
  37. 1 describe '#build_from_hash' do
  38. 1 it 'validates instance of MultiChannelChannelListSMSObject created by the build_from_hash method' do
  39. 1 multi_channel_channel_list_sms_object_from_hash = Bandwidth::MultiChannelChannelListSMSObject.build_from_hash({
  40. from: '+19195554321',
  41. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  42. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS,
  43. content: { text: 'Hello world' }
  44. })
  45. 1 expect(multi_channel_channel_list_sms_object_from_hash).to be_instance_of(Bandwidth::MultiChannelChannelListSMSObject)
  46. 1 expect(multi_channel_channel_list_sms_object_from_hash.from).to eq('+19195554321')
  47. 1 expect(multi_channel_channel_list_sms_object_from_hash.application_id).to eq('93de2206-9669-4e07-948d-329f4b722ee2')
  48. 1 expect(multi_channel_channel_list_sms_object_from_hash.channel).to eq(Bandwidth::MultiChannelMessageChannelEnum::SMS)
  49. 1 expect(multi_channel_channel_list_sms_object_from_hash.content).to be_instance_of(Bandwidth::SmsMessageContent)
  50. 1 expect(multi_channel_channel_list_sms_object_from_hash.content.text).to eq('Hello world')
  51. end
  52. end
  53. 1 describe '#to_s' do
  54. 1 it 'returns a string representation of the object' do
  55. 1 expect(multi_channel_channel_list_sms_object_values.to_s).to eq('{:from=>"+19195554321", :applicationId=>"93de2206-9669-4e07-948d-329f4b722ee2", :channel=>"SMS", :content=>{:text=>"Hello world"}}')
  56. end
  57. end
  58. 1 describe '#eq? #==' do
  59. 1 it 'returns true/false when comparing objects' do
  60. 1 multi_channel_channel_list_sms_object_equal = Bandwidth::MultiChannelChannelListSMSObject.new({
  61. from: '+15554443333',
  62. application_id: 'baseline-app-id',
  63. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS,
  64. content: Bandwidth::SmsMessageContent.new({ text: 'baseline' })
  65. })
  66. 1 expect(multi_channel_channel_list_sms_object_default.eql?(multi_channel_channel_list_sms_object_equal)).to be true
  67. 1 expect(multi_channel_channel_list_sms_object_default.eql?(multi_channel_channel_list_sms_object_values)).to be false
  68. end
  69. end
  70. 1 describe '#to_body #to_hash' do
  71. 1 it 'returns a hash representation of the object' do
  72. 1 expect(multi_channel_channel_list_sms_object_values.to_body).to eq({
  73. from: '+19195554321',
  74. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  75. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS,
  76. content: { text: 'Hello world' }
  77. })
  78. end
  79. end
  80. 1 describe 'custom attribute writers' do
  81. 1 it '#from=' do
  82. 1 expect {
  83. 1 Bandwidth::MultiChannelChannelListSMSObject.new({ from: nil })
  84. }.to raise_error(ArgumentError, 'from cannot be nil')
  85. end
  86. 1 it '#application_id=' do
  87. 1 expect {
  88. 1 Bandwidth::MultiChannelChannelListSMSObject.new({ from: '+15554443333', application_id: nil })
  89. }.to raise_error(ArgumentError, 'application_id cannot be nil')
  90. end
  91. 1 it '#channel=' do
  92. 1 expect {
  93. 1 Bandwidth::MultiChannelChannelListSMSObject.new({ from: '+15554443333', application_id: 'a', channel: nil })
  94. }.to raise_error(ArgumentError, 'channel cannot be nil')
  95. end
  96. 1 it '#content=' do
  97. 1 expect {
  98. 1 Bandwidth::MultiChannelChannelListSMSObject.new({ from: '+15554443333', application_id: 'a', channel: 'SMS', content: nil })
  99. }.to raise_error(ArgumentError, 'content cannot be nil')
  100. end
  101. end
  102. end

spec/unit/models/multi_channel_channel_list_sms_response_object_spec.rb

100.0% lines covered

53 relevant lines. 53 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MultiChannelChannelListSMSResponseObject
  2. 1 describe Bandwidth::MultiChannelChannelListSMSResponseObject do
  3. 2 let(:multi_channel_channel_list_sms_response_object_default) { Bandwidth::MultiChannelChannelListSMSResponseObject.new({
  4. from: '+15554443333',
  5. application_id: 'baseline-app-id',
  6. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS,
  7. content: Bandwidth::SmsMessageContent.new({ text: 'baseline' }),
  8. owner: '+15554443333'
  9. }) }
  10. 4 let(:multi_channel_channel_list_sms_response_object_values) { Bandwidth::MultiChannelChannelListSMSResponseObject.new({
  11. from: '+19195554321',
  12. application_id: '93de2206-9669-4e07-948d-329f4b722ee2',
  13. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS,
  14. content: Bandwidth::SmsMessageContent.new({ text: 'Hello world' }),
  15. owner: '+19195554321'
  16. }) }
  17. 1 describe '#initialize' do
  18. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  19. 1 expect {
  20. 1 Bandwidth::MultiChannelChannelListSMSResponseObject.new([])
  21. }.to raise_error(ArgumentError)
  22. end
  23. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  24. 1 expect {
  25. 1 Bandwidth::MultiChannelChannelListSMSResponseObject.new({ invalid: true })
  26. }.to raise_error(ArgumentError)
  27. end
  28. end
  29. 1 describe '#acceptable_attributes' do
  30. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  31. 1 expect(Bandwidth::MultiChannelChannelListSMSResponseObject.acceptable_attributes).to eq(Bandwidth::MultiChannelChannelListSMSResponseObject.attribute_map.values)
  32. end
  33. end
  34. 1 describe '#openapi_nullable' do
  35. 1 it 'expects nullable attributes to be an empty set' do
  36. 1 expect(Bandwidth::MultiChannelChannelListSMSResponseObject.openapi_nullable).to eq(Set.new([]))
  37. end
  38. end
  39. 1 describe '#build_from_hash' do
  40. 1 it 'validates instance of MultiChannelChannelListSMSResponseObject created by the build_from_hash method' do
  41. 1 multi_channel_channel_list_sms_response_object_from_hash = Bandwidth::MultiChannelChannelListSMSResponseObject.build_from_hash({
  42. from: '+19195554321',
  43. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  44. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS,
  45. content: { text: 'Hello world' },
  46. owner: '+19195554321'
  47. })
  48. 1 expect(multi_channel_channel_list_sms_response_object_from_hash).to be_instance_of(Bandwidth::MultiChannelChannelListSMSResponseObject)
  49. 1 expect(multi_channel_channel_list_sms_response_object_from_hash.from).to eq('+19195554321')
  50. 1 expect(multi_channel_channel_list_sms_response_object_from_hash.application_id).to eq('93de2206-9669-4e07-948d-329f4b722ee2')
  51. 1 expect(multi_channel_channel_list_sms_response_object_from_hash.channel).to eq(Bandwidth::MultiChannelMessageChannelEnum::SMS)
  52. 1 expect(multi_channel_channel_list_sms_response_object_from_hash.content).to be_instance_of(Bandwidth::SmsMessageContent)
  53. 1 expect(multi_channel_channel_list_sms_response_object_from_hash.content.text).to eq('Hello world')
  54. 1 expect(multi_channel_channel_list_sms_response_object_from_hash.owner).to eq('+19195554321')
  55. end
  56. end
  57. 1 describe '#to_s' do
  58. 1 it 'returns a string representation of the object' do
  59. 1 expect(multi_channel_channel_list_sms_response_object_values.to_s).to eq('{:from=>"+19195554321", :applicationId=>"93de2206-9669-4e07-948d-329f4b722ee2", :channel=>"SMS", :content=>{:text=>"Hello world"}, :owner=>"+19195554321"}')
  60. end
  61. end
  62. 1 describe '#eq? #==' do
  63. 1 it 'returns true/false when comparing objects' do
  64. 1 multi_channel_channel_list_sms_response_object_equal = Bandwidth::MultiChannelChannelListSMSResponseObject.new({
  65. from: '+15554443333',
  66. application_id: 'baseline-app-id',
  67. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS,
  68. content: Bandwidth::SmsMessageContent.new({ text: 'baseline' }),
  69. owner: '+15554443333'
  70. })
  71. 1 expect(multi_channel_channel_list_sms_response_object_default.eql?(multi_channel_channel_list_sms_response_object_equal)).to be true
  72. 1 expect(multi_channel_channel_list_sms_response_object_default.eql?(multi_channel_channel_list_sms_response_object_values)).to be false
  73. end
  74. end
  75. 1 describe '#to_body #to_hash' do
  76. 1 it 'returns a hash representation of the object' do
  77. 1 expect(multi_channel_channel_list_sms_response_object_values.to_body).to eq({
  78. from: '+19195554321',
  79. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  80. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS,
  81. content: { text: 'Hello world' },
  82. owner: '+19195554321'
  83. })
  84. end
  85. end
  86. 1 describe 'custom attribute writers' do
  87. 1 it '#from=' do
  88. 1 expect {
  89. 1 Bandwidth::MultiChannelChannelListSMSResponseObject.new({ from: nil })
  90. }.to raise_error(ArgumentError, 'from cannot be nil')
  91. end
  92. 1 it '#application_id=' do
  93. 1 expect {
  94. 1 Bandwidth::MultiChannelChannelListSMSResponseObject.new({ from: '+15554443333', application_id: nil })
  95. }.to raise_error(ArgumentError, 'application_id cannot be nil')
  96. end
  97. 1 it '#channel=' do
  98. 1 expect {
  99. 1 Bandwidth::MultiChannelChannelListSMSResponseObject.new({ from: '+15554443333', application_id: 'a', channel: nil })
  100. }.to raise_error(ArgumentError, 'channel cannot be nil')
  101. end
  102. 1 it '#content=' do
  103. 1 expect {
  104. 1 Bandwidth::MultiChannelChannelListSMSResponseObject.new({ from: '+15554443333', application_id: 'a', channel: 'SMS', content: nil })
  105. }.to raise_error(ArgumentError, 'content cannot be nil')
  106. end
  107. 1 it '#owner=' do
  108. 1 expect {
  109. 1 Bandwidth::MultiChannelChannelListSMSResponseObject.new({ from: '+15554443333', application_id: 'a', channel: 'SMS', content: 'c', owner: nil })
  110. }.to raise_error(ArgumentError, 'owner cannot be nil')
  111. end
  112. end
  113. end

spec/unit/models/multi_channel_error_spec.rb

100.0% lines covered

37 relevant lines. 37 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MultiChannelError
  2. 1 describe Bandwidth::MultiChannelError do
  3. 2 let(:multi_channel_error_default) { Bandwidth::MultiChannelError.new }
  4. 4 let(:multi_channel_error_values) { Bandwidth::MultiChannelError.new({
  5. links: [Bandwidth::Link.new({ rel: 'next', href: 'https://example.com/next' })],
  6. data: { someKey: 'someValue' },
  7. errors: [Bandwidth::ErrorObject.new({ type: 'invalid', description: 'Something went wrong', source: { parameter: 'foo' } })]
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::MultiChannelError.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::MultiChannelError.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::MultiChannelError.acceptable_attributes).to eq(Bandwidth::MultiChannelError.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be the set of nullable fields' do
  28. 1 expect(Bandwidth::MultiChannelError.openapi_nullable).to eq(Set.new([:'data']))
  29. end
  30. end
  31. 1 describe '#build_from_hash' do
  32. 1 it 'validates instance of MultiChannelError created by the build_from_hash method' do
  33. 1 multi_channel_error_from_hash = Bandwidth::MultiChannelError.build_from_hash({
  34. links: [{ rel: 'next', href: 'https://example.com/next' }],
  35. data: { someKey: 'someValue' },
  36. errors: [{ type: 'invalid', description: 'Something went wrong', source: { parameter: 'foo' } }]
  37. })
  38. 1 expect(multi_channel_error_from_hash).to be_instance_of(Bandwidth::MultiChannelError)
  39. 1 expect(multi_channel_error_from_hash.links.first).to be_instance_of(Bandwidth::Link)
  40. 1 expect(multi_channel_error_from_hash.links.first.rel).to eq('next')
  41. 1 expect(multi_channel_error_from_hash.links.first.href).to eq('https://example.com/next')
  42. 1 expect(multi_channel_error_from_hash.data).to eq({ someKey: 'someValue' })
  43. 1 expect(multi_channel_error_from_hash.errors.first).to be_instance_of(Bandwidth::ErrorObject)
  44. 1 expect(multi_channel_error_from_hash.errors.first.type).to eq('invalid')
  45. 1 expect(multi_channel_error_from_hash.errors.first.description).to eq('Something went wrong')
  46. end
  47. end
  48. 1 describe '#to_s' do
  49. 1 it 'returns a string representation of the object' do
  50. 1 expect(multi_channel_error_values.to_s).to eq('{:links=>[{:rel=>"next", :href=>"https://example.com/next"}], :data=>{:someKey=>"someValue"}, :errors=>[{:type=>"invalid", :description=>"Something went wrong", :source=>{:parameter=>"foo"}}]}')
  51. end
  52. end
  53. 1 describe '#eq? #==' do
  54. 1 it 'returns true/false when comparing objects' do
  55. 1 expect(multi_channel_error_default.eql?(Bandwidth::MultiChannelError.new)).to be true
  56. 1 expect(multi_channel_error_default.eql?(multi_channel_error_values)).to be false
  57. end
  58. end
  59. 1 describe '#to_body #to_hash' do
  60. 1 it 'returns a hash representation of the object' do
  61. 1 expect(multi_channel_error_values.to_body).to eq({
  62. links: [{ rel: 'next', href: 'https://example.com/next' }],
  63. data: { someKey: 'someValue' },
  64. errors: [{ type: 'invalid', description: 'Something went wrong', source: { parameter: 'foo' } }]
  65. })
  66. end
  67. end
  68. end

spec/unit/models/multi_channel_message_channel_enum_spec.rb

100.0% lines covered

19 relevant lines. 19 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MultiChannelMessageChannelEnum
  2. 1 describe Bandwidth::MultiChannelMessageChannelEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines RBM' do
  5. 1 expect(Bandwidth::MultiChannelMessageChannelEnum::RBM).to eq('RBM')
  6. end
  7. 1 it 'defines SMS' do
  8. 1 expect(Bandwidth::MultiChannelMessageChannelEnum::SMS).to eq('SMS')
  9. end
  10. 1 it 'defines MMS' do
  11. 1 expect(Bandwidth::MultiChannelMessageChannelEnum::MMS).to eq('MMS')
  12. end
  13. end
  14. 1 describe '.all_vars' do
  15. 1 it 'returns every valid enum value' do
  16. 1 expect(Bandwidth::MultiChannelMessageChannelEnum.all_vars).to eq([
  17. 'RBM',
  18. 'SMS',
  19. 'MMS'
  20. ])
  21. end
  22. end
  23. 1 describe '.build_from_hash' do
  24. 1 it 'returns the value when it matches a valid enum value' do
  25. 1 expect(Bandwidth::MultiChannelMessageChannelEnum.build_from_hash('RBM')).to eq('RBM')
  26. 1 expect(Bandwidth::MultiChannelMessageChannelEnum.build_from_hash('SMS')).to eq('SMS')
  27. 1 expect(Bandwidth::MultiChannelMessageChannelEnum.build_from_hash('MMS')).to eq('MMS')
  28. end
  29. 1 it 'raises an error for an invalid enum value' do
  30. 1 expect {
  31. 1 Bandwidth::MultiChannelMessageChannelEnum.build_from_hash('invalid')
  32. }.to raise_error(RuntimeError)
  33. end
  34. end
  35. end

spec/unit/models/multi_channel_message_content_spec.rb

100.0% lines covered

33 relevant lines. 33 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MultiChannelMessageContent
  2. 1 describe Bandwidth::MultiChannelMessageContent do
  3. 2 let(:multi_channel_message_content_default) { Bandwidth::MultiChannelMessageContent.new }
  4. 4 let(:multi_channel_message_content_values) { Bandwidth::MultiChannelMessageContent.new({
  5. text: 'Hello world',
  6. media: Bandwidth::RbmMessageContentFile.new({ file_url: 'https://dev.bandwidth.com/images/bandwidth-logo.png' })
  7. }) }
  8. 1 describe '#initialize' do
  9. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  10. 1 expect {
  11. 1 Bandwidth::MultiChannelMessageContent.new([])
  12. }.to raise_error(ArgumentError)
  13. end
  14. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  15. 1 expect {
  16. 1 Bandwidth::MultiChannelMessageContent.new({ invalid: true })
  17. }.to raise_error(ArgumentError)
  18. end
  19. end
  20. 1 describe '#acceptable_attributes' do
  21. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  22. 1 expect(Bandwidth::MultiChannelMessageContent.acceptable_attributes).to eq(Bandwidth::MultiChannelMessageContent.attribute_map.values)
  23. end
  24. end
  25. 1 describe '#openapi_nullable' do
  26. 1 it 'expects nullable attributes to be an empty set' do
  27. 1 expect(Bandwidth::MultiChannelMessageContent.openapi_nullable).to eq(Set.new([]))
  28. end
  29. end
  30. 1 describe '#build_from_hash' do
  31. 1 it 'validates instance of MultiChannelMessageContent created by the build_from_hash method' do
  32. 1 multi_channel_message_content_from_hash = Bandwidth::MultiChannelMessageContent.build_from_hash({
  33. text: 'Hello world',
  34. media: { fileUrl: 'https://dev.bandwidth.com/images/bandwidth-logo.png' }
  35. })
  36. 1 expect(multi_channel_message_content_from_hash).to be_instance_of(Bandwidth::MultiChannelMessageContent)
  37. 1 expect(multi_channel_message_content_from_hash.text).to eq('Hello world')
  38. 1 expect(multi_channel_message_content_from_hash.media).to be_instance_of(Bandwidth::RbmMessageContentFile)
  39. 1 expect(multi_channel_message_content_from_hash.media.file_url).to eq('https://dev.bandwidth.com/images/bandwidth-logo.png')
  40. end
  41. end
  42. 1 describe '#to_s' do
  43. 1 it 'returns a string representation of the object' do
  44. 1 expect(multi_channel_message_content_values.to_s).to eq('{:text=>"Hello world", :media=>{:fileUrl=>"https://dev.bandwidth.com/images/bandwidth-logo.png"}}')
  45. end
  46. end
  47. 1 describe '#eq? #==' do
  48. 1 it 'returns true/false when comparing objects' do
  49. 1 expect(multi_channel_message_content_default.eql?(Bandwidth::MultiChannelMessageContent.new)).to be true
  50. 1 expect(multi_channel_message_content_default.eql?(multi_channel_message_content_values)).to be false
  51. end
  52. end
  53. 1 describe '#to_body #to_hash' do
  54. 1 it 'returns a hash representation of the object' do
  55. 1 expect(multi_channel_message_content_values.to_body).to eq({
  56. text: 'Hello world',
  57. media: { fileUrl: 'https://dev.bandwidth.com/images/bandwidth-logo.png' }
  58. })
  59. end
  60. end
  61. end

spec/unit/models/multi_channel_message_request_spec.rb

100.0% lines covered

48 relevant lines. 48 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MultiChannelMessageRequest
  2. 1 describe Bandwidth::MultiChannelMessageRequest do
  3. 5 let(:sms_channel_object) { Bandwidth::MultiChannelChannelListSMSObject.new({
  4. from: '+19195554321',
  5. application_id: '93de2206-9669-4e07-948d-329f4b722ee2',
  6. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS,
  7. content: Bandwidth::SmsMessageContent.new({ text: 'Hello world' })
  8. }) }
  9. 2 let(:multi_channel_message_request_default) { Bandwidth::MultiChannelMessageRequest.new({
  10. to: '+15554443333',
  11. channel_list: [sms_channel_object]
  12. }) }
  13. 5 let(:multi_channel_message_request_values) { Bandwidth::MultiChannelMessageRequest.new({
  14. to: '+19195551234',
  15. channel_list: [sms_channel_object],
  16. tag: 'custom tag',
  17. priority: Bandwidth::PriorityEnum::DEFAULT,
  18. expiration: '2024-06-16T13:45:07.160Z'
  19. }) }
  20. 1 describe '#initialize' do
  21. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  22. 1 expect {
  23. 1 Bandwidth::MultiChannelMessageRequest.new([])
  24. }.to raise_error(ArgumentError)
  25. end
  26. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  27. 1 expect {
  28. 1 Bandwidth::MultiChannelMessageRequest.new({ invalid: true })
  29. }.to raise_error(ArgumentError)
  30. end
  31. end
  32. 1 describe '#acceptable_attributes' do
  33. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  34. 1 expect(Bandwidth::MultiChannelMessageRequest.acceptable_attributes).to eq(Bandwidth::MultiChannelMessageRequest.attribute_map.values)
  35. end
  36. end
  37. 1 describe '#openapi_nullable' do
  38. 1 it 'expects nullable attributes to be an empty set' do
  39. 1 expect(Bandwidth::MultiChannelMessageRequest.openapi_nullable).to eq(Set.new([]))
  40. end
  41. end
  42. 1 describe '#build_from_hash' do
  43. 1 it 'validates instance of MultiChannelMessageRequest created by the build_from_hash method' do
  44. 1 multi_channel_message_request_from_hash = Bandwidth::MultiChannelMessageRequest.build_from_hash({
  45. to: '+19195551234',
  46. channelList: [{
  47. from: '+19195554321',
  48. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  49. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS,
  50. content: { text: 'Hello world' }
  51. }],
  52. tag: 'custom tag',
  53. priority: Bandwidth::PriorityEnum::DEFAULT,
  54. expiration: '2024-06-16T13:45:07.160Z'
  55. })
  56. 1 expect(multi_channel_message_request_from_hash).to be_instance_of(Bandwidth::MultiChannelMessageRequest)
  57. 1 expect(multi_channel_message_request_from_hash.to).to eq('+19195551234')
  58. 1 expect(multi_channel_message_request_from_hash.channel_list.first).to be_instance_of(Bandwidth::MultiChannelChannelListSMSObject)
  59. 1 expect(multi_channel_message_request_from_hash.tag).to eq('custom tag')
  60. 1 expect(multi_channel_message_request_from_hash.priority).to eq(Bandwidth::PriorityEnum::DEFAULT)
  61. 1 expect(multi_channel_message_request_from_hash.expiration).to eq(Time.parse('2024-06-16T13:45:07.160Z'))
  62. end
  63. end
  64. 1 describe '#to_s' do
  65. 1 it 'returns a string representation of the object' do
  66. 1 expect(multi_channel_message_request_values.to_s).to eq('{:to=>"+19195551234", :channelList=>[{:from=>"+19195554321", :applicationId=>"93de2206-9669-4e07-948d-329f4b722ee2", :channel=>"SMS", :content=>{:text=>"Hello world"}}], :tag=>"custom tag", :priority=>"default", :expiration=>"2024-06-16T13:45:07.160Z"}')
  67. end
  68. end
  69. 1 describe '#eq? #==' do
  70. 1 it 'returns true/false when comparing objects' do
  71. 1 multi_channel_message_request_equal = Bandwidth::MultiChannelMessageRequest.new({
  72. to: '+15554443333',
  73. channel_list: [sms_channel_object]
  74. })
  75. 1 expect(multi_channel_message_request_default.eql?(multi_channel_message_request_equal)).to be true
  76. 1 expect(multi_channel_message_request_default.eql?(multi_channel_message_request_values)).to be false
  77. end
  78. end
  79. 1 describe '#to_body #to_hash' do
  80. 1 it 'returns a hash representation of the object' do
  81. 1 expect(multi_channel_message_request_values.to_body).to eq({
  82. to: '+19195551234',
  83. channelList: [{
  84. from: '+19195554321',
  85. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  86. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS,
  87. content: { text: 'Hello world' }
  88. }],
  89. tag: 'custom tag',
  90. priority: Bandwidth::PriorityEnum::DEFAULT,
  91. expiration: '2024-06-16T13:45:07.160Z'
  92. })
  93. end
  94. end
  95. 1 describe 'custom attribute writers' do
  96. 1 it '#to=' do
  97. 1 expect {
  98. 1 Bandwidth::MultiChannelMessageRequest.new({})
  99. }.to raise_error(ArgumentError, 'to cannot be nil')
  100. end
  101. 1 it '#channel_list=' do
  102. 1 expect {
  103. 1 Bandwidth::MultiChannelMessageRequest.new({ to: '+15554443333' })
  104. }.to raise_error(ArgumentError, 'channel_list cannot be nil')
  105. 1 expect {
  106. 1 multi_channel_message_request_values.channel_list = nil
  107. }.to raise_error(ArgumentError, 'channel_list cannot be nil')
  108. 1 expect {
  109. 1 multi_channel_message_request_values.channel_list = [sms_channel_object] * 5
  110. }.to raise_error(ArgumentError, 'invalid value for "channel_list", number of items must be less than or equal to 4.')
  111. end
  112. end
  113. end

spec/unit/models/multi_channel_message_response_data_spec.rb

100.0% lines covered

62 relevant lines. 62 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::MultiChannelMessageResponseData
  2. 1 describe Bandwidth::MultiChannelMessageResponseData do
  3. 6 let(:sms_channel_response) { Bandwidth::MultiChannelChannelListSMSResponseObject.new({
  4. from: '+19195554321',
  5. application_id: '93de2206-9669-4e07-948d-329f4b722ee2',
  6. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS,
  7. content: Bandwidth::SmsMessageContent.new({ text: 'Hello world' }),
  8. owner: '+19195554321'
  9. }) }
  10. 2 let(:multi_channel_message_response_data_default) { Bandwidth::MultiChannelMessageResponseData.new({
  11. id: 'baseline-id',
  12. time: '2024-01-01T00:00:00Z',
  13. direction: Bandwidth::MessageDirectionEnum::OUT,
  14. to: ['+15554443333'],
  15. channel_list: [sms_channel_response]
  16. }) }
  17. 6 let(:multi_channel_message_response_data_values) { Bandwidth::MultiChannelMessageResponseData.new({
  18. id: '1589228074636lm4k2je7j7jklbn2',
  19. time: '2024-06-16T13:15:07.160Z',
  20. direction: Bandwidth::MessageDirectionEnum::OUT,
  21. to: ['+19195551234'],
  22. channel_list: [sms_channel_response],
  23. tag: 'custom tag',
  24. priority: Bandwidth::PriorityEnum::DEFAULT,
  25. expiration: '2024-06-16T13:45:07.160Z'
  26. }) }
  27. 1 describe '#initialize' do
  28. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  29. 1 expect {
  30. 1 Bandwidth::MultiChannelMessageResponseData.new([])
  31. }.to raise_error(ArgumentError)
  32. end
  33. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  34. 1 expect {
  35. 1 Bandwidth::MultiChannelMessageResponseData.new({ invalid: true })
  36. }.to raise_error(ArgumentError)
  37. end
  38. end
  39. 1 describe '#acceptable_attributes' do
  40. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  41. 1 expect(Bandwidth::MultiChannelMessageResponseData.acceptable_attributes).to eq(Bandwidth::MultiChannelMessageResponseData.attribute_map.values)
  42. end
  43. end
  44. 1 describe '#openapi_nullable' do
  45. 1 it 'expects nullable attributes to be an empty set' do
  46. 1 expect(Bandwidth::MultiChannelMessageResponseData.openapi_nullable).to eq(Set.new([]))
  47. end
  48. end
  49. 1 describe '#build_from_hash' do
  50. 1 it 'validates instance of MultiChannelMessageResponseData created by the build_from_hash method' do
  51. 1 multi_channel_message_response_data_from_hash = Bandwidth::MultiChannelMessageResponseData.build_from_hash({
  52. id: '1589228074636lm4k2je7j7jklbn2',
  53. time: '2024-06-16T13:15:07.160Z',
  54. direction: Bandwidth::MessageDirectionEnum::OUT,
  55. to: ['+19195551234'],
  56. channelList: [{
  57. from: '+19195554321',
  58. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  59. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS,
  60. content: { text: 'Hello world' },
  61. owner: '+19195554321'
  62. }],
  63. tag: 'custom tag',
  64. priority: Bandwidth::PriorityEnum::DEFAULT,
  65. expiration: '2024-06-16T13:45:07.160Z'
  66. })
  67. 1 expect(multi_channel_message_response_data_from_hash).to be_instance_of(Bandwidth::MultiChannelMessageResponseData)
  68. 1 expect(multi_channel_message_response_data_from_hash.id).to eq('1589228074636lm4k2je7j7jklbn2')
  69. 1 expect(multi_channel_message_response_data_from_hash.time).to eq(Time.parse('2024-06-16T13:15:07.160Z'))
  70. 1 expect(multi_channel_message_response_data_from_hash.direction).to eq(Bandwidth::MessageDirectionEnum::OUT)
  71. 1 expect(multi_channel_message_response_data_from_hash.to).to eq(['+19195551234'])
  72. 1 expect(multi_channel_message_response_data_from_hash.channel_list.first).to be_instance_of(Bandwidth::MultiChannelChannelListSMSResponseObject)
  73. 1 expect(multi_channel_message_response_data_from_hash.tag).to eq('custom tag')
  74. 1 expect(multi_channel_message_response_data_from_hash.priority).to eq(Bandwidth::PriorityEnum::DEFAULT)
  75. 1 expect(multi_channel_message_response_data_from_hash.expiration).to eq(Time.parse('2024-06-16T13:45:07.160Z'))
  76. end
  77. end
  78. 1 describe '#to_s' do
  79. 1 it 'returns a string representation of the object' do
  80. 1 expect(multi_channel_message_response_data_values.to_s).to eq('{:id=>"1589228074636lm4k2je7j7jklbn2", :time=>"2024-06-16T13:15:07.160Z", :direction=>"out", :to=>["+19195551234"], :channelList=>[{:from=>"+19195554321", :applicationId=>"93de2206-9669-4e07-948d-329f4b722ee2", :channel=>"SMS", :content=>{:text=>"Hello world"}, :owner=>"+19195554321"}], :tag=>"custom tag", :priority=>"default", :expiration=>"2024-06-16T13:45:07.160Z"}')
  81. end
  82. end
  83. 1 describe '#eq? #==' do
  84. 1 it 'returns true/false when comparing objects' do
  85. 1 multi_channel_message_response_data_equal = Bandwidth::MultiChannelMessageResponseData.new({
  86. id: 'baseline-id',
  87. time: '2024-01-01T00:00:00Z',
  88. direction: Bandwidth::MessageDirectionEnum::OUT,
  89. to: ['+15554443333'],
  90. channel_list: [sms_channel_response]
  91. })
  92. 1 expect(multi_channel_message_response_data_default.eql?(multi_channel_message_response_data_equal)).to be true
  93. 1 expect(multi_channel_message_response_data_default.eql?(multi_channel_message_response_data_values)).to be false
  94. end
  95. end
  96. 1 describe '#to_body #to_hash' do
  97. 1 it 'returns a hash representation of the object' do
  98. 1 expect(multi_channel_message_response_data_values.to_body).to eq({
  99. id: '1589228074636lm4k2je7j7jklbn2',
  100. time: '2024-06-16T13:15:07.160Z',
  101. direction: Bandwidth::MessageDirectionEnum::OUT,
  102. to: ['+19195551234'],
  103. channelList: [{
  104. from: '+19195554321',
  105. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  106. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS,
  107. content: { text: 'Hello world' },
  108. owner: '+19195554321'
  109. }],
  110. tag: 'custom tag',
  111. priority: Bandwidth::PriorityEnum::DEFAULT,
  112. expiration: '2024-06-16T13:45:07.160Z'
  113. })
  114. end
  115. end
  116. 1 describe 'custom attribute writers' do
  117. 1 it '#id=' do
  118. 1 expect {
  119. 1 Bandwidth::MultiChannelMessageResponseData.new({ id: nil })
  120. }.to raise_error(ArgumentError, 'id cannot be nil')
  121. end
  122. 1 it '#time=' do
  123. 1 expect {
  124. 1 Bandwidth::MultiChannelMessageResponseData.new({ id: 'a', time: nil })
  125. }.to raise_error(ArgumentError, 'time cannot be nil')
  126. end
  127. 1 it '#direction=' do
  128. 1 expect {
  129. 1 Bandwidth::MultiChannelMessageResponseData.new({ id: 'a', time: 't', direction: nil })
  130. }.to raise_error(ArgumentError, 'direction cannot be nil')
  131. end
  132. 1 it '#to=' do
  133. 1 expect {
  134. 1 Bandwidth::MultiChannelMessageResponseData.new({ id: 'a', time: 't', direction: 'out' })
  135. }.to raise_error(ArgumentError, 'to cannot be nil')
  136. 1 expect {
  137. 1 multi_channel_message_response_data_values.to = nil
  138. }.to raise_error(ArgumentError, 'to cannot be nil')
  139. end
  140. 1 it '#channel_list=' do
  141. 1 expect {
  142. 1 Bandwidth::MultiChannelMessageResponseData.new({ id: 'a', time: 't', direction: 'out', to: ['x'] })
  143. }.to raise_error(ArgumentError, 'channel_list cannot be nil')
  144. 1 expect {
  145. 1 multi_channel_message_response_data_values.channel_list = nil
  146. }.to raise_error(ArgumentError, 'channel_list cannot be nil')
  147. 1 expect {
  148. 1 multi_channel_message_response_data_values.channel_list = [sms_channel_response] * 5
  149. }.to raise_error(ArgumentError, 'invalid value for "channel_list", number of items must be less than or equal to 4.')
  150. end
  151. end
  152. end

spec/unit/models/opt_in_workflow_spec.rb

100.0% lines covered

50 relevant lines. 50 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::OptInWorkflow
  2. 1 describe Bandwidth::OptInWorkflow do
  3. 2 let(:opt_in_workflow_default) { Bandwidth::OptInWorkflow.new({
  4. description: 'baseline description',
  5. image_urls: ['https://example.com/baseline.png']
  6. }) }
  7. 6 let(:opt_in_workflow_values) { Bandwidth::OptInWorkflow.new({
  8. description: 'A description of the opt in workflow',
  9. image_urls: ['https://example.com/image1.png', 'https://example.com/image2.png'],
  10. confirmation_response: 'Thanks for opting in!'
  11. }) }
  12. 1 describe '#initialize' do
  13. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  14. 1 expect {
  15. 1 Bandwidth::OptInWorkflow.new([])
  16. }.to raise_error(ArgumentError)
  17. end
  18. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  19. 1 expect {
  20. 1 Bandwidth::OptInWorkflow.new({ invalid: true })
  21. }.to raise_error(ArgumentError)
  22. end
  23. end
  24. 1 describe '#acceptable_attributes' do
  25. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  26. 1 expect(Bandwidth::OptInWorkflow.acceptable_attributes).to eq(Bandwidth::OptInWorkflow.attribute_map.values)
  27. end
  28. end
  29. 1 describe '#openapi_nullable' do
  30. 1 it 'expects nullable attributes to be the set of nullable fields' do
  31. 1 expect(Bandwidth::OptInWorkflow.openapi_nullable).to eq(Set.new([:'confirmation_response']))
  32. end
  33. end
  34. 1 describe '#build_from_hash' do
  35. 1 it 'validates instance of OptInWorkflow created by the build_from_hash method' do
  36. 1 opt_in_workflow_from_hash = Bandwidth::OptInWorkflow.build_from_hash({
  37. description: 'A description of the opt in workflow',
  38. imageUrls: ['https://example.com/image1.png', 'https://example.com/image2.png'],
  39. confirmationResponse: 'Thanks for opting in!'
  40. })
  41. 1 expect(opt_in_workflow_from_hash).to be_instance_of(Bandwidth::OptInWorkflow)
  42. 1 expect(opt_in_workflow_from_hash.description).to eq('A description of the opt in workflow')
  43. 1 expect(opt_in_workflow_from_hash.image_urls).to eq(['https://example.com/image1.png', 'https://example.com/image2.png'])
  44. 1 expect(opt_in_workflow_from_hash.confirmation_response).to eq('Thanks for opting in!')
  45. end
  46. end
  47. 1 describe '#to_s' do
  48. 1 it 'returns a string representation of the object' do
  49. 1 expect(opt_in_workflow_values.to_s).to eq('{:description=>"A description of the opt in workflow", :imageUrls=>["https://example.com/image1.png", "https://example.com/image2.png"], :confirmationResponse=>"Thanks for opting in!"}')
  50. end
  51. end
  52. 1 describe '#eq? #==' do
  53. 1 it 'returns true/false when comparing objects' do
  54. 1 opt_in_workflow_equal = Bandwidth::OptInWorkflow.new({
  55. description: 'baseline description',
  56. image_urls: ['https://example.com/baseline.png']
  57. })
  58. 1 expect(opt_in_workflow_default.eql?(opt_in_workflow_equal)).to be true
  59. 1 expect(opt_in_workflow_default.eql?(opt_in_workflow_values)).to be false
  60. end
  61. end
  62. 1 describe '#to_body #to_hash' do
  63. 1 it 'returns a hash representation of the object' do
  64. 1 expect(opt_in_workflow_values.to_body).to eq({
  65. description: 'A description of the opt in workflow',
  66. imageUrls: ['https://example.com/image1.png', 'https://example.com/image2.png'],
  67. confirmationResponse: 'Thanks for opting in!'
  68. })
  69. end
  70. end
  71. 1 describe 'custom attribute writers' do
  72. 1 it '#description=' do
  73. 1 expect {
  74. 1 Bandwidth::OptInWorkflow.new({ description: nil })
  75. }.to raise_error(ArgumentError, 'description cannot be nil')
  76. 1 expect {
  77. 1 Bandwidth::OptInWorkflow.new({ description: 'a' * 501 })
  78. }.to raise_error(ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 500.')
  79. 1 expect {
  80. 1 Bandwidth::OptInWorkflow.new({ description: '' })
  81. }.to raise_error(ArgumentError, 'invalid value for "description", the character length must be greater than or equal to 1.')
  82. end
  83. 1 it '#image_urls=' do
  84. 1 expect {
  85. 1 Bandwidth::OptInWorkflow.new({ description: 'a' })
  86. }.to raise_error(ArgumentError, 'image_urls cannot be nil')
  87. 1 expect {
  88. 1 opt_in_workflow_values.image_urls = nil
  89. }.to raise_error(ArgumentError, 'image_urls cannot be nil')
  90. end
  91. 1 it '#confirmation_response=' do
  92. 1 expect {
  93. 1 opt_in_workflow_values.confirmation_response = 'a' * 501
  94. }.to raise_error(ArgumentError, 'invalid value for "confirmation_response", the character length must be smaller than or equal to 500.')
  95. end
  96. end
  97. end

spec/unit/models/page_info_spec.rb

100.0% lines covered

34 relevant lines. 34 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::PageInfo
  2. 1 describe Bandwidth::PageInfo do
  3. 2 let(:page_info_default) { Bandwidth::PageInfo.new }
  4. 4 let(:page_info_values) { Bandwidth::PageInfo.new({
  5. prev_page: 'https://example.com/prev',
  6. next_page: 'https://example.com/next',
  7. prev_page_token: 'prev-token',
  8. next_page_token: 'next-token'
  9. }) }
  10. 1 describe '#initialize' do
  11. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  12. 1 expect {
  13. 1 Bandwidth::PageInfo.new([])
  14. }.to raise_error(ArgumentError)
  15. end
  16. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  17. 1 expect {
  18. 1 Bandwidth::PageInfo.new({ invalid: true })
  19. }.to raise_error(ArgumentError)
  20. end
  21. end
  22. 1 describe '#acceptable_attributes' do
  23. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  24. 1 expect(Bandwidth::PageInfo.acceptable_attributes).to eq(Bandwidth::PageInfo.attribute_map.values)
  25. end
  26. end
  27. 1 describe '#openapi_nullable' do
  28. 1 it 'expects nullable attributes to be an empty set' do
  29. 1 expect(Bandwidth::PageInfo.openapi_nullable).to eq(Set.new([]))
  30. end
  31. end
  32. 1 describe '#build_from_hash' do
  33. 1 it 'validates instance of PageInfo created by the build_from_hash method' do
  34. 1 page_info_from_hash = Bandwidth::PageInfo.build_from_hash({
  35. prevPage: 'https://example.com/prev',
  36. nextPage: 'https://example.com/next',
  37. prevPageToken: 'prev-token',
  38. nextPageToken: 'next-token'
  39. })
  40. 1 expect(page_info_from_hash).to be_instance_of(Bandwidth::PageInfo)
  41. 1 expect(page_info_from_hash.prev_page).to eq('https://example.com/prev')
  42. 1 expect(page_info_from_hash.next_page).to eq('https://example.com/next')
  43. 1 expect(page_info_from_hash.prev_page_token).to eq('prev-token')
  44. 1 expect(page_info_from_hash.next_page_token).to eq('next-token')
  45. end
  46. end
  47. 1 describe '#to_s' do
  48. 1 it 'returns a string representation of the object' do
  49. 1 expect(page_info_values.to_s).to eq('{:prevPage=>"https://example.com/prev", :nextPage=>"https://example.com/next", :prevPageToken=>"prev-token", :nextPageToken=>"next-token"}')
  50. end
  51. end
  52. 1 describe '#eq? #==' do
  53. 1 it 'returns true/false when comparing objects' do
  54. 1 expect(page_info_default.eql?(Bandwidth::PageInfo.new)).to be true
  55. 1 expect(page_info_default.eql?(page_info_values)).to be false
  56. end
  57. end
  58. 1 describe '#to_body #to_hash' do
  59. 1 it 'returns a hash representation of the object' do
  60. 1 expect(page_info_values.to_body).to eq({
  61. prevPage: 'https://example.com/prev',
  62. nextPage: 'https://example.com/next',
  63. prevPageToken: 'prev-token',
  64. nextPageToken: 'next-token'
  65. })
  66. end
  67. end
  68. end

spec/unit/models/page_spec.rb

100.0% lines covered

56 relevant lines. 56 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Page
  2. 1 describe Bandwidth::Page do
  3. 2 let(:page_default) { Bandwidth::Page.new({
  4. page_size: 25
  5. }) }
  6. 7 let(:page_values) { Bandwidth::Page.new({
  7. page_size: 100,
  8. total_elements: 250,
  9. total_pages: 3,
  10. page_number: 1
  11. }) }
  12. 1 describe '#initialize' do
  13. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  14. 1 expect {
  15. 1 Bandwidth::Page.new([])
  16. }.to raise_error(ArgumentError)
  17. end
  18. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  19. 1 expect {
  20. 1 Bandwidth::Page.new({ invalid: true })
  21. }.to raise_error(ArgumentError)
  22. end
  23. end
  24. 1 describe '#acceptable_attributes' do
  25. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  26. 1 expect(Bandwidth::Page.acceptable_attributes).to eq(Bandwidth::Page.attribute_map.values)
  27. end
  28. end
  29. 1 describe '#openapi_nullable' do
  30. 1 it 'expects nullable attributes to be an empty set' do
  31. 1 expect(Bandwidth::Page.openapi_nullable).to eq(Set.new([]))
  32. end
  33. end
  34. 1 describe '#build_from_hash' do
  35. 1 it 'validates instance of Page created by the build_from_hash method' do
  36. 1 page_from_hash = Bandwidth::Page.build_from_hash({
  37. pageSize: 100,
  38. totalElements: 250,
  39. totalPages: 3,
  40. pageNumber: 1
  41. })
  42. 1 expect(page_from_hash).to be_instance_of(Bandwidth::Page)
  43. 1 expect(page_from_hash.page_size).to eq(100)
  44. 1 expect(page_from_hash.total_elements).to eq(250)
  45. 1 expect(page_from_hash.total_pages).to eq(3)
  46. 1 expect(page_from_hash.page_number).to eq(1)
  47. end
  48. end
  49. 1 describe '#to_s' do
  50. 1 it 'returns a string representation of the object' do
  51. 1 expect(page_values.to_s).to eq('{:pageSize=>100, :totalElements=>250, :totalPages=>3, :pageNumber=>1}')
  52. end
  53. end
  54. 1 describe '#eq? #==' do
  55. 1 it 'returns true/false when comparing objects' do
  56. 1 page_equal = Bandwidth::Page.new({ page_size: 25 })
  57. 1 expect(page_default.eql?(page_equal)).to be true
  58. 1 expect(page_default.eql?(page_values)).to be false
  59. end
  60. end
  61. 1 describe '#to_body #to_hash' do
  62. 1 it 'returns a hash representation of the object' do
  63. 1 expect(page_values.to_body).to eq({
  64. pageSize: 100,
  65. totalElements: 250,
  66. totalPages: 3,
  67. pageNumber: 1
  68. })
  69. end
  70. end
  71. 1 describe 'custom attribute writers' do
  72. 1 it '#page_size=' do
  73. 1 expect {
  74. 1 Bandwidth::Page.new({ page_size: nil })
  75. }.to raise_error(ArgumentError, 'page_size cannot be nil')
  76. 1 expect {
  77. 1 Bandwidth::Page.new({ page_size: -1 })
  78. }.to raise_error(ArgumentError, 'invalid value for "page_size", must be greater than or equal to 0.')
  79. end
  80. 1 it '#total_elements=' do
  81. 1 expect {
  82. 1 page_values.total_elements = nil
  83. }.to raise_error(ArgumentError, 'total_elements cannot be nil')
  84. 1 expect {
  85. 1 page_values.total_elements = -1
  86. }.to raise_error(ArgumentError, 'invalid value for "total_elements", must be greater than or equal to 0.')
  87. end
  88. 1 it '#total_pages=' do
  89. 1 expect {
  90. 1 page_values.total_pages = nil
  91. }.to raise_error(ArgumentError, 'total_pages cannot be nil')
  92. 1 expect {
  93. 1 page_values.total_pages = -1
  94. }.to raise_error(ArgumentError, 'invalid value for "total_pages", must be greater than or equal to 0.')
  95. end
  96. 1 it '#page_number=' do
  97. 1 expect {
  98. 1 page_values.page_number = nil
  99. }.to raise_error(ArgumentError, 'page_number cannot be nil')
  100. 1 expect {
  101. 1 page_values.page_number = -1
  102. }.to raise_error(ArgumentError, 'invalid value for "page_number", must be greater than or equal to 0.')
  103. end
  104. end
  105. end

spec/unit/models/priority_enum_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::PriorityEnum
  2. 1 describe Bandwidth::PriorityEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines DEFAULT' do
  5. 1 expect(Bandwidth::PriorityEnum::DEFAULT).to eq('default')
  6. end
  7. 1 it 'defines HIGH' do
  8. 1 expect(Bandwidth::PriorityEnum::HIGH).to eq('high')
  9. end
  10. end
  11. 1 describe '.all_vars' do
  12. 1 it 'returns every valid enum value' do
  13. 1 expect(Bandwidth::PriorityEnum.all_vars).to eq([
  14. 'default',
  15. 'high'
  16. ])
  17. end
  18. end
  19. 1 describe '.build_from_hash' do
  20. 1 it 'returns the value when it matches a valid enum value' do
  21. 1 expect(Bandwidth::PriorityEnum.build_from_hash('default')).to eq('default')
  22. 1 expect(Bandwidth::PriorityEnum.build_from_hash('high')).to eq('high')
  23. end
  24. 1 it 'raises an error for an invalid enum value' do
  25. 1 expect {
  26. 1 Bandwidth::PriorityEnum.build_from_hash('invalid')
  27. }.to raise_error(RuntimeError)
  28. end
  29. end
  30. end

spec/unit/models/product_type_enum_spec.rb

100.0% lines covered

37 relevant lines. 37 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::ProductTypeEnum
  2. 1 describe Bandwidth::ProductTypeEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines LOCAL_A2_P' do
  5. 1 expect(Bandwidth::ProductTypeEnum::LOCAL_A2_P).to eq('LOCAL_A2P')
  6. end
  7. 1 it 'defines P2_P' do
  8. 1 expect(Bandwidth::ProductTypeEnum::P2_P).to eq('P2P')
  9. end
  10. 1 it 'defines SHORT_CODE_REACH' do
  11. 1 expect(Bandwidth::ProductTypeEnum::SHORT_CODE_REACH).to eq('SHORT_CODE_REACH')
  12. end
  13. 1 it 'defines TOLL_FREE' do
  14. 1 expect(Bandwidth::ProductTypeEnum::TOLL_FREE).to eq('TOLL_FREE')
  15. end
  16. 1 it 'defines HOSTED_SHORT_CODE' do
  17. 1 expect(Bandwidth::ProductTypeEnum::HOSTED_SHORT_CODE).to eq('HOSTED_SHORT_CODE')
  18. end
  19. 1 it 'defines ALPHA_NUMERIC' do
  20. 1 expect(Bandwidth::ProductTypeEnum::ALPHA_NUMERIC).to eq('ALPHA_NUMERIC')
  21. end
  22. 1 it 'defines RBM_MEDIA' do
  23. 1 expect(Bandwidth::ProductTypeEnum::RBM_MEDIA).to eq('RBM_MEDIA')
  24. end
  25. 1 it 'defines RBM_RICH' do
  26. 1 expect(Bandwidth::ProductTypeEnum::RBM_RICH).to eq('RBM_RICH')
  27. end
  28. 1 it 'defines RBM_CONVERSATIONAL' do
  29. 1 expect(Bandwidth::ProductTypeEnum::RBM_CONVERSATIONAL).to eq('RBM_CONVERSATIONAL')
  30. end
  31. end
  32. 1 describe '.all_vars' do
  33. 1 it 'returns every valid enum value' do
  34. 1 expect(Bandwidth::ProductTypeEnum.all_vars).to eq([
  35. 'LOCAL_A2P',
  36. 'P2P',
  37. 'SHORT_CODE_REACH',
  38. 'TOLL_FREE',
  39. 'HOSTED_SHORT_CODE',
  40. 'ALPHA_NUMERIC',
  41. 'RBM_MEDIA',
  42. 'RBM_RICH',
  43. 'RBM_CONVERSATIONAL'
  44. ])
  45. end
  46. end
  47. 1 describe '.build_from_hash' do
  48. 1 it 'returns the value when it matches a valid enum value' do
  49. 1 expect(Bandwidth::ProductTypeEnum.build_from_hash('LOCAL_A2P')).to eq('LOCAL_A2P')
  50. 1 expect(Bandwidth::ProductTypeEnum.build_from_hash('P2P')).to eq('P2P')
  51. 1 expect(Bandwidth::ProductTypeEnum.build_from_hash('SHORT_CODE_REACH')).to eq('SHORT_CODE_REACH')
  52. 1 expect(Bandwidth::ProductTypeEnum.build_from_hash('TOLL_FREE')).to eq('TOLL_FREE')
  53. 1 expect(Bandwidth::ProductTypeEnum.build_from_hash('HOSTED_SHORT_CODE')).to eq('HOSTED_SHORT_CODE')
  54. 1 expect(Bandwidth::ProductTypeEnum.build_from_hash('ALPHA_NUMERIC')).to eq('ALPHA_NUMERIC')
  55. 1 expect(Bandwidth::ProductTypeEnum.build_from_hash('RBM_MEDIA')).to eq('RBM_MEDIA')
  56. 1 expect(Bandwidth::ProductTypeEnum.build_from_hash('RBM_RICH')).to eq('RBM_RICH')
  57. 1 expect(Bandwidth::ProductTypeEnum.build_from_hash('RBM_CONVERSATIONAL')).to eq('RBM_CONVERSATIONAL')
  58. end
  59. 1 it 'raises an error for an invalid enum value' do
  60. 1 expect {
  61. 1 Bandwidth::ProductTypeEnum.build_from_hash('invalid')
  62. }.to raise_error(RuntimeError)
  63. end
  64. end
  65. end

spec/unit/models/rbm_action_base_spec.rb

100.0% lines covered

48 relevant lines. 48 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RbmActionBase
  2. 1 describe Bandwidth::RbmActionBase do
  3. 2 let(:rbm_action_base_default) { Bandwidth::RbmActionBase.new({
  4. type: Bandwidth::RbmActionTypeEnum::REPLY,
  5. text: 'baseline',
  6. postback_data: 'baseline_postback'
  7. }) }
  8. 4 let(:rbm_action_base_values) { Bandwidth::RbmActionBase.new({
  9. type: Bandwidth::RbmActionTypeEnum::REPLY,
  10. text: 'Yes',
  11. postback_data: 'reply_yes'
  12. }) }
  13. 1 describe '#initialize' do
  14. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  15. 1 expect {
  16. 1 Bandwidth::RbmActionBase.new([])
  17. }.to raise_error(ArgumentError)
  18. end
  19. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  20. 1 expect {
  21. 1 Bandwidth::RbmActionBase.new({ invalid: true })
  22. }.to raise_error(ArgumentError)
  23. end
  24. end
  25. 1 describe '#acceptable_attributes' do
  26. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  27. 1 expect(Bandwidth::RbmActionBase.acceptable_attributes).to eq(Bandwidth::RbmActionBase.attribute_map.values)
  28. end
  29. end
  30. 1 describe '#openapi_nullable' do
  31. 1 it 'expects nullable attributes to be an empty set' do
  32. 1 expect(Bandwidth::RbmActionBase.openapi_nullable).to eq(Set.new([]))
  33. end
  34. end
  35. 1 describe '#build_from_hash' do
  36. 1 it 'validates instance of RbmActionBase created by the build_from_hash method' do
  37. 1 rbm_action_base_from_hash = Bandwidth::RbmActionBase.build_from_hash({
  38. type: Bandwidth::RbmActionTypeEnum::REPLY,
  39. text: 'Yes',
  40. postbackData: 'reply_yes'
  41. })
  42. 1 expect(rbm_action_base_from_hash).to be_instance_of(Bandwidth::RbmActionBase)
  43. 1 expect(rbm_action_base_from_hash.type).to eq(Bandwidth::RbmActionTypeEnum::REPLY)
  44. 1 expect(rbm_action_base_from_hash.text).to eq('Yes')
  45. 1 expect(rbm_action_base_from_hash.postback_data).to eq('reply_yes')
  46. end
  47. end
  48. 1 describe '#to_s' do
  49. 1 it 'returns a string representation of the object' do
  50. 1 expect(rbm_action_base_values.to_s).to eq('{:type=>"REPLY", :text=>"Yes", :postbackData=>"reply_yes"}')
  51. end
  52. end
  53. 1 describe '#eq? #==' do
  54. 1 it 'returns true/false when comparing objects' do
  55. 1 rbm_action_base_equal = Bandwidth::RbmActionBase.new({
  56. type: Bandwidth::RbmActionTypeEnum::REPLY,
  57. text: 'baseline',
  58. postback_data: 'baseline_postback'
  59. })
  60. 1 expect(rbm_action_base_default.eql?(rbm_action_base_equal)).to be true
  61. 1 expect(rbm_action_base_default.eql?(rbm_action_base_values)).to be false
  62. end
  63. end
  64. 1 describe '#to_body #to_hash' do
  65. 1 it 'returns a hash representation of the object' do
  66. 1 expect(rbm_action_base_values.to_body).to eq({
  67. type: Bandwidth::RbmActionTypeEnum::REPLY,
  68. text: 'Yes',
  69. postbackData: 'reply_yes'
  70. })
  71. end
  72. end
  73. 1 describe 'custom attribute writers' do
  74. 1 it '#type=' do
  75. 1 expect {
  76. 1 Bandwidth::RbmActionBase.new({ type: nil })
  77. }.to raise_error(ArgumentError, 'type cannot be nil')
  78. end
  79. 1 it '#text=' do
  80. 1 expect {
  81. 1 Bandwidth::RbmActionBase.new({ type: 'REPLY', text: nil })
  82. }.to raise_error(ArgumentError, 'text cannot be nil')
  83. 1 expect {
  84. 1 Bandwidth::RbmActionBase.new({ type: 'REPLY', text: 'a' * 26 })
  85. }.to raise_error(ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 25.')
  86. end
  87. 1 it '#postback_data=' do
  88. 1 expect {
  89. 1 Bandwidth::RbmActionBase.new({ type: 'REPLY', text: 'a', postback_data: nil })
  90. }.to raise_error(ArgumentError, 'postback_data cannot be nil')
  91. 1 expect {
  92. 1 Bandwidth::RbmActionBase.new({ type: 'REPLY', text: 'a', postback_data: 'a' * 2049 })
  93. }.to raise_error(ArgumentError, 'invalid value for "postback_data", the character length must be smaller than or equal to 2048.')
  94. end
  95. end
  96. end

spec/unit/models/rbm_action_dial_spec.rb

100.0% lines covered

52 relevant lines. 52 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RbmActionDial
  2. 1 describe Bandwidth::RbmActionDial do
  3. 2 let(:rbm_action_dial_default) { Bandwidth::RbmActionDial.new({
  4. type: Bandwidth::RbmActionTypeEnum::DIAL_PHONE,
  5. text: 'baseline',
  6. postback_data: 'baseline_postback',
  7. phone_number: '+15554443333'
  8. }) }
  9. 4 let(:rbm_action_dial_values) { Bandwidth::RbmActionDial.new({
  10. type: Bandwidth::RbmActionTypeEnum::DIAL_PHONE,
  11. text: 'Call us',
  12. postback_data: 'dial_postback',
  13. phone_number: '+19195554321'
  14. }) }
  15. 1 describe '#initialize' do
  16. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  17. 1 expect {
  18. 1 Bandwidth::RbmActionDial.new([])
  19. }.to raise_error(ArgumentError)
  20. end
  21. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  22. 1 expect {
  23. 1 Bandwidth::RbmActionDial.new({ invalid: true })
  24. }.to raise_error(ArgumentError)
  25. end
  26. end
  27. 1 describe '#acceptable_attributes' do
  28. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  29. 1 expect(Bandwidth::RbmActionDial.acceptable_attributes).to eq(Bandwidth::RbmActionDial.attribute_map.values)
  30. end
  31. end
  32. 1 describe '#openapi_nullable' do
  33. 1 it 'expects nullable attributes to be an empty set' do
  34. 1 expect(Bandwidth::RbmActionDial.openapi_nullable).to eq(Set.new([]))
  35. end
  36. end
  37. 1 describe '#build_from_hash' do
  38. 1 it 'validates instance of RbmActionDial created by the build_from_hash method' do
  39. 1 rbm_action_dial_from_hash = Bandwidth::RbmActionDial.build_from_hash({
  40. type: Bandwidth::RbmActionTypeEnum::DIAL_PHONE,
  41. text: 'Call us',
  42. postbackData: 'dial_postback',
  43. phoneNumber: '+19195554321'
  44. })
  45. 1 expect(rbm_action_dial_from_hash).to be_instance_of(Bandwidth::RbmActionDial)
  46. 1 expect(rbm_action_dial_from_hash.type).to eq(Bandwidth::RbmActionTypeEnum::DIAL_PHONE)
  47. 1 expect(rbm_action_dial_from_hash.text).to eq('Call us')
  48. 1 expect(rbm_action_dial_from_hash.postback_data).to eq('dial_postback')
  49. 1 expect(rbm_action_dial_from_hash.phone_number).to eq('+19195554321')
  50. end
  51. end
  52. 1 describe '#to_s' do
  53. 1 it 'returns a string representation of the object' do
  54. 1 expect(rbm_action_dial_values.to_s).to eq('{:type=>"DIAL_PHONE", :text=>"Call us", :postbackData=>"dial_postback", :phoneNumber=>"+19195554321"}')
  55. end
  56. end
  57. 1 describe '#eq? #==' do
  58. 1 it 'returns true/false when comparing objects' do
  59. 1 rbm_action_dial_equal = Bandwidth::RbmActionDial.new({
  60. type: Bandwidth::RbmActionTypeEnum::DIAL_PHONE,
  61. text: 'baseline',
  62. postback_data: 'baseline_postback',
  63. phone_number: '+15554443333'
  64. })
  65. 1 expect(rbm_action_dial_default.eql?(rbm_action_dial_equal)).to be true
  66. 1 expect(rbm_action_dial_default.eql?(rbm_action_dial_values)).to be false
  67. end
  68. end
  69. 1 describe '#to_body #to_hash' do
  70. 1 it 'returns a hash representation of the object' do
  71. 1 expect(rbm_action_dial_values.to_body).to eq({
  72. type: Bandwidth::RbmActionTypeEnum::DIAL_PHONE,
  73. text: 'Call us',
  74. postbackData: 'dial_postback',
  75. phoneNumber: '+19195554321'
  76. })
  77. end
  78. end
  79. 1 describe 'custom attribute writers' do
  80. 1 it '#type=' do
  81. 1 expect {
  82. 1 Bandwidth::RbmActionDial.new({ type: nil })
  83. }.to raise_error(ArgumentError, 'type cannot be nil')
  84. end
  85. 1 it '#text=' do
  86. 1 expect {
  87. 1 Bandwidth::RbmActionDial.new({ type: 'DIAL_PHONE', text: nil })
  88. }.to raise_error(ArgumentError, 'text cannot be nil')
  89. 1 expect {
  90. 1 Bandwidth::RbmActionDial.new({ type: 'DIAL_PHONE', text: 'a' * 26 })
  91. }.to raise_error(ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 25.')
  92. end
  93. 1 it '#postback_data=' do
  94. 1 expect {
  95. 1 Bandwidth::RbmActionDial.new({ type: 'DIAL_PHONE', text: 'a', postback_data: nil })
  96. }.to raise_error(ArgumentError, 'postback_data cannot be nil')
  97. 1 expect {
  98. 1 Bandwidth::RbmActionDial.new({ type: 'DIAL_PHONE', text: 'a', postback_data: 'a' * 2049 })
  99. }.to raise_error(ArgumentError, 'invalid value for "postback_data", the character length must be smaller than or equal to 2048.')
  100. end
  101. 1 it '#phone_number=' do
  102. 1 expect {
  103. 1 Bandwidth::RbmActionDial.new({ type: 'DIAL_PHONE', text: 'a', postback_data: 'a', phone_number: nil })
  104. }.to raise_error(ArgumentError, 'phone_number cannot be nil')
  105. end
  106. end
  107. end

spec/unit/models/rbm_action_open_url_spec.rb

100.0% lines covered

56 relevant lines. 56 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RbmActionOpenUrl
  2. 1 describe Bandwidth::RbmActionOpenUrl do
  3. 2 let(:rbm_action_open_url_default) { Bandwidth::RbmActionOpenUrl.new({
  4. type: Bandwidth::RbmActionTypeEnum::OPEN_URL,
  5. text: 'baseline',
  6. postback_data: 'baseline_postback',
  7. url: 'https://example.com/baseline'
  8. }) }
  9. 4 let(:rbm_action_open_url_values) { Bandwidth::RbmActionOpenUrl.new({
  10. type: Bandwidth::RbmActionTypeEnum::OPEN_URL,
  11. text: 'Open URL',
  12. postback_data: 'open_url_postback',
  13. url: 'https://example.com',
  14. application: Bandwidth::RbmOpenUrlEnum::BROWSER,
  15. webview_view_mode: Bandwidth::RbmWebViewEnum::FULL
  16. }) }
  17. 1 describe '#initialize' do
  18. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  19. 1 expect {
  20. 1 Bandwidth::RbmActionOpenUrl.new([])
  21. }.to raise_error(ArgumentError)
  22. end
  23. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  24. 1 expect {
  25. 1 Bandwidth::RbmActionOpenUrl.new({ invalid: true })
  26. }.to raise_error(ArgumentError)
  27. end
  28. end
  29. 1 describe '#acceptable_attributes' do
  30. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  31. 1 expect(Bandwidth::RbmActionOpenUrl.acceptable_attributes).to eq(Bandwidth::RbmActionOpenUrl.attribute_map.values)
  32. end
  33. end
  34. 1 describe '#openapi_nullable' do
  35. 1 it 'expects nullable attributes to be an empty set' do
  36. 1 expect(Bandwidth::RbmActionOpenUrl.openapi_nullable).to eq(Set.new([]))
  37. end
  38. end
  39. 1 describe '#build_from_hash' do
  40. 1 it 'validates instance of RbmActionOpenUrl created by the build_from_hash method' do
  41. 1 rbm_action_open_url_from_hash = Bandwidth::RbmActionOpenUrl.build_from_hash({
  42. type: Bandwidth::RbmActionTypeEnum::OPEN_URL,
  43. text: 'Open URL',
  44. postbackData: 'open_url_postback',
  45. url: 'https://example.com',
  46. application: Bandwidth::RbmOpenUrlEnum::BROWSER,
  47. webviewViewMode: Bandwidth::RbmWebViewEnum::FULL
  48. })
  49. 1 expect(rbm_action_open_url_from_hash).to be_instance_of(Bandwidth::RbmActionOpenUrl)
  50. 1 expect(rbm_action_open_url_from_hash.type).to eq(Bandwidth::RbmActionTypeEnum::OPEN_URL)
  51. 1 expect(rbm_action_open_url_from_hash.text).to eq('Open URL')
  52. 1 expect(rbm_action_open_url_from_hash.postback_data).to eq('open_url_postback')
  53. 1 expect(rbm_action_open_url_from_hash.url).to eq('https://example.com')
  54. 1 expect(rbm_action_open_url_from_hash.application).to eq(Bandwidth::RbmOpenUrlEnum::BROWSER)
  55. 1 expect(rbm_action_open_url_from_hash.webview_view_mode).to eq(Bandwidth::RbmWebViewEnum::FULL)
  56. end
  57. end
  58. 1 describe '#to_s' do
  59. 1 it 'returns a string representation of the object' do
  60. 1 expect(rbm_action_open_url_values.to_s).to eq('{:type=>"OPEN_URL", :text=>"Open URL", :postbackData=>"open_url_postback", :url=>"https://example.com", :application=>"BROWSER", :webviewViewMode=>"FULL"}')
  61. end
  62. end
  63. 1 describe '#eq? #==' do
  64. 1 it 'returns true/false when comparing objects' do
  65. 1 rbm_action_open_url_equal = Bandwidth::RbmActionOpenUrl.new({
  66. type: Bandwidth::RbmActionTypeEnum::OPEN_URL,
  67. text: 'baseline',
  68. postback_data: 'baseline_postback',
  69. url: 'https://example.com/baseline'
  70. })
  71. 1 expect(rbm_action_open_url_default.eql?(rbm_action_open_url_equal)).to be true
  72. 1 expect(rbm_action_open_url_default.eql?(rbm_action_open_url_values)).to be false
  73. end
  74. end
  75. 1 describe '#to_body #to_hash' do
  76. 1 it 'returns a hash representation of the object' do
  77. 1 expect(rbm_action_open_url_values.to_body).to eq({
  78. type: Bandwidth::RbmActionTypeEnum::OPEN_URL,
  79. text: 'Open URL',
  80. postbackData: 'open_url_postback',
  81. url: 'https://example.com',
  82. application: Bandwidth::RbmOpenUrlEnum::BROWSER,
  83. webviewViewMode: Bandwidth::RbmWebViewEnum::FULL
  84. })
  85. end
  86. end
  87. 1 describe 'custom attribute writers' do
  88. 1 it '#type=' do
  89. 1 expect {
  90. 1 Bandwidth::RbmActionOpenUrl.new({ type: nil })
  91. }.to raise_error(ArgumentError, 'type cannot be nil')
  92. end
  93. 1 it '#text=' do
  94. 1 expect {
  95. 1 Bandwidth::RbmActionOpenUrl.new({ type: 'OPEN_URL', text: nil })
  96. }.to raise_error(ArgumentError, 'text cannot be nil')
  97. 1 expect {
  98. 1 Bandwidth::RbmActionOpenUrl.new({ type: 'OPEN_URL', text: 'a' * 26 })
  99. }.to raise_error(ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 25.')
  100. end
  101. 1 it '#postback_data=' do
  102. 1 expect {
  103. 1 Bandwidth::RbmActionOpenUrl.new({ type: 'OPEN_URL', text: 'a', postback_data: nil })
  104. }.to raise_error(ArgumentError, 'postback_data cannot be nil')
  105. 1 expect {
  106. 1 Bandwidth::RbmActionOpenUrl.new({ type: 'OPEN_URL', text: 'a', postback_data: 'a' * 2049 })
  107. }.to raise_error(ArgumentError, 'invalid value for "postback_data", the character length must be smaller than or equal to 2048.')
  108. end
  109. 1 it '#url=' do
  110. 1 expect {
  111. 1 Bandwidth::RbmActionOpenUrl.new({ type: 'OPEN_URL', text: 'a', postback_data: 'a', url: nil })
  112. }.to raise_error(ArgumentError, 'url cannot be nil')
  113. 1 expect {
  114. 1 Bandwidth::RbmActionOpenUrl.new({ type: 'OPEN_URL', text: 'a', postback_data: 'a', url: 'a' * 2049 })
  115. }.to raise_error(ArgumentError, 'invalid value for "url", the character length must be smaller than or equal to 2048.')
  116. end
  117. end
  118. end

spec/unit/models/rbm_action_type_enum_spec.rb

100.0% lines covered

28 relevant lines. 28 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RbmActionTypeEnum
  2. 1 describe Bandwidth::RbmActionTypeEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines REPLY' do
  5. 1 expect(Bandwidth::RbmActionTypeEnum::REPLY).to eq('REPLY')
  6. end
  7. 1 it 'defines DIAL_PHONE' do
  8. 1 expect(Bandwidth::RbmActionTypeEnum::DIAL_PHONE).to eq('DIAL_PHONE')
  9. end
  10. 1 it 'defines SHOW_LOCATION' do
  11. 1 expect(Bandwidth::RbmActionTypeEnum::SHOW_LOCATION).to eq('SHOW_LOCATION')
  12. end
  13. 1 it 'defines CREATE_CALENDAR_EVENT' do
  14. 1 expect(Bandwidth::RbmActionTypeEnum::CREATE_CALENDAR_EVENT).to eq('CREATE_CALENDAR_EVENT')
  15. end
  16. 1 it 'defines OPEN_URL' do
  17. 1 expect(Bandwidth::RbmActionTypeEnum::OPEN_URL).to eq('OPEN_URL')
  18. end
  19. 1 it 'defines REQUEST_LOCATION' do
  20. 1 expect(Bandwidth::RbmActionTypeEnum::REQUEST_LOCATION).to eq('REQUEST_LOCATION')
  21. end
  22. end
  23. 1 describe '.all_vars' do
  24. 1 it 'returns every valid enum value' do
  25. 1 expect(Bandwidth::RbmActionTypeEnum.all_vars).to eq([
  26. 'REPLY',
  27. 'DIAL_PHONE',
  28. 'SHOW_LOCATION',
  29. 'CREATE_CALENDAR_EVENT',
  30. 'OPEN_URL',
  31. 'REQUEST_LOCATION'
  32. ])
  33. end
  34. end
  35. 1 describe '.build_from_hash' do
  36. 1 it 'returns the value when it matches a valid enum value' do
  37. 1 expect(Bandwidth::RbmActionTypeEnum.build_from_hash('REPLY')).to eq('REPLY')
  38. 1 expect(Bandwidth::RbmActionTypeEnum.build_from_hash('DIAL_PHONE')).to eq('DIAL_PHONE')
  39. 1 expect(Bandwidth::RbmActionTypeEnum.build_from_hash('SHOW_LOCATION')).to eq('SHOW_LOCATION')
  40. 1 expect(Bandwidth::RbmActionTypeEnum.build_from_hash('CREATE_CALENDAR_EVENT')).to eq('CREATE_CALENDAR_EVENT')
  41. 1 expect(Bandwidth::RbmActionTypeEnum.build_from_hash('OPEN_URL')).to eq('OPEN_URL')
  42. 1 expect(Bandwidth::RbmActionTypeEnum.build_from_hash('REQUEST_LOCATION')).to eq('REQUEST_LOCATION')
  43. end
  44. 1 it 'raises an error for an invalid enum value' do
  45. 1 expect {
  46. 1 Bandwidth::RbmActionTypeEnum.build_from_hash('invalid')
  47. }.to raise_error(RuntimeError)
  48. end
  49. end
  50. end

spec/unit/models/rbm_action_view_location_spec.rb

100.0% lines covered

62 relevant lines. 62 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RbmActionViewLocation
  2. 1 describe Bandwidth::RbmActionViewLocation do
  3. 2 let(:rbm_action_view_location_default) { Bandwidth::RbmActionViewLocation.new({
  4. type: Bandwidth::RbmActionTypeEnum::SHOW_LOCATION,
  5. text: 'baseline',
  6. postback_data: 'baseline_postback',
  7. latitude: 0.0,
  8. longitude: 0.0
  9. }) }
  10. 5 let(:rbm_action_view_location_values) { Bandwidth::RbmActionViewLocation.new({
  11. type: Bandwidth::RbmActionTypeEnum::SHOW_LOCATION,
  12. text: 'View location',
  13. postback_data: 'location_postback',
  14. latitude: 35.7796,
  15. longitude: -78.6382,
  16. label: 'Bandwidth HQ'
  17. }) }
  18. 1 describe '#initialize' do
  19. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  20. 1 expect {
  21. 1 Bandwidth::RbmActionViewLocation.new([])
  22. }.to raise_error(ArgumentError)
  23. end
  24. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  25. 1 expect {
  26. 1 Bandwidth::RbmActionViewLocation.new({ invalid: true })
  27. }.to raise_error(ArgumentError)
  28. end
  29. end
  30. 1 describe '#acceptable_attributes' do
  31. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  32. 1 expect(Bandwidth::RbmActionViewLocation.acceptable_attributes).to eq(Bandwidth::RbmActionViewLocation.attribute_map.values)
  33. end
  34. end
  35. 1 describe '#openapi_nullable' do
  36. 1 it 'expects nullable attributes to be an empty set' do
  37. 1 expect(Bandwidth::RbmActionViewLocation.openapi_nullable).to eq(Set.new([]))
  38. end
  39. end
  40. 1 describe '#build_from_hash' do
  41. 1 it 'validates instance of RbmActionViewLocation created by the build_from_hash method' do
  42. 1 rbm_action_view_location_from_hash = Bandwidth::RbmActionViewLocation.build_from_hash({
  43. type: Bandwidth::RbmActionTypeEnum::SHOW_LOCATION,
  44. text: 'View location',
  45. postbackData: 'location_postback',
  46. latitude: 35.7796,
  47. longitude: -78.6382,
  48. label: 'Bandwidth HQ'
  49. })
  50. 1 expect(rbm_action_view_location_from_hash).to be_instance_of(Bandwidth::RbmActionViewLocation)
  51. 1 expect(rbm_action_view_location_from_hash.type).to eq(Bandwidth::RbmActionTypeEnum::SHOW_LOCATION)
  52. 1 expect(rbm_action_view_location_from_hash.text).to eq('View location')
  53. 1 expect(rbm_action_view_location_from_hash.postback_data).to eq('location_postback')
  54. 1 expect(rbm_action_view_location_from_hash.latitude).to eq(35.7796)
  55. 1 expect(rbm_action_view_location_from_hash.longitude).to eq(-78.6382)
  56. 1 expect(rbm_action_view_location_from_hash.label).to eq('Bandwidth HQ')
  57. end
  58. end
  59. 1 describe '#to_s' do
  60. 1 it 'returns a string representation of the object' do
  61. 1 expect(rbm_action_view_location_values.to_s).to eq('{:type=>"SHOW_LOCATION", :text=>"View location", :postbackData=>"location_postback", :latitude=>35.7796, :longitude=>-78.6382, :label=>"Bandwidth HQ"}')
  62. end
  63. end
  64. 1 describe '#eq? #==' do
  65. 1 it 'returns true/false when comparing objects' do
  66. 1 rbm_action_view_location_equal = Bandwidth::RbmActionViewLocation.new({
  67. type: Bandwidth::RbmActionTypeEnum::SHOW_LOCATION,
  68. text: 'baseline',
  69. postback_data: 'baseline_postback',
  70. latitude: 0.0,
  71. longitude: 0.0
  72. })
  73. 1 expect(rbm_action_view_location_default.eql?(rbm_action_view_location_equal)).to be true
  74. 1 expect(rbm_action_view_location_default.eql?(rbm_action_view_location_values)).to be false
  75. end
  76. end
  77. 1 describe '#to_body #to_hash' do
  78. 1 it 'returns a hash representation of the object' do
  79. 1 expect(rbm_action_view_location_values.to_body).to eq({
  80. type: Bandwidth::RbmActionTypeEnum::SHOW_LOCATION,
  81. text: 'View location',
  82. postbackData: 'location_postback',
  83. latitude: 35.7796,
  84. longitude: -78.6382,
  85. label: 'Bandwidth HQ'
  86. })
  87. end
  88. end
  89. 1 describe 'custom attribute writers' do
  90. 1 it '#type=' do
  91. 1 expect {
  92. 1 Bandwidth::RbmActionViewLocation.new({ type: nil })
  93. }.to raise_error(ArgumentError, 'type cannot be nil')
  94. end
  95. 1 it '#text=' do
  96. 1 expect {
  97. 1 Bandwidth::RbmActionViewLocation.new({ type: 'SHOW_LOCATION', text: nil })
  98. }.to raise_error(ArgumentError, 'text cannot be nil')
  99. 1 expect {
  100. 1 Bandwidth::RbmActionViewLocation.new({ type: 'SHOW_LOCATION', text: 'a' * 26 })
  101. }.to raise_error(ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 25.')
  102. end
  103. 1 it '#postback_data=' do
  104. 1 expect {
  105. 1 Bandwidth::RbmActionViewLocation.new({ type: 'SHOW_LOCATION', text: 'a', postback_data: nil })
  106. }.to raise_error(ArgumentError, 'postback_data cannot be nil')
  107. 1 expect {
  108. 1 Bandwidth::RbmActionViewLocation.new({ type: 'SHOW_LOCATION', text: 'a', postback_data: 'a' * 2049 })
  109. }.to raise_error(ArgumentError, 'invalid value for "postback_data", the character length must be smaller than or equal to 2048.')
  110. end
  111. 1 it '#latitude=' do
  112. 1 expect {
  113. 1 Bandwidth::RbmActionViewLocation.new({ type: 'SHOW_LOCATION', text: 'a', postback_data: 'a', latitude: nil })
  114. }.to raise_error(ArgumentError, 'latitude cannot be nil')
  115. end
  116. 1 it '#longitude=' do
  117. 1 expect {
  118. 1 Bandwidth::RbmActionViewLocation.new({ type: 'SHOW_LOCATION', text: 'a', postback_data: 'a', latitude: 0.0, longitude: nil })
  119. }.to raise_error(ArgumentError, 'longitude cannot be nil')
  120. end
  121. 1 it '#label=' do
  122. 1 expect {
  123. 1 rbm_action_view_location_values.label = nil
  124. }.to raise_error(ArgumentError, 'label cannot be nil')
  125. 1 expect {
  126. 1 rbm_action_view_location_values.label = 'a' * 101
  127. }.to raise_error(ArgumentError, 'invalid value for "label", the character length must be smaller than or equal to 100.')
  128. end
  129. end
  130. end

spec/unit/models/rbm_card_content_media_spec.rb

100.0% lines covered

48 relevant lines. 48 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RbmCardContentMedia
  2. 1 describe Bandwidth::RbmCardContentMedia do
  3. 2 let(:rbm_card_content_media_default) { Bandwidth::RbmCardContentMedia.new({
  4. file_url: 'https://example.com/baseline.png',
  5. height: Bandwidth::RbmMediaHeightEnum::SHORT
  6. }) }
  7. 5 let(:rbm_card_content_media_values) { Bandwidth::RbmCardContentMedia.new({
  8. file_url: 'https://dev.bandwidth.com/images/bandwidth-logo.png',
  9. thumbnail_url: 'https://dev.bandwidth.com/images/bandwidth-logo-thumb.png',
  10. height: Bandwidth::RbmMediaHeightEnum::MEDIUM
  11. }) }
  12. 1 describe '#initialize' do
  13. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  14. 1 expect {
  15. 1 Bandwidth::RbmCardContentMedia.new([])
  16. }.to raise_error(ArgumentError)
  17. end
  18. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  19. 1 expect {
  20. 1 Bandwidth::RbmCardContentMedia.new({ invalid: true })
  21. }.to raise_error(ArgumentError)
  22. end
  23. end
  24. 1 describe '#acceptable_attributes' do
  25. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  26. 1 expect(Bandwidth::RbmCardContentMedia.acceptable_attributes).to eq(Bandwidth::RbmCardContentMedia.attribute_map.values)
  27. end
  28. end
  29. 1 describe '#openapi_nullable' do
  30. 1 it 'expects nullable attributes to be an empty set' do
  31. 1 expect(Bandwidth::RbmCardContentMedia.openapi_nullable).to eq(Set.new([]))
  32. end
  33. end
  34. 1 describe '#build_from_hash' do
  35. 1 it 'validates instance of RbmCardContentMedia created by the build_from_hash method' do
  36. 1 rbm_card_content_media_from_hash = Bandwidth::RbmCardContentMedia.build_from_hash({
  37. fileUrl: 'https://dev.bandwidth.com/images/bandwidth-logo.png',
  38. thumbnailUrl: 'https://dev.bandwidth.com/images/bandwidth-logo-thumb.png',
  39. height: Bandwidth::RbmMediaHeightEnum::MEDIUM
  40. })
  41. 1 expect(rbm_card_content_media_from_hash).to be_instance_of(Bandwidth::RbmCardContentMedia)
  42. 1 expect(rbm_card_content_media_from_hash.file_url).to eq('https://dev.bandwidth.com/images/bandwidth-logo.png')
  43. 1 expect(rbm_card_content_media_from_hash.thumbnail_url).to eq('https://dev.bandwidth.com/images/bandwidth-logo-thumb.png')
  44. 1 expect(rbm_card_content_media_from_hash.height).to eq(Bandwidth::RbmMediaHeightEnum::MEDIUM)
  45. end
  46. end
  47. 1 describe '#to_s' do
  48. 1 it 'returns a string representation of the object' do
  49. 1 expect(rbm_card_content_media_values.to_s).to eq('{:fileUrl=>"https://dev.bandwidth.com/images/bandwidth-logo.png", :thumbnailUrl=>"https://dev.bandwidth.com/images/bandwidth-logo-thumb.png", :height=>"MEDIUM"}')
  50. end
  51. end
  52. 1 describe '#eq? #==' do
  53. 1 it 'returns true/false when comparing objects' do
  54. 1 rbm_card_content_media_equal = Bandwidth::RbmCardContentMedia.new({
  55. file_url: 'https://example.com/baseline.png',
  56. height: Bandwidth::RbmMediaHeightEnum::SHORT
  57. })
  58. 1 expect(rbm_card_content_media_default.eql?(rbm_card_content_media_equal)).to be true
  59. 1 expect(rbm_card_content_media_default.eql?(rbm_card_content_media_values)).to be false
  60. end
  61. end
  62. 1 describe '#to_body #to_hash' do
  63. 1 it 'returns a hash representation of the object' do
  64. 1 expect(rbm_card_content_media_values.to_body).to eq({
  65. fileUrl: 'https://dev.bandwidth.com/images/bandwidth-logo.png',
  66. thumbnailUrl: 'https://dev.bandwidth.com/images/bandwidth-logo-thumb.png',
  67. height: Bandwidth::RbmMediaHeightEnum::MEDIUM
  68. })
  69. end
  70. end
  71. 1 describe 'custom attribute writers' do
  72. 1 it '#file_url=' do
  73. 1 expect {
  74. 1 Bandwidth::RbmCardContentMedia.new({ file_url: nil })
  75. }.to raise_error(ArgumentError, 'file_url cannot be nil')
  76. 1 expect {
  77. 1 Bandwidth::RbmCardContentMedia.new({ file_url: 'a' * 1001 })
  78. }.to raise_error(ArgumentError, 'invalid value for "file_url", the character length must be smaller than or equal to 1000.')
  79. end
  80. 1 it '#thumbnail_url=' do
  81. 1 expect {
  82. 1 rbm_card_content_media_values.thumbnail_url = nil
  83. }.to raise_error(ArgumentError, 'thumbnail_url cannot be nil')
  84. 1 expect {
  85. 1 rbm_card_content_media_values.thumbnail_url = 'a' * 1001
  86. }.to raise_error(ArgumentError, 'invalid value for "thumbnail_url", the character length must be smaller than or equal to 1000.')
  87. end
  88. 1 it '#height=' do
  89. 1 expect {
  90. 1 Bandwidth::RbmCardContentMedia.new({ file_url: 'a', height: nil })
  91. }.to raise_error(ArgumentError, 'height cannot be nil')
  92. end
  93. end
  94. end

spec/unit/models/rbm_card_content_spec.rb

100.0% lines covered

51 relevant lines. 51 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RbmCardContent
  2. 1 describe Bandwidth::RbmCardContent do
  3. 5 let(:reply_action) { Bandwidth::RbmActionBase.new({
  4. type: Bandwidth::RbmActionTypeEnum::REPLY,
  5. text: 'Yes',
  6. postback_data: 'reply_yes'
  7. }) }
  8. 2 let(:rbm_card_content_default) { Bandwidth::RbmCardContent.new }
  9. 5 let(:rbm_card_content_values) { Bandwidth::RbmCardContent.new({
  10. title: 'Card Title',
  11. description: 'Card Description',
  12. media: Bandwidth::RbmCardContentMedia.new({
  13. file_url: 'https://dev.bandwidth.com/images/bandwidth-logo.png',
  14. height: Bandwidth::RbmMediaHeightEnum::MEDIUM
  15. }),
  16. suggestions: [reply_action]
  17. }) }
  18. 1 describe '#initialize' do
  19. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  20. 1 expect {
  21. 1 Bandwidth::RbmCardContent.new([])
  22. }.to raise_error(ArgumentError)
  23. end
  24. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  25. 1 expect {
  26. 1 Bandwidth::RbmCardContent.new({ invalid: true })
  27. }.to raise_error(ArgumentError)
  28. end
  29. end
  30. 1 describe '#acceptable_attributes' do
  31. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  32. 1 expect(Bandwidth::RbmCardContent.acceptable_attributes).to eq(Bandwidth::RbmCardContent.attribute_map.values)
  33. end
  34. end
  35. 1 describe '#openapi_nullable' do
  36. 1 it 'expects nullable attributes to be an empty set' do
  37. 1 expect(Bandwidth::RbmCardContent.openapi_nullable).to eq(Set.new([]))
  38. end
  39. end
  40. 1 describe '#build_from_hash' do
  41. 1 it 'validates instance of RbmCardContent created by the build_from_hash method' do
  42. 1 rbm_card_content_from_hash = Bandwidth::RbmCardContent.build_from_hash({
  43. title: 'Card Title',
  44. description: 'Card Description',
  45. media: {
  46. fileUrl: 'https://dev.bandwidth.com/images/bandwidth-logo.png',
  47. height: Bandwidth::RbmMediaHeightEnum::MEDIUM
  48. },
  49. suggestions: [{ type: Bandwidth::RbmActionTypeEnum::REPLY, text: 'Yes', postbackData: 'reply_yes' }]
  50. })
  51. 1 expect(rbm_card_content_from_hash).to be_instance_of(Bandwidth::RbmCardContent)
  52. 1 expect(rbm_card_content_from_hash.title).to eq('Card Title')
  53. 1 expect(rbm_card_content_from_hash.description).to eq('Card Description')
  54. 1 expect(rbm_card_content_from_hash.media).to be_instance_of(Bandwidth::RbmCardContentMedia)
  55. 1 expect(rbm_card_content_from_hash.suggestions.first).to be_instance_of(Bandwidth::RbmActionBase)
  56. end
  57. end
  58. 1 describe '#to_s' do
  59. 1 it 'returns a string representation of the object' do
  60. 1 expect(rbm_card_content_values.to_s).to eq('{:title=>"Card Title", :description=>"Card Description", :media=>{:fileUrl=>"https://dev.bandwidth.com/images/bandwidth-logo.png", :height=>"MEDIUM"}, :suggestions=>[{:type=>"REPLY", :text=>"Yes", :postbackData=>"reply_yes"}]}')
  61. end
  62. end
  63. 1 describe '#eq? #==' do
  64. 1 it 'returns true/false when comparing objects' do
  65. 1 expect(rbm_card_content_default.eql?(Bandwidth::RbmCardContent.new)).to be true
  66. 1 expect(rbm_card_content_default.eql?(rbm_card_content_values)).to be false
  67. end
  68. end
  69. 1 describe '#to_body #to_hash' do
  70. 1 it 'returns a hash representation of the object' do
  71. 1 expect(rbm_card_content_values.to_body).to eq({
  72. title: 'Card Title',
  73. description: 'Card Description',
  74. media: {
  75. fileUrl: 'https://dev.bandwidth.com/images/bandwidth-logo.png',
  76. height: Bandwidth::RbmMediaHeightEnum::MEDIUM
  77. },
  78. suggestions: [{ type: Bandwidth::RbmActionTypeEnum::REPLY, text: 'Yes', postbackData: 'reply_yes' }]
  79. })
  80. end
  81. end
  82. 1 describe 'custom attribute writers' do
  83. 1 it '#title=' do
  84. 1 expect {
  85. 1 Bandwidth::RbmCardContent.new({ title: nil })
  86. }.to raise_error(ArgumentError, 'title cannot be nil')
  87. 1 expect {
  88. 1 Bandwidth::RbmCardContent.new({ title: 'a' * 201 })
  89. }.to raise_error(ArgumentError, 'invalid value for "title", the character length must be smaller than or equal to 200.')
  90. end
  91. 1 it '#description=' do
  92. 1 expect {
  93. 1 Bandwidth::RbmCardContent.new({ description: nil })
  94. }.to raise_error(ArgumentError, 'description cannot be nil')
  95. 1 expect {
  96. 1 Bandwidth::RbmCardContent.new({ description: 'a' * 2001 })
  97. }.to raise_error(ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 2000.')
  98. end
  99. 1 it '#suggestions=' do
  100. 1 expect {
  101. 1 rbm_card_content_values.suggestions = nil
  102. }.to raise_error(ArgumentError, 'suggestions cannot be nil')
  103. 1 expect {
  104. 1 rbm_card_content_values.suggestions = [reply_action] * 5
  105. }.to raise_error(ArgumentError, 'invalid value for "suggestions", number of items must be less than or equal to 4.')
  106. end
  107. end
  108. end

spec/unit/models/rbm_location_response_spec.rb

100.0% lines covered

32 relevant lines. 32 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RbmLocationResponse
  2. 1 describe Bandwidth::RbmLocationResponse do
  3. 2 let(:rbm_location_response_default) { Bandwidth::RbmLocationResponse.new }
  4. 4 let(:rbm_location_response_values) { Bandwidth::RbmLocationResponse.new({
  5. latitude: 35.7796,
  6. longitude: -78.6382
  7. }) }
  8. 1 describe '#initialize' do
  9. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  10. 1 expect {
  11. 1 Bandwidth::RbmLocationResponse.new([])
  12. }.to raise_error(ArgumentError)
  13. end
  14. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  15. 1 expect {
  16. 1 Bandwidth::RbmLocationResponse.new({ invalid: true })
  17. }.to raise_error(ArgumentError)
  18. end
  19. end
  20. 1 describe '#acceptable_attributes' do
  21. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  22. 1 expect(Bandwidth::RbmLocationResponse.acceptable_attributes).to eq(Bandwidth::RbmLocationResponse.attribute_map.values)
  23. end
  24. end
  25. 1 describe '#openapi_nullable' do
  26. 1 it 'expects nullable attributes to be an empty set' do
  27. 1 expect(Bandwidth::RbmLocationResponse.openapi_nullable).to eq(Set.new([]))
  28. end
  29. end
  30. 1 describe '#build_from_hash' do
  31. 1 it 'validates instance of RbmLocationResponse created by the build_from_hash method' do
  32. 1 rbm_location_response_from_hash = Bandwidth::RbmLocationResponse.build_from_hash({
  33. latitude: 35.7796,
  34. longitude: -78.6382
  35. })
  36. 1 expect(rbm_location_response_from_hash).to be_instance_of(Bandwidth::RbmLocationResponse)
  37. 1 expect(rbm_location_response_from_hash.latitude).to eq(35.7796)
  38. 1 expect(rbm_location_response_from_hash.longitude).to eq(-78.6382)
  39. end
  40. end
  41. 1 describe '#to_s' do
  42. 1 it 'returns a string representation of the object' do
  43. 1 expect(rbm_location_response_values.to_s).to eq('{:latitude=>35.7796, :longitude=>-78.6382}')
  44. end
  45. end
  46. 1 describe '#eq? #==' do
  47. 1 it 'returns true/false when comparing objects' do
  48. 1 expect(rbm_location_response_default.eql?(Bandwidth::RbmLocationResponse.new)).to be true
  49. 1 expect(rbm_location_response_default.eql?(rbm_location_response_values)).to be false
  50. end
  51. end
  52. 1 describe '#to_body #to_hash' do
  53. 1 it 'returns a hash representation of the object' do
  54. 1 expect(rbm_location_response_values.to_body).to eq({
  55. latitude: 35.7796,
  56. longitude: -78.6382
  57. })
  58. end
  59. end
  60. end

spec/unit/models/rbm_media_height_enum_spec.rb

100.0% lines covered

19 relevant lines. 19 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RbmMediaHeightEnum
  2. 1 describe Bandwidth::RbmMediaHeightEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines SHORT' do
  5. 1 expect(Bandwidth::RbmMediaHeightEnum::SHORT).to eq('SHORT')
  6. end
  7. 1 it 'defines MEDIUM' do
  8. 1 expect(Bandwidth::RbmMediaHeightEnum::MEDIUM).to eq('MEDIUM')
  9. end
  10. 1 it 'defines TALL' do
  11. 1 expect(Bandwidth::RbmMediaHeightEnum::TALL).to eq('TALL')
  12. end
  13. end
  14. 1 describe '.all_vars' do
  15. 1 it 'returns every valid enum value' do
  16. 1 expect(Bandwidth::RbmMediaHeightEnum.all_vars).to eq([
  17. 'SHORT',
  18. 'MEDIUM',
  19. 'TALL'
  20. ])
  21. end
  22. end
  23. 1 describe '.build_from_hash' do
  24. 1 it 'returns the value when it matches a valid enum value' do
  25. 1 expect(Bandwidth::RbmMediaHeightEnum.build_from_hash('SHORT')).to eq('SHORT')
  26. 1 expect(Bandwidth::RbmMediaHeightEnum.build_from_hash('MEDIUM')).to eq('MEDIUM')
  27. 1 expect(Bandwidth::RbmMediaHeightEnum.build_from_hash('TALL')).to eq('TALL')
  28. end
  29. 1 it 'raises an error for an invalid enum value' do
  30. 1 expect {
  31. 1 Bandwidth::RbmMediaHeightEnum.build_from_hash('invalid')
  32. }.to raise_error(RuntimeError)
  33. end
  34. end
  35. end

spec/unit/models/rbm_message_carousel_card_spec.rb

100.0% lines covered

52 relevant lines. 52 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RbmMessageCarouselCard
  2. 1 describe Bandwidth::RbmMessageCarouselCard do
  3. 6 let(:card_content) { Bandwidth::RbmCardContent.new({
  4. title: 'Card Title',
  5. description: 'Card Description'
  6. }) }
  7. 6 let(:reply_action) { Bandwidth::RbmActionBase.new({
  8. type: Bandwidth::RbmActionTypeEnum::REPLY,
  9. text: 'Yes',
  10. postback_data: 'reply_yes'
  11. }) }
  12. 2 let(:rbm_message_carousel_card_default) { Bandwidth::RbmMessageCarouselCard.new({
  13. card_width: Bandwidth::CardWidthEnum::SMALL,
  14. card_contents: [card_content, card_content]
  15. }) }
  16. 6 let(:rbm_message_carousel_card_values) { Bandwidth::RbmMessageCarouselCard.new({
  17. card_width: Bandwidth::CardWidthEnum::MEDIUM,
  18. card_contents: [card_content, card_content],
  19. suggestions: [reply_action]
  20. }) }
  21. 1 describe '#initialize' do
  22. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  23. 1 expect {
  24. 1 Bandwidth::RbmMessageCarouselCard.new([])
  25. }.to raise_error(ArgumentError)
  26. end
  27. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  28. 1 expect {
  29. 1 Bandwidth::RbmMessageCarouselCard.new({ invalid: true })
  30. }.to raise_error(ArgumentError)
  31. end
  32. end
  33. 1 describe '#acceptable_attributes' do
  34. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  35. 1 expect(Bandwidth::RbmMessageCarouselCard.acceptable_attributes).to eq(Bandwidth::RbmMessageCarouselCard.attribute_map.values)
  36. end
  37. end
  38. 1 describe '#openapi_nullable' do
  39. 1 it 'expects nullable attributes to be an empty set' do
  40. 1 expect(Bandwidth::RbmMessageCarouselCard.openapi_nullable).to eq(Set.new([]))
  41. end
  42. end
  43. 1 describe '#build_from_hash' do
  44. 1 it 'validates instance of RbmMessageCarouselCard created by the build_from_hash method' do
  45. 1 rbm_message_carousel_card_from_hash = Bandwidth::RbmMessageCarouselCard.build_from_hash({
  46. cardWidth: Bandwidth::CardWidthEnum::MEDIUM,
  47. cardContents: [{ title: 'Card Title', description: 'Card Description' }, { title: 'Card Title', description: 'Card Description' }],
  48. suggestions: [{ type: Bandwidth::RbmActionTypeEnum::REPLY, text: 'Yes', postbackData: 'reply_yes' }]
  49. })
  50. 1 expect(rbm_message_carousel_card_from_hash).to be_instance_of(Bandwidth::RbmMessageCarouselCard)
  51. 1 expect(rbm_message_carousel_card_from_hash.card_width).to eq(Bandwidth::CardWidthEnum::MEDIUM)
  52. 1 expect(rbm_message_carousel_card_from_hash.card_contents.first).to be_instance_of(Bandwidth::RbmCardContent)
  53. 1 expect(rbm_message_carousel_card_from_hash.suggestions.first).to be_instance_of(Bandwidth::RbmActionBase)
  54. end
  55. end
  56. 1 describe '#to_s' do
  57. 1 it 'returns a string representation of the object' do
  58. 1 expect(rbm_message_carousel_card_values.to_s).to eq('{:cardWidth=>"MEDIUM", :cardContents=>[{:title=>"Card Title", :description=>"Card Description"}, {:title=>"Card Title", :description=>"Card Description"}], :suggestions=>[{:type=>"REPLY", :text=>"Yes", :postbackData=>"reply_yes"}]}')
  59. end
  60. end
  61. 1 describe '#eq? #==' do
  62. 1 it 'returns true/false when comparing objects' do
  63. 1 rbm_message_carousel_card_equal = Bandwidth::RbmMessageCarouselCard.new({
  64. card_width: Bandwidth::CardWidthEnum::SMALL,
  65. card_contents: [card_content, card_content]
  66. })
  67. 1 expect(rbm_message_carousel_card_default.eql?(rbm_message_carousel_card_equal)).to be true
  68. 1 expect(rbm_message_carousel_card_default.eql?(rbm_message_carousel_card_values)).to be false
  69. end
  70. end
  71. 1 describe '#to_body #to_hash' do
  72. 1 it 'returns a hash representation of the object' do
  73. 1 expect(rbm_message_carousel_card_values.to_body).to eq({
  74. cardWidth: Bandwidth::CardWidthEnum::MEDIUM,
  75. cardContents: [
  76. { title: 'Card Title', description: 'Card Description' },
  77. { title: 'Card Title', description: 'Card Description' }
  78. ],
  79. suggestions: [{ type: Bandwidth::RbmActionTypeEnum::REPLY, text: 'Yes', postbackData: 'reply_yes' }]
  80. })
  81. end
  82. end
  83. 1 describe 'custom attribute writers' do
  84. 1 it '#card_width=' do
  85. 1 expect {
  86. 1 Bandwidth::RbmMessageCarouselCard.new({ card_width: nil })
  87. }.to raise_error(ArgumentError, 'card_width cannot be nil')
  88. end
  89. 1 it '#card_contents=' do
  90. 1 expect {
  91. 1 Bandwidth::RbmMessageCarouselCard.new({ card_width: 'SMALL' })
  92. }.to raise_error(ArgumentError, 'card_contents cannot be nil')
  93. 1 expect {
  94. 1 rbm_message_carousel_card_values.card_contents = nil
  95. }.to raise_error(ArgumentError, 'card_contents cannot be nil')
  96. 1 expect {
  97. 1 rbm_message_carousel_card_values.card_contents = [card_content] * 11
  98. }.to raise_error(ArgumentError, 'invalid value for "card_contents", number of items must be less than or equal to 10.')
  99. end
  100. 1 it '#suggestions=' do
  101. 1 expect {
  102. 1 rbm_message_carousel_card_values.suggestions = nil
  103. }.to raise_error(ArgumentError, 'suggestions cannot be nil')
  104. 1 expect {
  105. 1 rbm_message_carousel_card_values.suggestions = [reply_action] * 12
  106. }.to raise_error(ArgumentError, 'invalid value for "suggestions", number of items must be less than or equal to 11.')
  107. end
  108. end
  109. end

spec/unit/models/rbm_message_content_file_spec.rb

100.0% lines covered

44 relevant lines. 44 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RbmMessageContentFile
  2. 1 describe Bandwidth::RbmMessageContentFile do
  3. 2 let(:rbm_message_content_file_default) { Bandwidth::RbmMessageContentFile.new({
  4. file_url: 'https://example.com/baseline.png'
  5. }) }
  6. 5 let(:rbm_message_content_file_values) { Bandwidth::RbmMessageContentFile.new({
  7. file_url: 'https://dev.bandwidth.com/images/bandwidth-logo.png',
  8. thumbnail_url: 'https://dev.bandwidth.com/images/bandwidth-logo-thumb.png'
  9. }) }
  10. 1 describe '#initialize' do
  11. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  12. 1 expect {
  13. 1 Bandwidth::RbmMessageContentFile.new([])
  14. }.to raise_error(ArgumentError)
  15. end
  16. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  17. 1 expect {
  18. 1 Bandwidth::RbmMessageContentFile.new({ invalid: true })
  19. }.to raise_error(ArgumentError)
  20. end
  21. end
  22. 1 describe '#acceptable_attributes' do
  23. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  24. 1 expect(Bandwidth::RbmMessageContentFile.acceptable_attributes).to eq(Bandwidth::RbmMessageContentFile.attribute_map.values)
  25. end
  26. end
  27. 1 describe '#openapi_nullable' do
  28. 1 it 'expects nullable attributes to be an empty set' do
  29. 1 expect(Bandwidth::RbmMessageContentFile.openapi_nullable).to eq(Set.new([]))
  30. end
  31. end
  32. 1 describe '#build_from_hash' do
  33. 1 it 'validates instance of RbmMessageContentFile created by the build_from_hash method' do
  34. 1 rbm_message_content_file_from_hash = Bandwidth::RbmMessageContentFile.build_from_hash({
  35. fileUrl: 'https://dev.bandwidth.com/images/bandwidth-logo.png',
  36. thumbnailUrl: 'https://dev.bandwidth.com/images/bandwidth-logo-thumb.png'
  37. })
  38. 1 expect(rbm_message_content_file_from_hash).to be_instance_of(Bandwidth::RbmMessageContentFile)
  39. 1 expect(rbm_message_content_file_from_hash.file_url).to eq('https://dev.bandwidth.com/images/bandwidth-logo.png')
  40. 1 expect(rbm_message_content_file_from_hash.thumbnail_url).to eq('https://dev.bandwidth.com/images/bandwidth-logo-thumb.png')
  41. end
  42. end
  43. 1 describe '#to_s' do
  44. 1 it 'returns a string representation of the object' do
  45. 1 expect(rbm_message_content_file_values.to_s).to eq('{:fileUrl=>"https://dev.bandwidth.com/images/bandwidth-logo.png", :thumbnailUrl=>"https://dev.bandwidth.com/images/bandwidth-logo-thumb.png"}')
  46. end
  47. end
  48. 1 describe '#eq? #==' do
  49. 1 it 'returns true/false when comparing objects' do
  50. 1 rbm_message_content_file_equal = Bandwidth::RbmMessageContentFile.new({
  51. file_url: 'https://example.com/baseline.png'
  52. })
  53. 1 expect(rbm_message_content_file_default.eql?(rbm_message_content_file_equal)).to be true
  54. 1 expect(rbm_message_content_file_default.eql?(rbm_message_content_file_values)).to be false
  55. end
  56. end
  57. 1 describe '#to_body #to_hash' do
  58. 1 it 'returns a hash representation of the object' do
  59. 1 expect(rbm_message_content_file_values.to_body).to eq({
  60. fileUrl: 'https://dev.bandwidth.com/images/bandwidth-logo.png',
  61. thumbnailUrl: 'https://dev.bandwidth.com/images/bandwidth-logo-thumb.png'
  62. })
  63. end
  64. end
  65. 1 describe 'custom attribute writers' do
  66. 1 it '#file_url=' do
  67. 1 expect {
  68. 1 Bandwidth::RbmMessageContentFile.new({ file_url: nil })
  69. }.to raise_error(ArgumentError, 'file_url cannot be nil')
  70. 1 expect {
  71. 1 Bandwidth::RbmMessageContentFile.new({ file_url: 'a' * 1001 })
  72. }.to raise_error(ArgumentError, 'invalid value for "file_url", the character length must be smaller than or equal to 1000.')
  73. end
  74. 1 it '#thumbnail_url=' do
  75. 1 expect {
  76. 1 rbm_message_content_file_values.thumbnail_url = nil
  77. }.to raise_error(ArgumentError, 'thumbnail_url cannot be nil')
  78. 1 expect {
  79. 1 rbm_message_content_file_values.thumbnail_url = 'a' * 1001
  80. }.to raise_error(ArgumentError, 'invalid value for "thumbnail_url", the character length must be smaller than or equal to 1000.')
  81. end
  82. end
  83. end

spec/unit/models/rbm_message_content_rich_card_spec.rb

100.0% lines covered

14 relevant lines. 14 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RbmMessageContentRichCard
  2. 1 describe Bandwidth::RbmMessageContentRichCard do
  3. 2 let(:card_content) { Bandwidth::RbmCardContent.new({
  4. title: 'Card Title',
  5. description: 'Card Description'
  6. }) }
  7. 1 describe '.openapi_one_of' do
  8. 1 it 'lists the classes defined in oneOf' do
  9. 1 expect(Bandwidth::RbmMessageContentRichCard.openapi_one_of).to eq([
  10. :'RbmMessageCarouselCard',
  11. :'RbmStandaloneCard'
  12. ])
  13. end
  14. end
  15. 1 describe '.build' do
  16. 1 it 'routes payloads matching RbmMessageCarouselCard attributes to RbmMessageCarouselCard.build_from_hash' do
  17. 1 data = { cardWidth: 'SMALL', cardContents: [card_content, card_content] }
  18. 1 expect(Bandwidth::RbmMessageContentRichCard.build(data)).to be_instance_of(Bandwidth::RbmMessageCarouselCard)
  19. end
  20. 1 it 'routes payloads matching RbmStandaloneCard attributes to RbmStandaloneCard.build_from_hash' do
  21. 1 data = { orientation: 'HORIZONTAL', thumbnailImageAlignment: 'LEFT', cardContent: { title: 'Card Title' } }
  22. 1 expect(Bandwidth::RbmMessageContentRichCard.build(data)).to be_instance_of(Bandwidth::RbmStandaloneCard)
  23. end
  24. 1 it 'returns nil when the payload does not match any oneOf schema' do
  25. 1 expect(Bandwidth::RbmMessageContentRichCard.build({ unknown: 'value' })).to be_nil
  26. end
  27. end
  28. end

spec/unit/models/rbm_message_content_text_spec.rb

100.0% lines covered

45 relevant lines. 45 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RbmMessageContentText
  2. 1 describe Bandwidth::RbmMessageContentText do
  3. 5 let(:reply_action) { Bandwidth::RbmActionBase.new({
  4. type: Bandwidth::RbmActionTypeEnum::REPLY,
  5. text: 'Yes',
  6. postback_data: 'reply_yes'
  7. }) }
  8. 2 let(:rbm_message_content_text_default) { Bandwidth::RbmMessageContentText.new({
  9. text: 'baseline'
  10. }) }
  11. 5 let(:rbm_message_content_text_values) { Bandwidth::RbmMessageContentText.new({
  12. text: 'Hello world',
  13. suggestions: [reply_action]
  14. }) }
  15. 1 describe '#initialize' do
  16. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  17. 1 expect {
  18. 1 Bandwidth::RbmMessageContentText.new([])
  19. }.to raise_error(ArgumentError)
  20. end
  21. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  22. 1 expect {
  23. 1 Bandwidth::RbmMessageContentText.new({ invalid: true })
  24. }.to raise_error(ArgumentError)
  25. end
  26. end
  27. 1 describe '#acceptable_attributes' do
  28. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  29. 1 expect(Bandwidth::RbmMessageContentText.acceptable_attributes).to eq(Bandwidth::RbmMessageContentText.attribute_map.values)
  30. end
  31. end
  32. 1 describe '#openapi_nullable' do
  33. 1 it 'expects nullable attributes to be an empty set' do
  34. 1 expect(Bandwidth::RbmMessageContentText.openapi_nullable).to eq(Set.new([]))
  35. end
  36. end
  37. 1 describe '#build_from_hash' do
  38. 1 it 'validates instance of RbmMessageContentText created by the build_from_hash method' do
  39. 1 rbm_message_content_text_from_hash = Bandwidth::RbmMessageContentText.build_from_hash({
  40. text: 'Hello world',
  41. suggestions: [{ type: Bandwidth::RbmActionTypeEnum::REPLY, text: 'Yes', postbackData: 'reply_yes' }]
  42. })
  43. 1 expect(rbm_message_content_text_from_hash).to be_instance_of(Bandwidth::RbmMessageContentText)
  44. 1 expect(rbm_message_content_text_from_hash.text).to eq('Hello world')
  45. 1 expect(rbm_message_content_text_from_hash.suggestions.first).to be_instance_of(Bandwidth::RbmActionBase)
  46. end
  47. end
  48. 1 describe '#to_s' do
  49. 1 it 'returns a string representation of the object' do
  50. 1 expect(rbm_message_content_text_values.to_s).to eq('{:text=>"Hello world", :suggestions=>[{:type=>"REPLY", :text=>"Yes", :postbackData=>"reply_yes"}]}')
  51. end
  52. end
  53. 1 describe '#eq? #==' do
  54. 1 it 'returns true/false when comparing objects' do
  55. 1 rbm_message_content_text_equal = Bandwidth::RbmMessageContentText.new({
  56. text: 'baseline'
  57. })
  58. 1 expect(rbm_message_content_text_default.eql?(rbm_message_content_text_equal)).to be true
  59. 1 expect(rbm_message_content_text_default.eql?(rbm_message_content_text_values)).to be false
  60. end
  61. end
  62. 1 describe '#to_body #to_hash' do
  63. 1 it 'returns a hash representation of the object' do
  64. 1 expect(rbm_message_content_text_values.to_body).to eq({
  65. text: 'Hello world',
  66. suggestions: [{ type: Bandwidth::RbmActionTypeEnum::REPLY, text: 'Yes', postbackData: 'reply_yes' }]
  67. })
  68. end
  69. end
  70. 1 describe 'custom attribute writers' do
  71. 1 it '#text=' do
  72. 1 expect {
  73. 1 Bandwidth::RbmMessageContentText.new({ text: nil })
  74. }.to raise_error(ArgumentError, 'text cannot be nil')
  75. 1 expect {
  76. 1 Bandwidth::RbmMessageContentText.new({ text: 'a' * 3271 })
  77. }.to raise_error(ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 3270.')
  78. end
  79. 1 it '#suggestions=' do
  80. 1 expect {
  81. 1 rbm_message_content_text_values.suggestions = nil
  82. }.to raise_error(ArgumentError, 'suggestions cannot be nil')
  83. 1 expect {
  84. 1 rbm_message_content_text_values.suggestions = [reply_action] * 12
  85. }.to raise_error(ArgumentError, 'invalid value for "suggestions", number of items must be less than or equal to 11.')
  86. end
  87. end
  88. end

spec/unit/models/rbm_message_media_spec.rb

100.0% lines covered

46 relevant lines. 46 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RbmMessageMedia
  2. 1 describe Bandwidth::RbmMessageMedia do
  3. 6 let(:media_file) { Bandwidth::RbmMessageContentFile.new({
  4. file_url: 'https://dev.bandwidth.com/images/bandwidth-logo.png'
  5. }) }
  6. 6 let(:reply_action) { Bandwidth::RbmActionBase.new({
  7. type: Bandwidth::RbmActionTypeEnum::REPLY,
  8. text: 'Yes',
  9. postback_data: 'reply_yes'
  10. }) }
  11. 2 let(:rbm_message_media_default) { Bandwidth::RbmMessageMedia.new({
  12. media: [media_file]
  13. }) }
  14. 6 let(:rbm_message_media_values) { Bandwidth::RbmMessageMedia.new({
  15. media: [media_file],
  16. suggestions: [reply_action]
  17. }) }
  18. 1 describe '#initialize' do
  19. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  20. 1 expect {
  21. 1 Bandwidth::RbmMessageMedia.new([])
  22. }.to raise_error(ArgumentError)
  23. end
  24. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  25. 1 expect {
  26. 1 Bandwidth::RbmMessageMedia.new({ invalid: true })
  27. }.to raise_error(ArgumentError)
  28. end
  29. end
  30. 1 describe '#acceptable_attributes' do
  31. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  32. 1 expect(Bandwidth::RbmMessageMedia.acceptable_attributes).to eq(Bandwidth::RbmMessageMedia.attribute_map.values)
  33. end
  34. end
  35. 1 describe '#openapi_nullable' do
  36. 1 it 'expects nullable attributes to be an empty set' do
  37. 1 expect(Bandwidth::RbmMessageMedia.openapi_nullable).to eq(Set.new([]))
  38. end
  39. end
  40. 1 describe '#build_from_hash' do
  41. 1 it 'validates instance of RbmMessageMedia created by the build_from_hash method' do
  42. 1 rbm_message_media_from_hash = Bandwidth::RbmMessageMedia.build_from_hash({
  43. media: [{ fileUrl: 'https://dev.bandwidth.com/images/bandwidth-logo.png' }],
  44. suggestions: [{ type: Bandwidth::RbmActionTypeEnum::REPLY, text: 'Yes', postbackData: 'reply_yes' }]
  45. })
  46. 1 expect(rbm_message_media_from_hash).to be_instance_of(Bandwidth::RbmMessageMedia)
  47. 1 expect(rbm_message_media_from_hash.media.first).to be_instance_of(Bandwidth::RbmMessageContentFile)
  48. 1 expect(rbm_message_media_from_hash.suggestions.first).to be_instance_of(Bandwidth::RbmActionBase)
  49. end
  50. end
  51. 1 describe '#to_s' do
  52. 1 it 'returns a string representation of the object' do
  53. 1 expect(rbm_message_media_values.to_s).to eq('{:media=>[{:fileUrl=>"https://dev.bandwidth.com/images/bandwidth-logo.png"}], :suggestions=>[{:type=>"REPLY", :text=>"Yes", :postbackData=>"reply_yes"}]}')
  54. end
  55. end
  56. 1 describe '#eq? #==' do
  57. 1 it 'returns true/false when comparing objects' do
  58. 1 rbm_message_media_equal = Bandwidth::RbmMessageMedia.new({
  59. media: [media_file]
  60. })
  61. 1 expect(rbm_message_media_default.eql?(rbm_message_media_equal)).to be true
  62. 1 expect(rbm_message_media_default.eql?(rbm_message_media_values)).to be false
  63. end
  64. end
  65. 1 describe '#to_body #to_hash' do
  66. 1 it 'returns a hash representation of the object' do
  67. 1 expect(rbm_message_media_values.to_body).to eq({
  68. media: [{ fileUrl: 'https://dev.bandwidth.com/images/bandwidth-logo.png' }],
  69. suggestions: [{ type: Bandwidth::RbmActionTypeEnum::REPLY, text: 'Yes', postbackData: 'reply_yes' }]
  70. })
  71. end
  72. end
  73. 1 describe 'custom attribute writers' do
  74. 1 it '#media=' do
  75. 1 expect {
  76. 1 Bandwidth::RbmMessageMedia.new({})
  77. }.to raise_error(ArgumentError, 'media cannot be nil')
  78. 1 expect {
  79. 1 rbm_message_media_values.media = nil
  80. }.to raise_error(ArgumentError, 'media cannot be nil')
  81. end
  82. 1 it '#suggestions=' do
  83. 1 expect {
  84. 1 rbm_message_media_values.suggestions = nil
  85. }.to raise_error(ArgumentError, 'suggestions cannot be nil')
  86. 1 expect {
  87. 1 rbm_message_media_values.suggestions = [reply_action] * 12
  88. }.to raise_error(ArgumentError, 'invalid value for "suggestions", number of items must be less than or equal to 11.')
  89. end
  90. end
  91. end

spec/unit/models/rbm_open_url_enum_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RbmOpenUrlEnum
  2. 1 describe Bandwidth::RbmOpenUrlEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines BROWSER' do
  5. 1 expect(Bandwidth::RbmOpenUrlEnum::BROWSER).to eq('BROWSER')
  6. end
  7. 1 it 'defines WEBVIEW' do
  8. 1 expect(Bandwidth::RbmOpenUrlEnum::WEBVIEW).to eq('WEBVIEW')
  9. end
  10. end
  11. 1 describe '.all_vars' do
  12. 1 it 'returns every valid enum value' do
  13. 1 expect(Bandwidth::RbmOpenUrlEnum.all_vars).to eq([
  14. 'BROWSER',
  15. 'WEBVIEW'
  16. ])
  17. end
  18. end
  19. 1 describe '.build_from_hash' do
  20. 1 it 'returns the value when it matches a valid enum value' do
  21. 1 expect(Bandwidth::RbmOpenUrlEnum.build_from_hash('BROWSER')).to eq('BROWSER')
  22. 1 expect(Bandwidth::RbmOpenUrlEnum.build_from_hash('WEBVIEW')).to eq('WEBVIEW')
  23. end
  24. 1 it 'raises an error for an invalid enum value' do
  25. 1 expect {
  26. 1 Bandwidth::RbmOpenUrlEnum.build_from_hash('invalid')
  27. }.to raise_error(RuntimeError)
  28. end
  29. end
  30. end

spec/unit/models/rbm_standalone_card_spec.rb

100.0% lines covered

49 relevant lines. 49 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RbmStandaloneCard
  2. 1 describe Bandwidth::RbmStandaloneCard do
  3. 5 let(:card_content) { Bandwidth::RbmCardContent.new({
  4. title: 'Card Title',
  5. description: 'Card Description'
  6. }) }
  7. 5 let(:reply_action) { Bandwidth::RbmActionBase.new({
  8. type: Bandwidth::RbmActionTypeEnum::REPLY,
  9. text: 'Yes',
  10. postback_data: 'reply_yes'
  11. }) }
  12. 2 let(:rbm_standalone_card_default) { Bandwidth::RbmStandaloneCard.new({
  13. orientation: Bandwidth::StandaloneCardOrientationEnum::HORIZONTAL,
  14. thumbnail_image_alignment: Bandwidth::ThumbnailAlignmentEnum::LEFT,
  15. card_content: card_content
  16. }) }
  17. 5 let(:rbm_standalone_card_values) { Bandwidth::RbmStandaloneCard.new({
  18. orientation: Bandwidth::StandaloneCardOrientationEnum::VERTICAL,
  19. thumbnail_image_alignment: Bandwidth::ThumbnailAlignmentEnum::RIGHT,
  20. card_content: card_content,
  21. suggestions: [reply_action]
  22. }) }
  23. 1 describe '#initialize' do
  24. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  25. 1 expect {
  26. 1 Bandwidth::RbmStandaloneCard.new([])
  27. }.to raise_error(ArgumentError)
  28. end
  29. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  30. 1 expect {
  31. 1 Bandwidth::RbmStandaloneCard.new({ invalid: true })
  32. }.to raise_error(ArgumentError)
  33. end
  34. end
  35. 1 describe '#acceptable_attributes' do
  36. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  37. 1 expect(Bandwidth::RbmStandaloneCard.acceptable_attributes).to eq(Bandwidth::RbmStandaloneCard.attribute_map.values)
  38. end
  39. end
  40. 1 describe '#openapi_nullable' do
  41. 1 it 'expects nullable attributes to be an empty set' do
  42. 1 expect(Bandwidth::RbmStandaloneCard.openapi_nullable).to eq(Set.new([]))
  43. end
  44. end
  45. 1 describe '#build_from_hash' do
  46. 1 it 'validates instance of RbmStandaloneCard created by the build_from_hash method' do
  47. 1 rbm_standalone_card_from_hash = Bandwidth::RbmStandaloneCard.build_from_hash({
  48. orientation: Bandwidth::StandaloneCardOrientationEnum::VERTICAL,
  49. thumbnailImageAlignment: Bandwidth::ThumbnailAlignmentEnum::RIGHT,
  50. cardContent: { title: 'Card Title', description: 'Card Description' },
  51. suggestions: [{ type: Bandwidth::RbmActionTypeEnum::REPLY, text: 'Yes', postbackData: 'reply_yes' }]
  52. })
  53. 1 expect(rbm_standalone_card_from_hash).to be_instance_of(Bandwidth::RbmStandaloneCard)
  54. 1 expect(rbm_standalone_card_from_hash.orientation).to eq(Bandwidth::StandaloneCardOrientationEnum::VERTICAL)
  55. 1 expect(rbm_standalone_card_from_hash.thumbnail_image_alignment).to eq(Bandwidth::ThumbnailAlignmentEnum::RIGHT)
  56. 1 expect(rbm_standalone_card_from_hash.card_content).to be_instance_of(Bandwidth::RbmCardContent)
  57. 1 expect(rbm_standalone_card_from_hash.suggestions.first).to be_instance_of(Bandwidth::RbmActionBase)
  58. end
  59. end
  60. 1 describe '#to_s' do
  61. 1 it 'returns a string representation of the object' do
  62. 1 expect(rbm_standalone_card_values.to_s).to eq('{:orientation=>"VERTICAL", :thumbnailImageAlignment=>"RIGHT", :cardContent=>{:title=>"Card Title", :description=>"Card Description"}, :suggestions=>[{:type=>"REPLY", :text=>"Yes", :postbackData=>"reply_yes"}]}')
  63. end
  64. end
  65. 1 describe '#eq? #==' do
  66. 1 it 'returns true/false when comparing objects' do
  67. 1 rbm_standalone_card_equal = Bandwidth::RbmStandaloneCard.new({
  68. orientation: Bandwidth::StandaloneCardOrientationEnum::HORIZONTAL,
  69. thumbnail_image_alignment: Bandwidth::ThumbnailAlignmentEnum::LEFT,
  70. card_content: card_content
  71. })
  72. 1 expect(rbm_standalone_card_default.eql?(rbm_standalone_card_equal)).to be true
  73. 1 expect(rbm_standalone_card_default.eql?(rbm_standalone_card_values)).to be false
  74. end
  75. end
  76. 1 describe '#to_body #to_hash' do
  77. 1 it 'returns a hash representation of the object' do
  78. 1 expect(rbm_standalone_card_values.to_body).to eq({
  79. orientation: Bandwidth::StandaloneCardOrientationEnum::VERTICAL,
  80. thumbnailImageAlignment: Bandwidth::ThumbnailAlignmentEnum::RIGHT,
  81. cardContent: { title: 'Card Title', description: 'Card Description' },
  82. suggestions: [{ type: Bandwidth::RbmActionTypeEnum::REPLY, text: 'Yes', postbackData: 'reply_yes' }]
  83. })
  84. end
  85. end
  86. 1 describe 'custom attribute writers' do
  87. 1 it '#orientation=' do
  88. 1 expect {
  89. 1 Bandwidth::RbmStandaloneCard.new({ orientation: nil })
  90. }.to raise_error(ArgumentError, 'orientation cannot be nil')
  91. end
  92. 1 it '#card_content=' do
  93. 1 expect {
  94. 1 Bandwidth::RbmStandaloneCard.new({ orientation: 'HORIZONTAL', thumbnail_image_alignment: 'LEFT', card_content: nil })
  95. }.to raise_error(ArgumentError, 'card_content cannot be nil')
  96. end
  97. 1 it '#suggestions=' do
  98. 1 expect {
  99. 1 rbm_standalone_card_values.suggestions = nil
  100. }.to raise_error(ArgumentError, 'suggestions cannot be nil')
  101. 1 expect {
  102. 1 rbm_standalone_card_values.suggestions = [reply_action] * 12
  103. }.to raise_error(ArgumentError, 'invalid value for "suggestions", number of items must be less than or equal to 11.')
  104. end
  105. end
  106. end

spec/unit/models/rbm_suggestion_response_spec.rb

100.0% lines covered

38 relevant lines. 38 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RbmSuggestionResponse
  2. 1 describe Bandwidth::RbmSuggestionResponse do
  3. 2 let(:rbm_suggestion_response_default) { Bandwidth::RbmSuggestionResponse.new }
  4. 5 let(:rbm_suggestion_response_values) { Bandwidth::RbmSuggestionResponse.new({
  5. text: 'Yes',
  6. postback_data: 'reply_yes'
  7. }) }
  8. 1 describe '#initialize' do
  9. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  10. 1 expect {
  11. 1 Bandwidth::RbmSuggestionResponse.new([])
  12. }.to raise_error(ArgumentError)
  13. end
  14. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  15. 1 expect {
  16. 1 Bandwidth::RbmSuggestionResponse.new({ invalid: true })
  17. }.to raise_error(ArgumentError)
  18. end
  19. end
  20. 1 describe '#acceptable_attributes' do
  21. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  22. 1 expect(Bandwidth::RbmSuggestionResponse.acceptable_attributes).to eq(Bandwidth::RbmSuggestionResponse.attribute_map.values)
  23. end
  24. end
  25. 1 describe '#openapi_nullable' do
  26. 1 it 'expects nullable attributes to be an empty set' do
  27. 1 expect(Bandwidth::RbmSuggestionResponse.openapi_nullable).to eq(Set.new([]))
  28. end
  29. end
  30. 1 describe '#build_from_hash' do
  31. 1 it 'validates instance of RbmSuggestionResponse created by the build_from_hash method' do
  32. 1 rbm_suggestion_response_from_hash = Bandwidth::RbmSuggestionResponse.build_from_hash({
  33. text: 'Yes',
  34. postbackData: 'reply_yes'
  35. })
  36. 1 expect(rbm_suggestion_response_from_hash).to be_instance_of(Bandwidth::RbmSuggestionResponse)
  37. 1 expect(rbm_suggestion_response_from_hash.text).to eq('Yes')
  38. 1 expect(rbm_suggestion_response_from_hash.postback_data).to eq('reply_yes')
  39. end
  40. end
  41. 1 describe '#to_s' do
  42. 1 it 'returns a string representation of the object' do
  43. 1 expect(rbm_suggestion_response_values.to_s).to eq('{:text=>"Yes", :postbackData=>"reply_yes"}')
  44. end
  45. end
  46. 1 describe '#eq? #==' do
  47. 1 it 'returns true/false when comparing objects' do
  48. 1 expect(rbm_suggestion_response_default.eql?(Bandwidth::RbmSuggestionResponse.new)).to be true
  49. 1 expect(rbm_suggestion_response_default.eql?(rbm_suggestion_response_values)).to be false
  50. end
  51. end
  52. 1 describe '#to_body #to_hash' do
  53. 1 it 'returns a hash representation of the object' do
  54. 1 expect(rbm_suggestion_response_values.to_body).to eq({
  55. text: 'Yes',
  56. postbackData: 'reply_yes'
  57. })
  58. end
  59. end
  60. 1 describe 'custom attribute writers' do
  61. 1 it '#postback_data=' do
  62. 1 expect {
  63. 1 rbm_suggestion_response_values.postback_data = nil
  64. }.to raise_error(ArgumentError, 'postback_data cannot be nil')
  65. 1 expect {
  66. 1 rbm_suggestion_response_values.postback_data = 'a' * 2049
  67. }.to raise_error(ArgumentError, 'invalid value for "postback_data", the character length must be smaller than or equal to 2048.')
  68. end
  69. end
  70. end

spec/unit/models/rbm_web_view_enum_spec.rb

100.0% lines covered

19 relevant lines. 19 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RbmWebViewEnum
  2. 1 describe Bandwidth::RbmWebViewEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines FULL' do
  5. 1 expect(Bandwidth::RbmWebViewEnum::FULL).to eq('FULL')
  6. end
  7. 1 it 'defines HALF' do
  8. 1 expect(Bandwidth::RbmWebViewEnum::HALF).to eq('HALF')
  9. end
  10. 1 it 'defines TALL' do
  11. 1 expect(Bandwidth::RbmWebViewEnum::TALL).to eq('TALL')
  12. end
  13. end
  14. 1 describe '.all_vars' do
  15. 1 it 'returns every valid enum value' do
  16. 1 expect(Bandwidth::RbmWebViewEnum.all_vars).to eq([
  17. 'FULL',
  18. 'HALF',
  19. 'TALL'
  20. ])
  21. end
  22. end
  23. 1 describe '.build_from_hash' do
  24. 1 it 'returns the value when it matches a valid enum value' do
  25. 1 expect(Bandwidth::RbmWebViewEnum.build_from_hash('FULL')).to eq('FULL')
  26. 1 expect(Bandwidth::RbmWebViewEnum.build_from_hash('HALF')).to eq('HALF')
  27. 1 expect(Bandwidth::RbmWebViewEnum.build_from_hash('TALL')).to eq('TALL')
  28. end
  29. 1 it 'raises an error for an invalid enum value' do
  30. 1 expect {
  31. 1 Bandwidth::RbmWebViewEnum.build_from_hash('invalid')
  32. }.to raise_error(RuntimeError)
  33. end
  34. end
  35. end

spec/unit/models/recording_available_callback_spec.rb

100.0% lines covered

52 relevant lines. 52 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RecordingAvailableCallback
  2. 1 describe Bandwidth::RecordingAvailableCallback do
  3. 2 let(:recording_available_callback_default) { Bandwidth::RecordingAvailableCallback.new }
  4. 4 let(:recording_available_callback_values) { Bandwidth::RecordingAvailableCallback.new({
  5. event_type: 'recordingAvailable',
  6. event_time: '2022-06-16T13:15:07.160Z',
  7. account_id: '9900000',
  8. application_id: '04e88489-df02-4e34-a0ee-27a91849555f',
  9. from: '+19195554321',
  10. to: '+19195551234',
  11. direction: Bandwidth::CallDirectionEnum::INBOUND,
  12. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  13. call_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  14. parent_call_id: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  15. recording_id: 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  16. media_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/media',
  17. enqueued_time: '2022-06-16T13:15:07.160Z',
  18. start_time: '2022-06-16T13:15:07.160Z',
  19. end_time: '2022-06-16T13:17:07.160Z',
  20. duration: 'PT2M',
  21. file_format: Bandwidth::FileFormatEnum::WAV,
  22. channels: 1,
  23. tag: 'custom tag',
  24. status: 'complete',
  25. transfer_caller_id: '+19195554321',
  26. transfer_to: '+19195551234'
  27. }) }
  28. 1 describe '#initialize' do
  29. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  30. 1 expect {
  31. 1 Bandwidth::RecordingAvailableCallback.new([])
  32. }.to raise_error(ArgumentError)
  33. end
  34. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  35. 1 expect {
  36. 1 Bandwidth::RecordingAvailableCallback.new({ invalid: true })
  37. }.to raise_error(ArgumentError)
  38. end
  39. end
  40. 1 describe '#acceptable_attributes' do
  41. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  42. 1 expect(Bandwidth::RecordingAvailableCallback.acceptable_attributes).to eq(Bandwidth::RecordingAvailableCallback.attribute_map.values)
  43. end
  44. end
  45. 1 describe '#openapi_nullable' do
  46. 1 it 'expects nullable attributes to be the set of nullable fields' do
  47. 1 expect(Bandwidth::RecordingAvailableCallback.openapi_nullable).to eq(Set.new([
  48. :'media_url',
  49. :'enqueued_time',
  50. :'tag'
  51. ]))
  52. end
  53. end
  54. 1 describe '#build_from_hash' do
  55. 1 it 'validates instance of RecordingAvailableCallback created by the build_from_hash method' do
  56. 1 recording_available_callback_from_hash = Bandwidth::RecordingAvailableCallback.build_from_hash({
  57. eventType: 'recordingAvailable',
  58. eventTime: '2022-06-16T13:15:07.160Z',
  59. accountId: '9900000',
  60. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  61. from: '+19195554321',
  62. to: '+19195551234',
  63. direction: Bandwidth::CallDirectionEnum::INBOUND,
  64. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  65. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  66. parentCallId: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  67. recordingId: 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  68. mediaUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/media',
  69. enqueuedTime: '2022-06-16T13:15:07.160Z',
  70. startTime: '2022-06-16T13:15:07.160Z',
  71. endTime: '2022-06-16T13:17:07.160Z',
  72. duration: 'PT2M',
  73. fileFormat: Bandwidth::FileFormatEnum::WAV,
  74. channels: 1,
  75. tag: 'custom tag',
  76. status: 'complete',
  77. transferCallerId: '+19195554321',
  78. transferTo: '+19195551234'
  79. })
  80. 1 expect(recording_available_callback_from_hash).to be_instance_of(Bandwidth::RecordingAvailableCallback)
  81. 1 expect(recording_available_callback_from_hash.event_type).to eq('recordingAvailable')
  82. 1 expect(recording_available_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  83. 1 expect(recording_available_callback_from_hash.account_id).to eq('9900000')
  84. 1 expect(recording_available_callback_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f')
  85. 1 expect(recording_available_callback_from_hash.from).to eq('+19195554321')
  86. 1 expect(recording_available_callback_from_hash.to).to eq('+19195551234')
  87. 1 expect(recording_available_callback_from_hash.direction).to eq(Bandwidth::CallDirectionEnum::INBOUND)
  88. 1 expect(recording_available_callback_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  89. 1 expect(recording_available_callback_from_hash.call_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  90. 1 expect(recording_available_callback_from_hash.parent_call_id).to eq('c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99')
  91. 1 expect(recording_available_callback_from_hash.recording_id).to eq('r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  92. 1 expect(recording_available_callback_from_hash.media_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/media')
  93. 1 expect(recording_available_callback_from_hash.enqueued_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  94. 1 expect(recording_available_callback_from_hash.start_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  95. 1 expect(recording_available_callback_from_hash.end_time).to eq(Time.parse('2022-06-16T13:17:07.160Z'))
  96. 1 expect(recording_available_callback_from_hash.duration).to eq('PT2M')
  97. 1 expect(recording_available_callback_from_hash.file_format).to eq(Bandwidth::FileFormatEnum::WAV)
  98. 1 expect(recording_available_callback_from_hash.channels).to eq(1)
  99. 1 expect(recording_available_callback_from_hash.tag).to eq('custom tag')
  100. 1 expect(recording_available_callback_from_hash.status).to eq('complete')
  101. 1 expect(recording_available_callback_from_hash.transfer_caller_id).to eq('+19195554321')
  102. 1 expect(recording_available_callback_from_hash.transfer_to).to eq('+19195551234')
  103. end
  104. end
  105. 1 describe '#to_s' do
  106. 1 it 'returns a string representation of the object' do
  107. 1 expect(recording_available_callback_values.to_s).to eq('{:eventType=>"recordingAvailable", :eventTime=>"2022-06-16T13:15:07.160Z", :accountId=>"9900000", :applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :from=>"+19195554321", :to=>"+19195551234", :direction=>"inbound", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :callUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :parentCallId=>"c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99", :recordingId=>"r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :mediaUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/media", :enqueuedTime=>"2022-06-16T13:15:07.160Z", :startTime=>"2022-06-16T13:15:07.160Z", :endTime=>"2022-06-16T13:17:07.160Z", :duration=>"PT2M", :fileFormat=>"wav", :channels=>1, :tag=>"custom tag", :status=>"complete", :transferCallerId=>"+19195554321", :transferTo=>"+19195551234"}')
  108. end
  109. end
  110. 1 describe '#eq? #==' do
  111. 1 it 'returns true/false when comparing objects' do
  112. 1 expect(recording_available_callback_default.eql?(Bandwidth::RecordingAvailableCallback.new)).to be true
  113. 1 expect(recording_available_callback_default.eql?(recording_available_callback_values)).to be false
  114. end
  115. end
  116. 1 describe '#to_body #to_hash' do
  117. 1 it 'returns a hash representation of the object' do
  118. 1 expect(recording_available_callback_values.to_body).to eq({
  119. eventType: 'recordingAvailable',
  120. eventTime: '2022-06-16T13:15:07.160Z',
  121. accountId: '9900000',
  122. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  123. from: '+19195554321',
  124. to: '+19195551234',
  125. direction: Bandwidth::CallDirectionEnum::INBOUND,
  126. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  127. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  128. parentCallId: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  129. recordingId: 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  130. mediaUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/media',
  131. enqueuedTime: '2022-06-16T13:15:07.160Z',
  132. startTime: '2022-06-16T13:15:07.160Z',
  133. endTime: '2022-06-16T13:17:07.160Z',
  134. duration: 'PT2M',
  135. fileFormat: Bandwidth::FileFormatEnum::WAV,
  136. channels: 1,
  137. tag: 'custom tag',
  138. status: 'complete',
  139. transferCallerId: '+19195554321',
  140. transferTo: '+19195551234'
  141. })
  142. end
  143. end
  144. end

spec/unit/models/recording_complete_callback_spec.rb

100.0% lines covered

52 relevant lines. 52 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RecordingCompleteCallback
  2. 1 describe Bandwidth::RecordingCompleteCallback do
  3. 2 let(:recording_complete_callback_default) { Bandwidth::RecordingCompleteCallback.new }
  4. 4 let(:recording_complete_callback_values) { Bandwidth::RecordingCompleteCallback.new({
  5. event_type: 'recordingComplete',
  6. event_time: '2022-06-16T13:15:07.160Z',
  7. account_id: '9900000',
  8. application_id: '04e88489-df02-4e34-a0ee-27a91849555f',
  9. from: '+19195554321',
  10. to: '+19195551234',
  11. direction: Bandwidth::CallDirectionEnum::INBOUND,
  12. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  13. call_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  14. parent_call_id: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  15. recording_id: 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  16. media_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/media',
  17. enqueued_time: '2022-06-16T13:15:07.160Z',
  18. start_time: '2022-06-16T13:15:07.160Z',
  19. answer_time: '2022-06-16T13:15:18.126Z',
  20. end_time: '2022-06-16T13:17:07.160Z',
  21. duration: 'PT2M',
  22. file_format: Bandwidth::FileFormatEnum::WAV,
  23. channels: 1,
  24. tag: 'custom tag',
  25. transfer_caller_id: '+19195554321',
  26. transfer_to: '+19195551234'
  27. }) }
  28. 1 describe '#initialize' do
  29. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  30. 1 expect {
  31. 1 Bandwidth::RecordingCompleteCallback.new([])
  32. }.to raise_error(ArgumentError)
  33. end
  34. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  35. 1 expect {
  36. 1 Bandwidth::RecordingCompleteCallback.new({ invalid: true })
  37. }.to raise_error(ArgumentError)
  38. end
  39. end
  40. 1 describe '#acceptable_attributes' do
  41. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  42. 1 expect(Bandwidth::RecordingCompleteCallback.acceptable_attributes).to eq(Bandwidth::RecordingCompleteCallback.attribute_map.values)
  43. end
  44. end
  45. 1 describe '#openapi_nullable' do
  46. 1 it 'expects nullable attributes to be the set of nullable fields' do
  47. 1 expect(Bandwidth::RecordingCompleteCallback.openapi_nullable).to eq(Set.new([
  48. :'media_url',
  49. :'enqueued_time',
  50. :'answer_time',
  51. :'tag'
  52. ]))
  53. end
  54. end
  55. 1 describe '#build_from_hash' do
  56. 1 it 'validates instance of RecordingCompleteCallback created by the build_from_hash method' do
  57. 1 recording_complete_callback_from_hash = Bandwidth::RecordingCompleteCallback.build_from_hash({
  58. eventType: 'recordingComplete',
  59. eventTime: '2022-06-16T13:15:07.160Z',
  60. accountId: '9900000',
  61. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  62. from: '+19195554321',
  63. to: '+19195551234',
  64. direction: Bandwidth::CallDirectionEnum::INBOUND,
  65. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  66. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  67. parentCallId: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  68. recordingId: 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  69. mediaUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/media',
  70. enqueuedTime: '2022-06-16T13:15:07.160Z',
  71. startTime: '2022-06-16T13:15:07.160Z',
  72. answerTime: '2022-06-16T13:15:18.126Z',
  73. endTime: '2022-06-16T13:17:07.160Z',
  74. duration: 'PT2M',
  75. fileFormat: Bandwidth::FileFormatEnum::WAV,
  76. channels: 1,
  77. tag: 'custom tag',
  78. transferCallerId: '+19195554321',
  79. transferTo: '+19195551234'
  80. })
  81. 1 expect(recording_complete_callback_from_hash).to be_instance_of(Bandwidth::RecordingCompleteCallback)
  82. 1 expect(recording_complete_callback_from_hash.event_type).to eq('recordingComplete')
  83. 1 expect(recording_complete_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  84. 1 expect(recording_complete_callback_from_hash.account_id).to eq('9900000')
  85. 1 expect(recording_complete_callback_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f')
  86. 1 expect(recording_complete_callback_from_hash.from).to eq('+19195554321')
  87. 1 expect(recording_complete_callback_from_hash.to).to eq('+19195551234')
  88. 1 expect(recording_complete_callback_from_hash.direction).to eq(Bandwidth::CallDirectionEnum::INBOUND)
  89. 1 expect(recording_complete_callback_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  90. 1 expect(recording_complete_callback_from_hash.call_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  91. 1 expect(recording_complete_callback_from_hash.parent_call_id).to eq('c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99')
  92. 1 expect(recording_complete_callback_from_hash.recording_id).to eq('r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  93. 1 expect(recording_complete_callback_from_hash.media_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/media')
  94. 1 expect(recording_complete_callback_from_hash.enqueued_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  95. 1 expect(recording_complete_callback_from_hash.start_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  96. 1 expect(recording_complete_callback_from_hash.answer_time).to eq(Time.parse('2022-06-16T13:15:18.126Z'))
  97. 1 expect(recording_complete_callback_from_hash.end_time).to eq(Time.parse('2022-06-16T13:17:07.160Z'))
  98. 1 expect(recording_complete_callback_from_hash.duration).to eq('PT2M')
  99. 1 expect(recording_complete_callback_from_hash.file_format).to eq(Bandwidth::FileFormatEnum::WAV)
  100. 1 expect(recording_complete_callback_from_hash.channels).to eq(1)
  101. 1 expect(recording_complete_callback_from_hash.tag).to eq('custom tag')
  102. 1 expect(recording_complete_callback_from_hash.transfer_caller_id).to eq('+19195554321')
  103. 1 expect(recording_complete_callback_from_hash.transfer_to).to eq('+19195551234')
  104. end
  105. end
  106. 1 describe '#to_s' do
  107. 1 it 'returns a string representation of the object' do
  108. 1 expect(recording_complete_callback_values.to_s).to eq('{:eventType=>"recordingComplete", :eventTime=>"2022-06-16T13:15:07.160Z", :accountId=>"9900000", :applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :from=>"+19195554321", :to=>"+19195551234", :direction=>"inbound", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :callUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :parentCallId=>"c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99", :recordingId=>"r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :mediaUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/media", :enqueuedTime=>"2022-06-16T13:15:07.160Z", :startTime=>"2022-06-16T13:15:07.160Z", :answerTime=>"2022-06-16T13:15:18.126Z", :endTime=>"2022-06-16T13:17:07.160Z", :duration=>"PT2M", :fileFormat=>"wav", :channels=>1, :tag=>"custom tag", :transferCallerId=>"+19195554321", :transferTo=>"+19195551234"}')
  109. end
  110. end
  111. 1 describe '#eq? #==' do
  112. 1 it 'returns true/false when comparing objects' do
  113. 1 expect(recording_complete_callback_default.eql?(Bandwidth::RecordingCompleteCallback.new)).to be true
  114. 1 expect(recording_complete_callback_default.eql?(recording_complete_callback_values)).to be false
  115. end
  116. end
  117. 1 describe '#to_body #to_hash' do
  118. 1 it 'returns a hash representation of the object' do
  119. 1 expect(recording_complete_callback_values.to_body).to eq({
  120. eventType: 'recordingComplete',
  121. eventTime: '2022-06-16T13:15:07.160Z',
  122. accountId: '9900000',
  123. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  124. from: '+19195554321',
  125. to: '+19195551234',
  126. direction: Bandwidth::CallDirectionEnum::INBOUND,
  127. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  128. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  129. parentCallId: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  130. recordingId: 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  131. mediaUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/media',
  132. enqueuedTime: '2022-06-16T13:15:07.160Z',
  133. startTime: '2022-06-16T13:15:07.160Z',
  134. answerTime: '2022-06-16T13:15:18.126Z',
  135. endTime: '2022-06-16T13:17:07.160Z',
  136. duration: 'PT2M',
  137. fileFormat: Bandwidth::FileFormatEnum::WAV,
  138. channels: 1,
  139. tag: 'custom tag',
  140. transferCallerId: '+19195554321',
  141. transferTo: '+19195551234'
  142. })
  143. end
  144. end
  145. end

spec/unit/models/recording_state_enum_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RecordingStateEnum
  2. 1 describe Bandwidth::RecordingStateEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines PAUSED' do
  5. 1 expect(Bandwidth::RecordingStateEnum::PAUSED).to eq('paused')
  6. end
  7. 1 it 'defines RECORDING' do
  8. 1 expect(Bandwidth::RecordingStateEnum::RECORDING).to eq('recording')
  9. end
  10. end
  11. 1 describe '.all_vars' do
  12. 1 it 'returns every valid enum value' do
  13. 1 expect(Bandwidth::RecordingStateEnum.all_vars).to eq([
  14. 'paused',
  15. 'recording'
  16. ])
  17. end
  18. end
  19. 1 describe '.build_from_hash' do
  20. 1 it 'returns the value when it matches a valid enum value' do
  21. 1 expect(Bandwidth::RecordingStateEnum.build_from_hash('paused')).to eq('paused')
  22. 1 expect(Bandwidth::RecordingStateEnum.build_from_hash('recording')).to eq('recording')
  23. end
  24. 1 it 'raises an error for an invalid enum value' do
  25. 1 expect {
  26. 1 Bandwidth::RecordingStateEnum.build_from_hash('invalid')
  27. }.to raise_error(RuntimeError)
  28. end
  29. end
  30. end

spec/unit/models/recording_transcription_metadata_spec.rb

100.0% lines covered

34 relevant lines. 34 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RecordingTranscriptionMetadata
  2. 1 describe Bandwidth::RecordingTranscriptionMetadata do
  3. 2 let(:recording_transcription_metadata_default) { Bandwidth::RecordingTranscriptionMetadata.new }
  4. 4 let(:recording_transcription_metadata_values) { Bandwidth::RecordingTranscriptionMetadata.new({
  5. id: 't-3f758f24-c7a2fdac-7c2e-4d83-bf28-c7c1ed29563c',
  6. status: 'available',
  7. completed_time: '2022-06-17T22:21:30Z',
  8. url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/transcriptions/t-3f758f24-c7a2fdac-7c2e-4d83-bf28-c7c1ed29563c'
  9. }) }
  10. 1 describe '#initialize' do
  11. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  12. 1 expect {
  13. 1 Bandwidth::RecordingTranscriptionMetadata.new([])
  14. }.to raise_error(ArgumentError)
  15. end
  16. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  17. 1 expect {
  18. 1 Bandwidth::RecordingTranscriptionMetadata.new({ invalid: true })
  19. }.to raise_error(ArgumentError)
  20. end
  21. end
  22. 1 describe '#acceptable_attributes' do
  23. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  24. 1 expect(Bandwidth::RecordingTranscriptionMetadata.acceptable_attributes).to eq(Bandwidth::RecordingTranscriptionMetadata.attribute_map.values)
  25. end
  26. end
  27. 1 describe '#openapi_nullable' do
  28. 1 it 'expects nullable attributes to be an empty set' do
  29. 1 expect(Bandwidth::RecordingTranscriptionMetadata.openapi_nullable).to eq(Set.new([]))
  30. end
  31. end
  32. 1 describe '#build_from_hash' do
  33. 1 it 'validates instance of RecordingTranscriptionMetadata created by the build_from_hash method' do
  34. 1 recording_transcription_metadata_from_hash = Bandwidth::RecordingTranscriptionMetadata.build_from_hash({
  35. id: 't-3f758f24-c7a2fdac-7c2e-4d83-bf28-c7c1ed29563c',
  36. status: 'available',
  37. completedTime: '2022-06-17T22:21:30Z',
  38. url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/transcriptions/t-3f758f24-c7a2fdac-7c2e-4d83-bf28-c7c1ed29563c'
  39. })
  40. 1 expect(recording_transcription_metadata_from_hash).to be_instance_of(Bandwidth::RecordingTranscriptionMetadata)
  41. 1 expect(recording_transcription_metadata_from_hash.id).to eq('t-3f758f24-c7a2fdac-7c2e-4d83-bf28-c7c1ed29563c')
  42. 1 expect(recording_transcription_metadata_from_hash.status).to eq('available')
  43. 1 expect(recording_transcription_metadata_from_hash.completed_time).to eq(Time.parse('2022-06-17T22:21:30Z'))
  44. 1 expect(recording_transcription_metadata_from_hash.url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/transcriptions/t-3f758f24-c7a2fdac-7c2e-4d83-bf28-c7c1ed29563c')
  45. end
  46. end
  47. 1 describe '#to_s' do
  48. 1 it 'returns a string representation of the object' do
  49. 1 expect(recording_transcription_metadata_values.to_s).to eq('{:id=>"t-3f758f24-c7a2fdac-7c2e-4d83-bf28-c7c1ed29563c", :status=>"available", :completedTime=>"2022-06-17T22:21:30Z", :url=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/transcriptions/t-3f758f24-c7a2fdac-7c2e-4d83-bf28-c7c1ed29563c"}')
  50. end
  51. end
  52. 1 describe '#eq? #==' do
  53. 1 it 'returns true/false when comparing objects' do
  54. 1 expect(recording_transcription_metadata_default.eql?(Bandwidth::RecordingTranscriptionMetadata.new)).to be true
  55. 1 expect(recording_transcription_metadata_default.eql?(recording_transcription_metadata_values)).to be false
  56. end
  57. end
  58. 1 describe '#to_body #to_hash' do
  59. 1 it 'returns a hash representation of the object' do
  60. 1 expect(recording_transcription_metadata_values.to_body).to eq({
  61. id: 't-3f758f24-c7a2fdac-7c2e-4d83-bf28-c7c1ed29563c',
  62. status: 'available',
  63. completedTime: '2022-06-17T22:21:30Z',
  64. url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/transcriptions/t-3f758f24-c7a2fdac-7c2e-4d83-bf28-c7c1ed29563c'
  65. })
  66. end
  67. end
  68. end

spec/unit/models/recording_transcriptions_spec.rb

100.0% lines covered

34 relevant lines. 34 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RecordingTranscriptions
  2. 1 describe Bandwidth::RecordingTranscriptions do
  3. 2 let(:recording_transcriptions_default) { Bandwidth::RecordingTranscriptions.new }
  4. 4 let(:recording_transcriptions_values) { Bandwidth::RecordingTranscriptions.new({
  5. transcripts: [
  6. Bandwidth::Transcription.new({ text: 'Hello World! Thank you for calling.', confidence: 0.9 })
  7. ]
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::RecordingTranscriptions.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::RecordingTranscriptions.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::RecordingTranscriptions.acceptable_attributes).to eq(Bandwidth::RecordingTranscriptions.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be an empty set' do
  28. 1 expect(Bandwidth::RecordingTranscriptions.openapi_nullable).to eq(Set.new([]))
  29. end
  30. end
  31. 1 describe '#build_from_hash' do
  32. 1 it 'validates instance of RecordingTranscriptions created by the build_from_hash method' do
  33. 1 recording_transcriptions_from_hash = Bandwidth::RecordingTranscriptions.build_from_hash({
  34. transcripts: [{ text: 'Hello World! Thank you for calling.', confidence: 0.9 }]
  35. })
  36. 1 expect(recording_transcriptions_from_hash).to be_instance_of(Bandwidth::RecordingTranscriptions)
  37. 1 expect(recording_transcriptions_from_hash.transcripts).to be_instance_of(Array)
  38. 1 expect(recording_transcriptions_from_hash.transcripts.first).to be_instance_of(Bandwidth::Transcription)
  39. 1 expect(recording_transcriptions_from_hash.transcripts.first.text).to eq('Hello World! Thank you for calling.')
  40. 1 expect(recording_transcriptions_from_hash.transcripts.first.confidence).to eq(0.9)
  41. end
  42. end
  43. 1 describe '#to_s' do
  44. 1 it 'returns a string representation of the object' do
  45. 1 expect(recording_transcriptions_values.to_s).to eq('{:transcripts=>[{:text=>"Hello World! Thank you for calling.", :confidence=>0.9}]}')
  46. end
  47. end
  48. 1 describe '#eq? #==' do
  49. 1 it 'returns true/false when comparing objects' do
  50. 1 expect(recording_transcriptions_default.eql?(Bandwidth::RecordingTranscriptions.new)).to be true
  51. 1 expect(recording_transcriptions_default.eql?(recording_transcriptions_values)).to be false
  52. end
  53. end
  54. 1 describe '#to_body #to_hash' do
  55. 1 it 'returns a hash representation of the object' do
  56. 1 expect(recording_transcriptions_values.to_body).to eq({
  57. transcripts: [{ text: 'Hello World! Thank you for calling.', confidence: 0.9 }]
  58. })
  59. end
  60. end
  61. end

spec/unit/models/redirect_callback_spec.rb

100.0% lines covered

46 relevant lines. 46 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RedirectCallback
  2. 1 describe Bandwidth::RedirectCallback do
  3. 2 let(:redirect_callback_default) { Bandwidth::RedirectCallback.new }
  4. 4 let(:redirect_callback_values) { Bandwidth::RedirectCallback.new({
  5. event_type: 'redirect',
  6. event_time: '2022-06-16T13:15:07.160Z',
  7. account_id: '9900000',
  8. application_id: '04e88489-df02-4e34-a0ee-27a91849555f',
  9. from: '+19195554321',
  10. to: '+19195551234',
  11. direction: Bandwidth::CallDirectionEnum::INBOUND,
  12. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  13. call_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  14. parent_call_id: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  15. enqueued_time: '2022-06-16T13:15:07.160Z',
  16. start_time: '2022-06-16T13:15:07.160Z',
  17. answer_time: '2022-06-16T13:15:18.126Z',
  18. tag: 'custom tag',
  19. transfer_caller_id: '+19195554321',
  20. transfer_to: '+19195551234'
  21. }) }
  22. 1 describe '#initialize' do
  23. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  24. 1 expect {
  25. 1 Bandwidth::RedirectCallback.new([])
  26. }.to raise_error(ArgumentError)
  27. end
  28. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  29. 1 expect {
  30. 1 Bandwidth::RedirectCallback.new({ invalid: true })
  31. }.to raise_error(ArgumentError)
  32. end
  33. end
  34. 1 describe '#acceptable_attributes' do
  35. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  36. 1 expect(Bandwidth::RedirectCallback.acceptable_attributes).to eq(Bandwidth::RedirectCallback.attribute_map.values)
  37. end
  38. end
  39. 1 describe '#openapi_nullable' do
  40. 1 it 'expects nullable attributes to be the set of nullable fields' do
  41. 1 expect(Bandwidth::RedirectCallback.openapi_nullable).to eq(Set.new([
  42. :'enqueued_time',
  43. :'answer_time',
  44. :'tag'
  45. ]))
  46. end
  47. end
  48. 1 describe '#build_from_hash' do
  49. 1 it 'validates instance of RedirectCallback created by the build_from_hash method' do
  50. 1 redirect_callback_from_hash = Bandwidth::RedirectCallback.build_from_hash({
  51. eventType: 'redirect',
  52. eventTime: '2022-06-16T13:15:07.160Z',
  53. accountId: '9900000',
  54. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  55. from: '+19195554321',
  56. to: '+19195551234',
  57. direction: Bandwidth::CallDirectionEnum::INBOUND,
  58. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  59. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  60. parentCallId: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  61. enqueuedTime: '2022-06-16T13:15:07.160Z',
  62. startTime: '2022-06-16T13:15:07.160Z',
  63. answerTime: '2022-06-16T13:15:18.126Z',
  64. tag: 'custom tag',
  65. transferCallerId: '+19195554321',
  66. transferTo: '+19195551234'
  67. })
  68. 1 expect(redirect_callback_from_hash).to be_instance_of(Bandwidth::RedirectCallback)
  69. 1 expect(redirect_callback_from_hash.event_type).to eq('redirect')
  70. 1 expect(redirect_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  71. 1 expect(redirect_callback_from_hash.account_id).to eq('9900000')
  72. 1 expect(redirect_callback_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f')
  73. 1 expect(redirect_callback_from_hash.from).to eq('+19195554321')
  74. 1 expect(redirect_callback_from_hash.to).to eq('+19195551234')
  75. 1 expect(redirect_callback_from_hash.direction).to eq(Bandwidth::CallDirectionEnum::INBOUND)
  76. 1 expect(redirect_callback_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  77. 1 expect(redirect_callback_from_hash.call_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  78. 1 expect(redirect_callback_from_hash.parent_call_id).to eq('c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99')
  79. 1 expect(redirect_callback_from_hash.enqueued_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  80. 1 expect(redirect_callback_from_hash.start_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  81. 1 expect(redirect_callback_from_hash.answer_time).to eq(Time.parse('2022-06-16T13:15:18.126Z'))
  82. 1 expect(redirect_callback_from_hash.tag).to eq('custom tag')
  83. 1 expect(redirect_callback_from_hash.transfer_caller_id).to eq('+19195554321')
  84. 1 expect(redirect_callback_from_hash.transfer_to).to eq('+19195551234')
  85. end
  86. end
  87. 1 describe '#to_s' do
  88. 1 it 'returns a string representation of the object' do
  89. 1 expect(redirect_callback_values.to_s).to eq('{:eventType=>"redirect", :eventTime=>"2022-06-16T13:15:07.160Z", :accountId=>"9900000", :applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :from=>"+19195554321", :to=>"+19195551234", :direction=>"inbound", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :callUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :parentCallId=>"c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99", :enqueuedTime=>"2022-06-16T13:15:07.160Z", :startTime=>"2022-06-16T13:15:07.160Z", :answerTime=>"2022-06-16T13:15:18.126Z", :tag=>"custom tag", :transferCallerId=>"+19195554321", :transferTo=>"+19195551234"}')
  90. end
  91. end
  92. 1 describe '#eq? #==' do
  93. 1 it 'returns true/false when comparing objects' do
  94. 1 expect(redirect_callback_default.eql?(Bandwidth::RedirectCallback.new)).to be true
  95. 1 expect(redirect_callback_default.eql?(redirect_callback_values)).to be false
  96. end
  97. end
  98. 1 describe '#to_body #to_hash' do
  99. 1 it 'returns a hash representation of the object' do
  100. 1 expect(redirect_callback_values.to_body).to eq({
  101. eventType: 'redirect',
  102. eventTime: '2022-06-16T13:15:07.160Z',
  103. accountId: '9900000',
  104. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  105. from: '+19195554321',
  106. to: '+19195551234',
  107. direction: Bandwidth::CallDirectionEnum::INBOUND,
  108. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  109. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  110. parentCallId: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  111. enqueuedTime: '2022-06-16T13:15:07.160Z',
  112. startTime: '2022-06-16T13:15:07.160Z',
  113. answerTime: '2022-06-16T13:15:18.126Z',
  114. tag: 'custom tag',
  115. transferCallerId: '+19195554321',
  116. transferTo: '+19195551234'
  117. })
  118. end
  119. end
  120. end

spec/unit/models/redirect_method_enum_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::RedirectMethodEnum
  2. 1 describe Bandwidth::RedirectMethodEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines GET' do
  5. 1 expect(Bandwidth::RedirectMethodEnum::GET).to eq('GET')
  6. end
  7. 1 it 'defines POST' do
  8. 1 expect(Bandwidth::RedirectMethodEnum::POST).to eq('POST')
  9. end
  10. end
  11. 1 describe '.all_vars' do
  12. 1 it 'returns every valid enum value' do
  13. 1 expect(Bandwidth::RedirectMethodEnum.all_vars).to eq([
  14. 'GET',
  15. 'POST'
  16. ])
  17. end
  18. end
  19. 1 describe '.build_from_hash' do
  20. 1 it 'returns the value when it matches a valid enum value' do
  21. 1 expect(Bandwidth::RedirectMethodEnum.build_from_hash('GET')).to eq('GET')
  22. 1 expect(Bandwidth::RedirectMethodEnum.build_from_hash('POST')).to eq('POST')
  23. end
  24. 1 it 'raises an error for an invalid enum value' do
  25. 1 expect {
  26. 1 Bandwidth::RedirectMethodEnum.build_from_hash('invalid')
  27. }.to raise_error(RuntimeError)
  28. end
  29. end
  30. end

spec/unit/models/sip_connection_metadata_spec.rb

100.0% lines covered

36 relevant lines. 36 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::SipConnectionMetadata
  2. 1 describe Bandwidth::SipConnectionMetadata do
  3. 2 let(:sip_connection_metadata_default) { Bandwidth::SipConnectionMetadata.new }
  4. 4 let(:sip_connection_metadata_values) { Bandwidth::SipConnectionMetadata.new({
  5. ip_address: '192.168.1.1',
  6. port: 5060,
  7. credentials: Bandwidth::SipCredentials.new({ username: 'sipUser', password: 'sipPass' }),
  8. uui_header: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9'
  9. }) }
  10. 1 describe '#initialize' do
  11. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  12. 1 expect {
  13. 1 Bandwidth::SipConnectionMetadata.new([])
  14. }.to raise_error(ArgumentError)
  15. end
  16. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  17. 1 expect {
  18. 1 Bandwidth::SipConnectionMetadata.new({ invalid: true })
  19. }.to raise_error(ArgumentError)
  20. end
  21. end
  22. 1 describe '#acceptable_attributes' do
  23. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  24. 1 expect(Bandwidth::SipConnectionMetadata.acceptable_attributes).to eq(Bandwidth::SipConnectionMetadata.attribute_map.values)
  25. end
  26. end
  27. 1 describe '#openapi_nullable' do
  28. 1 it 'expects nullable attributes to be an empty set' do
  29. 1 expect(Bandwidth::SipConnectionMetadata.openapi_nullable).to eq(Set.new([]))
  30. end
  31. end
  32. 1 describe '#build_from_hash' do
  33. 1 it 'validates instance of SipConnectionMetadata created by the build_from_hash method' do
  34. 1 sip_connection_metadata_from_hash = Bandwidth::SipConnectionMetadata.build_from_hash({
  35. ipAddress: '192.168.1.1',
  36. port: 5060,
  37. credentials: { username: 'sipUser', password: 'sipPass' },
  38. uuiHeader: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9'
  39. })
  40. 1 expect(sip_connection_metadata_from_hash).to be_instance_of(Bandwidth::SipConnectionMetadata)
  41. 1 expect(sip_connection_metadata_from_hash.ip_address).to eq('192.168.1.1')
  42. 1 expect(sip_connection_metadata_from_hash.port).to eq(5060)
  43. 1 expect(sip_connection_metadata_from_hash.credentials).to be_instance_of(Bandwidth::SipCredentials)
  44. 1 expect(sip_connection_metadata_from_hash.credentials.username).to eq('sipUser')
  45. 1 expect(sip_connection_metadata_from_hash.credentials.password).to eq('sipPass')
  46. 1 expect(sip_connection_metadata_from_hash.uui_header).to eq('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9')
  47. end
  48. end
  49. 1 describe '#to_s' do
  50. 1 it 'returns a string representation of the object' do
  51. 1 expect(sip_connection_metadata_values.to_s).to eq('{:ipAddress=>"192.168.1.1", :port=>5060, :credentials=>{:username=>"sipUser", :password=>"sipPass"}, :uuiHeader=>"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9"}')
  52. end
  53. end
  54. 1 describe '#eq? #==' do
  55. 1 it 'returns true/false when comparing objects' do
  56. 1 expect(sip_connection_metadata_default.eql?(Bandwidth::SipConnectionMetadata.new)).to be true
  57. 1 expect(sip_connection_metadata_default.eql?(sip_connection_metadata_values)).to be false
  58. end
  59. end
  60. 1 describe '#to_body #to_hash' do
  61. 1 it 'returns a hash representation of the object' do
  62. 1 expect(sip_connection_metadata_values.to_body).to eq({
  63. ipAddress: '192.168.1.1',
  64. port: 5060,
  65. credentials: { username: 'sipUser', password: 'sipPass' },
  66. uuiHeader: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9'
  67. })
  68. end
  69. end
  70. end

spec/unit/models/sip_credentials_spec.rb

100.0% lines covered

32 relevant lines. 32 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::SipCredentials
  2. 1 describe Bandwidth::SipCredentials do
  3. 2 let(:sip_credentials_default) { Bandwidth::SipCredentials.new }
  4. 4 let(:sip_credentials_values) { Bandwidth::SipCredentials.new({
  5. username: 'sipUser',
  6. password: 'sipPass'
  7. }) }
  8. 1 describe '#initialize' do
  9. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  10. 1 expect {
  11. 1 Bandwidth::SipCredentials.new([])
  12. }.to raise_error(ArgumentError)
  13. end
  14. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  15. 1 expect {
  16. 1 Bandwidth::SipCredentials.new({ invalid: true })
  17. }.to raise_error(ArgumentError)
  18. end
  19. end
  20. 1 describe '#acceptable_attributes' do
  21. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  22. 1 expect(Bandwidth::SipCredentials.acceptable_attributes).to eq(Bandwidth::SipCredentials.attribute_map.values)
  23. end
  24. end
  25. 1 describe '#openapi_nullable' do
  26. 1 it 'expects nullable attributes to be an empty set' do
  27. 1 expect(Bandwidth::SipCredentials.openapi_nullable).to eq(Set.new([]))
  28. end
  29. end
  30. 1 describe '#build_from_hash' do
  31. 1 it 'validates instance of SipCredentials created by the build_from_hash method' do
  32. 1 sip_credentials_from_hash = Bandwidth::SipCredentials.build_from_hash({
  33. username: 'sipUser',
  34. password: 'sipPass'
  35. })
  36. 1 expect(sip_credentials_from_hash).to be_instance_of(Bandwidth::SipCredentials)
  37. 1 expect(sip_credentials_from_hash.username).to eq('sipUser')
  38. 1 expect(sip_credentials_from_hash.password).to eq('sipPass')
  39. end
  40. end
  41. 1 describe '#to_s' do
  42. 1 it 'returns a string representation of the object' do
  43. 1 expect(sip_credentials_values.to_s).to eq('{:username=>"sipUser", :password=>"sipPass"}')
  44. end
  45. end
  46. 1 describe '#eq? #==' do
  47. 1 it 'returns true/false when comparing objects' do
  48. 1 expect(sip_credentials_default.eql?(Bandwidth::SipCredentials.new)).to be true
  49. 1 expect(sip_credentials_default.eql?(sip_credentials_values)).to be false
  50. end
  51. end
  52. 1 describe '#to_body #to_hash' do
  53. 1 it 'returns a hash representation of the object' do
  54. 1 expect(sip_credentials_values.to_body).to eq({
  55. username: 'sipUser',
  56. password: 'sipPass'
  57. })
  58. end
  59. end
  60. end

spec/unit/models/sms_message_content_spec.rb

100.0% lines covered

38 relevant lines. 38 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::SmsMessageContent
  2. 1 describe Bandwidth::SmsMessageContent do
  3. 2 let(:sms_message_content_default) { Bandwidth::SmsMessageContent.new({
  4. text: 'baseline'
  5. }) }
  6. 4 let(:sms_message_content_values) { Bandwidth::SmsMessageContent.new({
  7. text: 'Hello world'
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::SmsMessageContent.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::SmsMessageContent.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::SmsMessageContent.acceptable_attributes).to eq(Bandwidth::SmsMessageContent.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be an empty set' do
  28. 1 expect(Bandwidth::SmsMessageContent.openapi_nullable).to eq(Set.new([]))
  29. end
  30. end
  31. 1 describe '#build_from_hash' do
  32. 1 it 'validates instance of SmsMessageContent created by the build_from_hash method' do
  33. 1 sms_message_content_from_hash = Bandwidth::SmsMessageContent.build_from_hash({
  34. text: 'Hello world'
  35. })
  36. 1 expect(sms_message_content_from_hash).to be_instance_of(Bandwidth::SmsMessageContent)
  37. 1 expect(sms_message_content_from_hash.text).to eq('Hello world')
  38. end
  39. end
  40. 1 describe '#to_s' do
  41. 1 it 'returns a string representation of the object' do
  42. 1 expect(sms_message_content_values.to_s).to eq('{:text=>"Hello world"}')
  43. end
  44. end
  45. 1 describe '#eq? #==' do
  46. 1 it 'returns true/false when comparing objects' do
  47. 1 sms_message_content_equal = Bandwidth::SmsMessageContent.new({
  48. text: 'baseline'
  49. })
  50. 1 expect(sms_message_content_default.eql?(sms_message_content_equal)).to be true
  51. 1 expect(sms_message_content_default.eql?(sms_message_content_values)).to be false
  52. end
  53. end
  54. 1 describe '#to_body #to_hash' do
  55. 1 it 'returns a hash representation of the object' do
  56. 1 expect(sms_message_content_values.to_body).to eq({
  57. text: 'Hello world'
  58. })
  59. end
  60. end
  61. 1 describe 'custom attribute writers' do
  62. 1 it '#text=' do
  63. 1 expect {
  64. 1 Bandwidth::SmsMessageContent.new({ text: nil })
  65. }.to raise_error(ArgumentError, 'text cannot be nil')
  66. 1 expect {
  67. 1 Bandwidth::SmsMessageContent.new({ text: 'a' * 2049 })
  68. }.to raise_error(ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 2048.')
  69. end
  70. end
  71. end

spec/unit/models/standalone_card_orientation_enum_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::StandaloneCardOrientationEnum
  2. 1 describe Bandwidth::StandaloneCardOrientationEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines HORIZONTAL' do
  5. 1 expect(Bandwidth::StandaloneCardOrientationEnum::HORIZONTAL).to eq('HORIZONTAL')
  6. end
  7. 1 it 'defines VERTICAL' do
  8. 1 expect(Bandwidth::StandaloneCardOrientationEnum::VERTICAL).to eq('VERTICAL')
  9. end
  10. end
  11. 1 describe '.all_vars' do
  12. 1 it 'returns every valid enum value' do
  13. 1 expect(Bandwidth::StandaloneCardOrientationEnum.all_vars).to eq([
  14. 'HORIZONTAL',
  15. 'VERTICAL'
  16. ])
  17. end
  18. end
  19. 1 describe '.build_from_hash' do
  20. 1 it 'returns the value when it matches a valid enum value' do
  21. 1 expect(Bandwidth::StandaloneCardOrientationEnum.build_from_hash('HORIZONTAL')).to eq('HORIZONTAL')
  22. 1 expect(Bandwidth::StandaloneCardOrientationEnum.build_from_hash('VERTICAL')).to eq('VERTICAL')
  23. end
  24. 1 it 'raises an error for an invalid enum value' do
  25. 1 expect {
  26. 1 Bandwidth::StandaloneCardOrientationEnum.build_from_hash('invalid')
  27. }.to raise_error(RuntimeError)
  28. end
  29. end
  30. end

spec/unit/models/status_callback_message_spec.rb

100.0% lines covered

69 relevant lines. 69 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::StatusCallbackMessage
  2. 1 describe Bandwidth::StatusCallbackMessage do
  3. 2 let(:status_callback_message_default) { Bandwidth::StatusCallbackMessage.new({
  4. id: 'baseline-id',
  5. owner: '+19195554321',
  6. application_id: 'baseline-app',
  7. time: '2022-06-16T13:15:07.160Z',
  8. segment_count: 1,
  9. direction: Bandwidth::MessageDirectionEnum::OUT,
  10. to: ['+19195551234'],
  11. from: '+19195554321'
  12. }) }
  13. 12 let(:status_callback_message_values) { Bandwidth::StatusCallbackMessage.new({
  14. id: '1589228074636lm4k2je7j7jklbn2',
  15. owner: '+19195554321',
  16. application_id: '93de2206-9669-4e07-948d-329f4b722ee2',
  17. time: '2022-06-16T13:15:07.160Z',
  18. segment_count: 2,
  19. direction: Bandwidth::MessageDirectionEnum::OUT,
  20. to: ['+19195551234'],
  21. from: '+19195554321',
  22. text: 'Hello world',
  23. tag: 'custom tag',
  24. media: ['https://dev.bandwidth.com/images/bandwidth-logo.png'],
  25. priority: Bandwidth::PriorityEnum::DEFAULT,
  26. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS
  27. }) }
  28. 1 describe '#initialize' do
  29. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  30. 1 expect {
  31. 1 Bandwidth::StatusCallbackMessage.new([])
  32. }.to raise_error(ArgumentError)
  33. end
  34. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  35. 1 expect {
  36. 1 Bandwidth::StatusCallbackMessage.new({ invalid: true })
  37. }.to raise_error(ArgumentError)
  38. end
  39. end
  40. 1 describe '#acceptable_attributes' do
  41. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  42. 1 expect(Bandwidth::StatusCallbackMessage.acceptable_attributes).to eq(Bandwidth::StatusCallbackMessage.attribute_map.values)
  43. end
  44. end
  45. 1 describe '#openapi_nullable' do
  46. 1 it 'expects nullable attributes to be an empty set' do
  47. 1 expect(Bandwidth::StatusCallbackMessage.openapi_nullable).to eq(Set.new([]))
  48. end
  49. end
  50. 1 describe '#build_from_hash' do
  51. 1 it 'validates instance of StatusCallbackMessage created by the build_from_hash method' do
  52. 1 status_callback_message_from_hash = Bandwidth::StatusCallbackMessage.build_from_hash({
  53. id: '1589228074636lm4k2je7j7jklbn2',
  54. owner: '+19195554321',
  55. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  56. time: '2022-06-16T13:15:07.160Z',
  57. segmentCount: 2,
  58. direction: Bandwidth::MessageDirectionEnum::OUT,
  59. to: ['+19195551234'],
  60. from: '+19195554321',
  61. text: 'Hello world',
  62. tag: 'custom tag',
  63. media: ['https://dev.bandwidth.com/images/bandwidth-logo.png'],
  64. priority: Bandwidth::PriorityEnum::DEFAULT,
  65. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS
  66. })
  67. 1 expect(status_callback_message_from_hash).to be_instance_of(Bandwidth::StatusCallbackMessage)
  68. 1 expect(status_callback_message_from_hash.id).to eq('1589228074636lm4k2je7j7jklbn2')
  69. 1 expect(status_callback_message_from_hash.owner).to eq('+19195554321')
  70. 1 expect(status_callback_message_from_hash.application_id).to eq('93de2206-9669-4e07-948d-329f4b722ee2')
  71. 1 expect(status_callback_message_from_hash.time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  72. 1 expect(status_callback_message_from_hash.segment_count).to eq(2)
  73. 1 expect(status_callback_message_from_hash.direction).to eq(Bandwidth::MessageDirectionEnum::OUT)
  74. 1 expect(status_callback_message_from_hash.to).to eq(['+19195551234'])
  75. 1 expect(status_callback_message_from_hash.from).to eq('+19195554321')
  76. 1 expect(status_callback_message_from_hash.text).to eq('Hello world')
  77. 1 expect(status_callback_message_from_hash.tag).to eq('custom tag')
  78. 1 expect(status_callback_message_from_hash.media).to eq(['https://dev.bandwidth.com/images/bandwidth-logo.png'])
  79. 1 expect(status_callback_message_from_hash.priority).to eq(Bandwidth::PriorityEnum::DEFAULT)
  80. 1 expect(status_callback_message_from_hash.channel).to eq(Bandwidth::MultiChannelMessageChannelEnum::SMS)
  81. end
  82. end
  83. 1 describe '#to_s' do
  84. 1 it 'returns a string representation of the object' do
  85. 1 expect(status_callback_message_values.to_s).to eq('{:id=>"1589228074636lm4k2je7j7jklbn2", :owner=>"+19195554321", :applicationId=>"93de2206-9669-4e07-948d-329f4b722ee2", :time=>"2022-06-16T13:15:07.160Z", :segmentCount=>2, :direction=>"out", :to=>["+19195551234"], :from=>"+19195554321", :text=>"Hello world", :tag=>"custom tag", :media=>["https://dev.bandwidth.com/images/bandwidth-logo.png"], :priority=>"default", :channel=>"SMS"}')
  86. end
  87. end
  88. 1 describe '#eq? #==' do
  89. 1 it 'returns true/false when comparing objects' do
  90. 1 status_callback_message_equal = Bandwidth::StatusCallbackMessage.new({
  91. id: 'baseline-id',
  92. owner: '+19195554321',
  93. application_id: 'baseline-app',
  94. time: '2022-06-16T13:15:07.160Z',
  95. segment_count: 1,
  96. direction: Bandwidth::MessageDirectionEnum::OUT,
  97. to: ['+19195551234'],
  98. from: '+19195554321'
  99. })
  100. 1 expect(status_callback_message_default.eql?(status_callback_message_equal)).to be true
  101. 1 expect(status_callback_message_default.eql?(status_callback_message_values)).to be false
  102. end
  103. end
  104. 1 describe '#to_body #to_hash' do
  105. 1 it 'returns a hash representation of the object' do
  106. 1 expect(status_callback_message_values.to_body).to eq({
  107. id: '1589228074636lm4k2je7j7jklbn2',
  108. owner: '+19195554321',
  109. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  110. time: '2022-06-16T13:15:07.160Z',
  111. segmentCount: 2,
  112. direction: Bandwidth::MessageDirectionEnum::OUT,
  113. to: ['+19195551234'],
  114. from: '+19195554321',
  115. text: 'Hello world',
  116. tag: 'custom tag',
  117. media: ['https://dev.bandwidth.com/images/bandwidth-logo.png'],
  118. priority: Bandwidth::PriorityEnum::DEFAULT,
  119. channel: Bandwidth::MultiChannelMessageChannelEnum::SMS
  120. })
  121. end
  122. end
  123. 1 describe 'custom attribute writers' do
  124. 1 it '#id=' do
  125. 1 expect {
  126. 1 status_callback_message_values.id = nil
  127. }.to raise_error(ArgumentError, 'id cannot be nil')
  128. end
  129. 1 it '#owner=' do
  130. 1 expect {
  131. 1 status_callback_message_values.owner = nil
  132. }.to raise_error(ArgumentError, 'owner cannot be nil')
  133. end
  134. 1 it '#application_id=' do
  135. 1 expect {
  136. 1 status_callback_message_values.application_id = nil
  137. }.to raise_error(ArgumentError, 'application_id cannot be nil')
  138. end
  139. 1 it '#time=' do
  140. 1 expect {
  141. 1 status_callback_message_values.time = nil
  142. }.to raise_error(ArgumentError, 'time cannot be nil')
  143. end
  144. 1 it '#segment_count=' do
  145. 1 expect {
  146. 1 status_callback_message_values.segment_count = nil
  147. }.to raise_error(ArgumentError, 'segment_count cannot be nil')
  148. end
  149. 1 it '#direction=' do
  150. 1 expect {
  151. 1 status_callback_message_values.direction = nil
  152. }.to raise_error(ArgumentError, 'direction cannot be nil')
  153. end
  154. 1 it '#to=' do
  155. 1 expect {
  156. 1 status_callback_message_values.to = nil
  157. }.to raise_error(ArgumentError, 'to cannot be nil')
  158. end
  159. 1 it '#from=' do
  160. 1 expect {
  161. 1 status_callback_message_values.from = nil
  162. }.to raise_error(ArgumentError, 'from cannot be nil')
  163. end
  164. end
  165. end

spec/unit/models/status_callback_spec.rb

100.0% lines covered

57 relevant lines. 57 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::StatusCallback
  2. 1 describe Bandwidth::StatusCallback do
  3. 2 let(:status_callback_default) { Bandwidth::StatusCallback.new({
  4. time: '2022-06-16T13:15:07.160Z',
  5. type: Bandwidth::StatusCallbackTypeEnum::MESSAGE_DELIVERED,
  6. to: '+19195551234',
  7. description: 'baseline description',
  8. message: { id: 'baseline' }
  9. }) }
  10. 9 let(:status_callback_values) { Bandwidth::StatusCallback.new({
  11. time: '2022-06-16T13:15:07.160Z',
  12. event_time: '2022-06-16T13:16:07.160Z',
  13. type: Bandwidth::StatusCallbackTypeEnum::MESSAGE_DELIVERED,
  14. to: '+19195551234',
  15. description: 'Message delivered to carrier',
  16. message: {
  17. id: '1589228074636lm4k2je7j7jklbn2',
  18. owner: '+19195554321',
  19. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  20. time: '2022-06-16T13:15:07.160Z',
  21. segmentCount: 1,
  22. direction: 'out',
  23. to: ['+19195551234'],
  24. from: '+19195554321',
  25. text: 'Hello world'
  26. },
  27. error_code: 0,
  28. carrier_name: 'Verizon'
  29. }) }
  30. 1 describe '#initialize' do
  31. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  32. 1 expect {
  33. 1 Bandwidth::StatusCallback.new([])
  34. }.to raise_error(ArgumentError)
  35. end
  36. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  37. 1 expect {
  38. 1 Bandwidth::StatusCallback.new({ invalid: true })
  39. }.to raise_error(ArgumentError)
  40. end
  41. end
  42. 1 describe '#acceptable_attributes' do
  43. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  44. 1 expect(Bandwidth::StatusCallback.acceptable_attributes).to eq(Bandwidth::StatusCallback.attribute_map.values)
  45. end
  46. end
  47. 1 describe '#openapi_nullable' do
  48. 1 it 'expects nullable attributes to be an empty set' do
  49. 1 expect(Bandwidth::StatusCallback.openapi_nullable).to eq(Set.new([]))
  50. end
  51. end
  52. 1 describe '#build_from_hash' do
  53. 1 it 'validates instance of StatusCallback created by the build_from_hash method' do
  54. 1 status_callback_from_hash = Bandwidth::StatusCallback.build_from_hash({
  55. time: '2022-06-16T13:15:07.160Z',
  56. eventTime: '2022-06-16T13:16:07.160Z',
  57. type: Bandwidth::StatusCallbackTypeEnum::MESSAGE_DELIVERED,
  58. to: '+19195551234',
  59. description: 'Message delivered to carrier',
  60. message: {
  61. id: '1589228074636lm4k2je7j7jklbn2',
  62. owner: '+19195554321',
  63. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  64. time: '2022-06-16T13:15:07.160Z',
  65. segmentCount: 1,
  66. direction: Bandwidth::MessageDirectionEnum::OUT,
  67. to: ['+19195551234'],
  68. from: '+19195554321',
  69. text: 'Hello world'
  70. },
  71. errorCode: 0,
  72. carrierName: 'Verizon'
  73. })
  74. 1 expect(status_callback_from_hash).to be_instance_of(Bandwidth::StatusCallback)
  75. 1 expect(status_callback_from_hash.time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  76. 1 expect(status_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:16:07.160Z'))
  77. 1 expect(status_callback_from_hash.type).to eq(Bandwidth::StatusCallbackTypeEnum::MESSAGE_DELIVERED)
  78. 1 expect(status_callback_from_hash.to).to eq('+19195551234')
  79. 1 expect(status_callback_from_hash.description).to eq('Message delivered to carrier')
  80. 1 expect(status_callback_from_hash.message).to be_instance_of(Bandwidth::StatusCallbackMessage)
  81. 1 expect(status_callback_from_hash.message.id).to eq('1589228074636lm4k2je7j7jklbn2')
  82. 1 expect(status_callback_from_hash.message.text).to eq('Hello world')
  83. 1 expect(status_callback_from_hash.error_code).to eq(0)
  84. 1 expect(status_callback_from_hash.carrier_name).to eq('Verizon')
  85. end
  86. end
  87. 1 describe '#to_s' do
  88. 1 it 'returns a string representation of the object' do
  89. 1 expect(status_callback_values.to_s).to eq('{:time=>"2022-06-16T13:15:07.160Z", :eventTime=>"2022-06-16T13:16:07.160Z", :type=>"message-delivered", :to=>"+19195551234", :description=>"Message delivered to carrier", :message=>{:id=>"1589228074636lm4k2je7j7jklbn2", :owner=>"+19195554321", :applicationId=>"93de2206-9669-4e07-948d-329f4b722ee2", :time=>"2022-06-16T13:15:07.160Z", :segmentCount=>1, :direction=>"out", :to=>["+19195551234"], :from=>"+19195554321", :text=>"Hello world"}, :errorCode=>0, :carrierName=>"Verizon"}')
  90. end
  91. end
  92. 1 describe '#eq? #==' do
  93. 1 it 'returns true/false when comparing objects' do
  94. 1 status_callback_equal = Bandwidth::StatusCallback.new({
  95. time: '2022-06-16T13:15:07.160Z',
  96. type: Bandwidth::StatusCallbackTypeEnum::MESSAGE_DELIVERED,
  97. to: '+19195551234',
  98. description: 'baseline description',
  99. message: { id: 'baseline' }
  100. })
  101. 1 expect(status_callback_default.eql?(status_callback_equal)).to be true
  102. 1 expect(status_callback_default.eql?(status_callback_values)).to be false
  103. end
  104. end
  105. 1 describe '#to_body #to_hash' do
  106. 1 it 'returns a hash representation of the object' do
  107. 1 expect(status_callback_values.to_body).to eq({
  108. time: '2022-06-16T13:15:07.160Z',
  109. eventTime: '2022-06-16T13:16:07.160Z',
  110. type: Bandwidth::StatusCallbackTypeEnum::MESSAGE_DELIVERED,
  111. to: '+19195551234',
  112. description: 'Message delivered to carrier',
  113. message: {
  114. id: '1589228074636lm4k2je7j7jklbn2',
  115. owner: '+19195554321',
  116. applicationId: '93de2206-9669-4e07-948d-329f4b722ee2',
  117. time: '2022-06-16T13:15:07.160Z',
  118. segmentCount: 1,
  119. direction: 'out',
  120. to: ['+19195551234'],
  121. from: '+19195554321',
  122. text: 'Hello world'
  123. },
  124. errorCode: 0,
  125. carrierName: 'Verizon'
  126. })
  127. end
  128. end
  129. 1 describe 'custom attribute writers' do
  130. 1 it '#time=' do
  131. 1 expect {
  132. 1 status_callback_values.time = nil
  133. }.to raise_error(ArgumentError, 'time cannot be nil')
  134. end
  135. 1 it '#type=' do
  136. 1 expect {
  137. 1 status_callback_values.type = nil
  138. }.to raise_error(ArgumentError, 'type cannot be nil')
  139. end
  140. 1 it '#to=' do
  141. 1 expect {
  142. 1 status_callback_values.to = nil
  143. }.to raise_error(ArgumentError, 'to cannot be nil')
  144. end
  145. 1 it '#description=' do
  146. 1 expect {
  147. 1 status_callback_values.description = nil
  148. }.to raise_error(ArgumentError, 'description cannot be nil')
  149. end
  150. 1 it '#message=' do
  151. 1 expect {
  152. 1 status_callback_values.message = nil
  153. }.to raise_error(ArgumentError, 'message cannot be nil')
  154. end
  155. end
  156. end

spec/unit/models/status_callback_type_enum_spec.rb

100.0% lines covered

22 relevant lines. 22 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::StatusCallbackTypeEnum
  2. 1 describe Bandwidth::StatusCallbackTypeEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines MESSAGE_SENDING' do
  5. 1 expect(Bandwidth::StatusCallbackTypeEnum::MESSAGE_SENDING).to eq('message-sending')
  6. end
  7. 1 it 'defines MESSAGE_DELIVERED' do
  8. 1 expect(Bandwidth::StatusCallbackTypeEnum::MESSAGE_DELIVERED).to eq('message-delivered')
  9. end
  10. 1 it 'defines MESSAGE_FAILED' do
  11. 1 expect(Bandwidth::StatusCallbackTypeEnum::MESSAGE_FAILED).to eq('message-failed')
  12. end
  13. 1 it 'defines MESSAGE_READ' do
  14. 1 expect(Bandwidth::StatusCallbackTypeEnum::MESSAGE_READ).to eq('message-read')
  15. end
  16. end
  17. 1 describe '.all_vars' do
  18. 1 it 'returns every valid enum value' do
  19. 1 expect(Bandwidth::StatusCallbackTypeEnum.all_vars).to eq([
  20. 'message-sending',
  21. 'message-delivered',
  22. 'message-failed',
  23. 'message-read'
  24. ])
  25. end
  26. end
  27. 1 describe '.build_from_hash' do
  28. 1 it 'returns the value when it matches a valid enum value' do
  29. 1 expect(Bandwidth::StatusCallbackTypeEnum.build_from_hash('message-sending')).to eq('message-sending')
  30. 1 expect(Bandwidth::StatusCallbackTypeEnum.build_from_hash('message-delivered')).to eq('message-delivered')
  31. 1 expect(Bandwidth::StatusCallbackTypeEnum.build_from_hash('message-failed')).to eq('message-failed')
  32. 1 expect(Bandwidth::StatusCallbackTypeEnum.build_from_hash('message-read')).to eq('message-read')
  33. end
  34. 1 it 'raises an error for an invalid enum value' do
  35. 1 expect {
  36. 1 Bandwidth::StatusCallbackTypeEnum.build_from_hash('invalid')
  37. }.to raise_error(RuntimeError)
  38. end
  39. end
  40. end

spec/unit/models/stir_shaken_spec.rb

100.0% lines covered

33 relevant lines. 33 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::StirShaken
  2. 1 describe Bandwidth::StirShaken do
  3. 2 let(:stir_shaken_default) { Bandwidth::StirShaken.new }
  4. 4 let(:stir_shaken_values) { Bandwidth::StirShaken.new({
  5. verstat: 'TN-Validation-Passed',
  6. attestation_indicator: 'A',
  7. originating_id: '99759086-1335-11ed-9bcf-5f7d464e91af'
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::StirShaken.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::StirShaken.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::StirShaken.acceptable_attributes).to eq(Bandwidth::StirShaken.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be an empty set' do
  28. 1 expect(Bandwidth::StirShaken.openapi_nullable).to eq(Set.new([]))
  29. end
  30. end
  31. 1 describe '#build_from_hash' do
  32. 1 it 'validates instance of StirShaken created by the build_from_hash method' do
  33. 1 stir_shaken_from_hash = Bandwidth::StirShaken.build_from_hash({
  34. verstat: 'TN-Validation-Passed',
  35. attestationIndicator: 'A',
  36. originatingId: '99759086-1335-11ed-9bcf-5f7d464e91af'
  37. })
  38. 1 expect(stir_shaken_from_hash).to be_instance_of(Bandwidth::StirShaken)
  39. 1 expect(stir_shaken_from_hash.verstat).to eq('TN-Validation-Passed')
  40. 1 expect(stir_shaken_from_hash.attestation_indicator).to eq('A')
  41. 1 expect(stir_shaken_from_hash.originating_id).to eq('99759086-1335-11ed-9bcf-5f7d464e91af')
  42. end
  43. end
  44. 1 describe '#to_s' do
  45. 1 it 'returns a string representation of the object' do
  46. 1 expect(stir_shaken_values.to_s).to eq('{:verstat=>"TN-Validation-Passed", :attestationIndicator=>"A", :originatingId=>"99759086-1335-11ed-9bcf-5f7d464e91af"}')
  47. end
  48. end
  49. 1 describe '#eq? #==' do
  50. 1 it 'returns true/false when comparing objects' do
  51. 1 expect(stir_shaken_default.eql?(Bandwidth::StirShaken.new)).to be true
  52. 1 expect(stir_shaken_default.eql?(stir_shaken_values)).to be false
  53. end
  54. end
  55. 1 describe '#to_body #to_hash' do
  56. 1 it 'returns a hash representation of the object' do
  57. 1 expect(stir_shaken_values.to_body).to eq({
  58. verstat: 'TN-Validation-Passed',
  59. attestationIndicator: 'A',
  60. originatingId: '99759086-1335-11ed-9bcf-5f7d464e91af'
  61. })
  62. end
  63. end
  64. end

spec/unit/models/sync_lookup_request_spec.rb

100.0% lines covered

42 relevant lines. 42 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::SyncLookupRequest
  2. 1 describe Bandwidth::SyncLookupRequest do
  3. 2 let(:sync_lookup_request_default) { Bandwidth::SyncLookupRequest.new({
  4. phone_numbers: ['+19195551234']
  5. }) }
  6. 5 let(:sync_lookup_request_values) { Bandwidth::SyncLookupRequest.new({
  7. phone_numbers: ['+19195551234', '+19195554321'],
  8. rcs_agent: 'my_agent'
  9. }) }
  10. 1 describe '#initialize' do
  11. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  12. 1 expect {
  13. 1 Bandwidth::SyncLookupRequest.new([])
  14. }.to raise_error(ArgumentError)
  15. end
  16. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  17. 1 expect {
  18. 1 Bandwidth::SyncLookupRequest.new({ invalid: true })
  19. }.to raise_error(ArgumentError)
  20. end
  21. end
  22. 1 describe '#acceptable_attributes' do
  23. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  24. 1 expect(Bandwidth::SyncLookupRequest.acceptable_attributes).to eq(Bandwidth::SyncLookupRequest.attribute_map.values)
  25. end
  26. end
  27. 1 describe '#openapi_nullable' do
  28. 1 it 'expects nullable attributes to be an empty set' do
  29. 1 expect(Bandwidth::SyncLookupRequest.openapi_nullable).to eq(Set.new([]))
  30. end
  31. end
  32. 1 describe '#build_from_hash' do
  33. 1 it 'validates instance of SyncLookupRequest created by the build_from_hash method' do
  34. 1 sync_lookup_request_from_hash = Bandwidth::SyncLookupRequest.build_from_hash({
  35. phoneNumbers: ['+19195551234', '+19195554321'],
  36. rcsAgent: 'my_agent'
  37. })
  38. 1 expect(sync_lookup_request_from_hash).to be_instance_of(Bandwidth::SyncLookupRequest)
  39. 1 expect(sync_lookup_request_from_hash.phone_numbers).to eq(['+19195551234', '+19195554321'])
  40. 1 expect(sync_lookup_request_from_hash.rcs_agent).to eq('my_agent')
  41. end
  42. end
  43. 1 describe '#to_s' do
  44. 1 it 'returns a string representation of the object' do
  45. 1 expect(sync_lookup_request_values.to_s).to eq('{:phoneNumbers=>["+19195551234", "+19195554321"], :rcsAgent=>"my_agent"}')
  46. end
  47. end
  48. 1 describe '#eq? #==' do
  49. 1 it 'returns true/false when comparing objects' do
  50. 1 sync_lookup_request_equal = Bandwidth::SyncLookupRequest.new({
  51. phone_numbers: ['+19195551234']
  52. })
  53. 1 expect(sync_lookup_request_default.eql?(sync_lookup_request_equal)).to be true
  54. 1 expect(sync_lookup_request_default.eql?(sync_lookup_request_values)).to be false
  55. end
  56. end
  57. 1 describe '#to_body #to_hash' do
  58. 1 it 'returns a hash representation of the object' do
  59. 1 expect(sync_lookup_request_values.to_body).to eq({
  60. phoneNumbers: ['+19195551234', '+19195554321'],
  61. rcsAgent: 'my_agent'
  62. })
  63. end
  64. end
  65. 1 describe 'custom attribute writers' do
  66. 1 it '#phone_numbers=' do
  67. 1 expect {
  68. 1 sync_lookup_request_values.phone_numbers = nil
  69. }.to raise_error(ArgumentError, 'phone_numbers cannot be nil')
  70. end
  71. 1 it '#rcs_agent=' do
  72. 1 expect {
  73. 1 Bandwidth::SyncLookupRequest.new({ phone_numbers: ['+19195551234'], rcs_agent: nil })
  74. }.to raise_error(ArgumentError, 'rcs_agent cannot be nil')
  75. 1 expect {
  76. 1 Bandwidth::SyncLookupRequest.new({ phone_numbers: ['+19195551234'], rcs_agent: 'invalid agent!' })
  77. }.to raise_error(ArgumentError, 'invalid value for "rcs_agent", must conform to the pattern (?-mix:^[A-Za-z0-9_-]{1,40}$).')
  78. end
  79. end
  80. end

spec/unit/models/telephone_number_spec.rb

100.0% lines covered

31 relevant lines. 31 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::TelephoneNumber
  2. 1 describe Bandwidth::TelephoneNumber do
  3. 2 let(:telephone_number_default) { Bandwidth::TelephoneNumber.new }
  4. 4 let(:telephone_number_values) { Bandwidth::TelephoneNumber.new({
  5. telephone_number: '+19195551234'
  6. }) }
  7. 1 describe '#initialize' do
  8. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  9. 1 expect {
  10. 1 Bandwidth::TelephoneNumber.new([])
  11. }.to raise_error(ArgumentError)
  12. end
  13. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  14. 1 expect {
  15. 1 Bandwidth::TelephoneNumber.new({ invalid: true })
  16. }.to raise_error(ArgumentError)
  17. end
  18. end
  19. 1 describe '#acceptable_attributes' do
  20. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  21. 1 expect(Bandwidth::TelephoneNumber.acceptable_attributes).to eq(Bandwidth::TelephoneNumber.attribute_map.values)
  22. end
  23. end
  24. 1 describe '#openapi_nullable' do
  25. 1 it 'expects nullable attributes to be an empty set' do
  26. 1 expect(Bandwidth::TelephoneNumber.openapi_nullable).to eq(Set.new([]))
  27. end
  28. end
  29. 1 describe '#build_from_hash' do
  30. 1 it 'validates instance of TelephoneNumber created by the build_from_hash method' do
  31. 1 telephone_number_from_hash = Bandwidth::TelephoneNumber.build_from_hash({
  32. telephoneNumber: '+19195551234'
  33. })
  34. 1 expect(telephone_number_from_hash).to be_instance_of(Bandwidth::TelephoneNumber)
  35. 1 expect(telephone_number_from_hash.telephone_number).to eq('+19195551234')
  36. end
  37. end
  38. 1 describe '#to_s' do
  39. 1 it 'returns a string representation of the object' do
  40. 1 expect(telephone_number_values.to_s).to eq('{:telephoneNumber=>"+19195551234"}')
  41. end
  42. end
  43. 1 describe '#eq? #==' do
  44. 1 it 'returns true/false when comparing objects' do
  45. 1 expect(telephone_number_default.eql?(Bandwidth::TelephoneNumber.new)).to be true
  46. 1 expect(telephone_number_default.eql?(telephone_number_values)).to be false
  47. end
  48. end
  49. 1 describe '#to_body #to_hash' do
  50. 1 it 'returns a hash representation of the object' do
  51. 1 expect(telephone_number_values.to_body).to eq({
  52. telephoneNumber: '+19195551234'
  53. })
  54. end
  55. end
  56. end

spec/unit/models/tfv_basic_authentication_spec.rb

100.0% lines covered

44 relevant lines. 44 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::TfvBasicAuthentication
  2. 1 describe Bandwidth::TfvBasicAuthentication do
  3. 2 let(:tfv_basic_authentication_default) { Bandwidth::TfvBasicAuthentication.new({
  4. username: 'baseline',
  5. password: 'baselinePass'
  6. }) }
  7. 4 let(:tfv_basic_authentication_values) { Bandwidth::TfvBasicAuthentication.new({
  8. username: 'mySecretUsername',
  9. password: 'mySecretPassword'
  10. }) }
  11. 1 describe '#initialize' do
  12. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  13. 1 expect {
  14. 1 Bandwidth::TfvBasicAuthentication.new([])
  15. }.to raise_error(ArgumentError)
  16. end
  17. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  18. 1 expect {
  19. 1 Bandwidth::TfvBasicAuthentication.new({ invalid: true })
  20. }.to raise_error(ArgumentError)
  21. end
  22. end
  23. 1 describe '#acceptable_attributes' do
  24. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  25. 1 expect(Bandwidth::TfvBasicAuthentication.acceptable_attributes).to eq(Bandwidth::TfvBasicAuthentication.attribute_map.values)
  26. end
  27. end
  28. 1 describe '#openapi_nullable' do
  29. 1 it 'expects nullable attributes to be an empty set' do
  30. 1 expect(Bandwidth::TfvBasicAuthentication.openapi_nullable).to eq(Set.new([]))
  31. end
  32. end
  33. 1 describe '#build_from_hash' do
  34. 1 it 'validates instance of TfvBasicAuthentication created by the build_from_hash method' do
  35. 1 tfv_basic_authentication_from_hash = Bandwidth::TfvBasicAuthentication.build_from_hash({
  36. username: 'mySecretUsername',
  37. password: 'mySecretPassword'
  38. })
  39. 1 expect(tfv_basic_authentication_from_hash).to be_instance_of(Bandwidth::TfvBasicAuthentication)
  40. 1 expect(tfv_basic_authentication_from_hash.username).to eq('mySecretUsername')
  41. 1 expect(tfv_basic_authentication_from_hash.password).to eq('mySecretPassword')
  42. end
  43. end
  44. 1 describe '#to_s' do
  45. 1 it 'returns a string representation of the object' do
  46. 1 expect(tfv_basic_authentication_values.to_s).to eq('{:username=>"mySecretUsername", :password=>"mySecretPassword"}')
  47. end
  48. end
  49. 1 describe '#eq? #==' do
  50. 1 it 'returns true/false when comparing objects' do
  51. 1 tfv_basic_authentication_equal = Bandwidth::TfvBasicAuthentication.new({
  52. username: 'baseline',
  53. password: 'baselinePass'
  54. })
  55. 1 expect(tfv_basic_authentication_default.eql?(tfv_basic_authentication_equal)).to be true
  56. 1 expect(tfv_basic_authentication_default.eql?(tfv_basic_authentication_values)).to be false
  57. end
  58. end
  59. 1 describe '#to_body #to_hash' do
  60. 1 it 'returns a hash representation of the object' do
  61. 1 expect(tfv_basic_authentication_values.to_body).to eq({
  62. username: 'mySecretUsername',
  63. password: 'mySecretPassword'
  64. })
  65. end
  66. end
  67. 1 describe 'custom attribute writers' do
  68. 1 it '#username=' do
  69. 1 expect {
  70. 1 Bandwidth::TfvBasicAuthentication.new({ username: nil, password: 'pass' })
  71. }.to raise_error(ArgumentError, 'username cannot be nil')
  72. 1 expect {
  73. 1 Bandwidth::TfvBasicAuthentication.new({ username: 'a' * 101, password: 'pass' })
  74. }.to raise_error(ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 100.')
  75. end
  76. 1 it '#password=' do
  77. 1 expect {
  78. 1 Bandwidth::TfvBasicAuthentication.new({ username: 'user', password: nil })
  79. }.to raise_error(ArgumentError, 'password cannot be nil')
  80. 1 expect {
  81. 1 Bandwidth::TfvBasicAuthentication.new({ username: 'user', password: 'a' * 201 })
  82. }.to raise_error(ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 200.')
  83. end
  84. end
  85. end

spec/unit/models/tfv_callback_status_enum_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::TfvCallbackStatusEnum
  2. 1 describe Bandwidth::TfvCallbackStatusEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines VERIFIED' do
  5. 1 expect(Bandwidth::TfvCallbackStatusEnum::VERIFIED).to eq('VERIFIED')
  6. end
  7. 1 it 'defines UNVERIFIED' do
  8. 1 expect(Bandwidth::TfvCallbackStatusEnum::UNVERIFIED).to eq('UNVERIFIED')
  9. end
  10. end
  11. 1 describe '.all_vars' do
  12. 1 it 'returns every valid enum value' do
  13. 1 expect(Bandwidth::TfvCallbackStatusEnum.all_vars).to eq([
  14. 'VERIFIED',
  15. 'UNVERIFIED'
  16. ])
  17. end
  18. end
  19. 1 describe '.build_from_hash' do
  20. 1 it 'returns the value when it matches a valid enum value' do
  21. 1 expect(Bandwidth::TfvCallbackStatusEnum.build_from_hash('VERIFIED')).to eq('VERIFIED')
  22. 1 expect(Bandwidth::TfvCallbackStatusEnum.build_from_hash('UNVERIFIED')).to eq('UNVERIFIED')
  23. end
  24. 1 it 'raises an error for an invalid enum value' do
  25. 1 expect {
  26. 1 Bandwidth::TfvCallbackStatusEnum.build_from_hash('invalid')
  27. }.to raise_error(RuntimeError)
  28. end
  29. end
  30. end

spec/unit/models/tfv_error_spec.rb

100.0% lines covered

33 relevant lines. 33 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::TfvError
  2. 1 describe Bandwidth::TfvError do
  3. 2 let(:tfv_error_default) { Bandwidth::TfvError.new }
  4. 4 let(:tfv_error_values) { Bandwidth::TfvError.new({
  5. type: 'type',
  6. description: 'description',
  7. errors: { key: 'value' }
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::TfvError.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::TfvError.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::TfvError.acceptable_attributes).to eq(Bandwidth::TfvError.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be an empty set' do
  28. 1 expect(Bandwidth::TfvError.openapi_nullable).to eq(Set.new([]))
  29. end
  30. end
  31. 1 describe '#build_from_hash' do
  32. 1 it 'validates instance of TfvError created by the build_from_hash method' do
  33. 1 tfv_error_from_hash = Bandwidth::TfvError.build_from_hash({
  34. type: 'type',
  35. description: 'description',
  36. errors: { key: 'value' }
  37. })
  38. 1 expect(tfv_error_from_hash).to be_instance_of(Bandwidth::TfvError)
  39. 1 expect(tfv_error_from_hash.type).to eq('type')
  40. 1 expect(tfv_error_from_hash.description).to eq('description')
  41. 1 expect(tfv_error_from_hash.errors).to eq({ key: 'value' })
  42. end
  43. end
  44. 1 describe '#to_s' do
  45. 1 it 'returns a string representation of the object' do
  46. 1 expect(tfv_error_values.to_s).to eq('{:type=>"type", :description=>"description", :errors=>{:key=>"value"}}')
  47. end
  48. end
  49. 1 describe '#eq? #==' do
  50. 1 it 'returns true/false when comparing objects' do
  51. 1 expect(tfv_error_default.eql?(Bandwidth::TfvError.new)).to be true
  52. 1 expect(tfv_error_default.eql?(tfv_error_values)).to be false
  53. end
  54. end
  55. 1 describe '#to_body #to_hash' do
  56. 1 it 'returns a hash representation of the object' do
  57. 1 expect(tfv_error_values.to_body).to eq({
  58. type: 'type',
  59. description: 'description',
  60. errors: { key: 'value' }
  61. })
  62. end
  63. end
  64. end

spec/unit/models/tfv_status_enum_spec.rb

100.0% lines covered

19 relevant lines. 19 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::TfvStatusEnum
  2. 1 describe Bandwidth::TfvStatusEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines VERIFIED' do
  5. 1 expect(Bandwidth::TfvStatusEnum::VERIFIED).to eq('VERIFIED')
  6. end
  7. 1 it 'defines UNVERIFIED' do
  8. 1 expect(Bandwidth::TfvStatusEnum::UNVERIFIED).to eq('UNVERIFIED')
  9. end
  10. 1 it 'defines PENDING' do
  11. 1 expect(Bandwidth::TfvStatusEnum::PENDING).to eq('PENDING')
  12. end
  13. end
  14. 1 describe '.all_vars' do
  15. 1 it 'returns every valid enum value' do
  16. 1 expect(Bandwidth::TfvStatusEnum.all_vars).to eq([
  17. 'VERIFIED',
  18. 'UNVERIFIED',
  19. 'PENDING'
  20. ])
  21. end
  22. end
  23. 1 describe '.build_from_hash' do
  24. 1 it 'returns the value when it matches a valid enum value' do
  25. 1 expect(Bandwidth::TfvStatusEnum.build_from_hash('VERIFIED')).to eq('VERIFIED')
  26. 1 expect(Bandwidth::TfvStatusEnum.build_from_hash('UNVERIFIED')).to eq('UNVERIFIED')
  27. 1 expect(Bandwidth::TfvStatusEnum.build_from_hash('PENDING')).to eq('PENDING')
  28. end
  29. 1 it 'raises an error for an invalid enum value' do
  30. 1 expect {
  31. 1 Bandwidth::TfvStatusEnum.build_from_hash('invalid')
  32. }.to raise_error(RuntimeError)
  33. end
  34. end
  35. end

spec/unit/models/tfv_status_spec.rb

100.0% lines covered

54 relevant lines. 54 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::TfvStatus
  2. 1 describe Bandwidth::TfvStatus do
  3. 2 let(:tfv_status_default) { Bandwidth::TfvStatus.new }
  4. 4 let(:tfv_status_values) { Bandwidth::TfvStatus.new({
  5. phone_number: '+18005554321',
  6. status: Bandwidth::TfvStatusEnum::VERIFIED,
  7. internal_ticket_number: '8c8f33f8-0d72-43c8-8b6c-1da8f0a9e6b3',
  8. decline_reason_description: 'The reason for declining',
  9. resubmit_allowed: false,
  10. created_date_time: '2024-01-01T00:00:00Z',
  11. modified_date_time: '2024-01-02T00:00:00Z',
  12. submission: { businessAddress: { name: 'Bandwidth' } },
  13. blocked: false,
  14. blocked_reason: 'The reason for blocking',
  15. cv_token: 'cv_token_value'
  16. }) }
  17. 1 describe '#initialize' do
  18. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  19. 1 expect {
  20. 1 Bandwidth::TfvStatus.new([])
  21. }.to raise_error(ArgumentError)
  22. end
  23. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  24. 1 expect {
  25. 1 Bandwidth::TfvStatus.new({ invalid: true })
  26. }.to raise_error(ArgumentError)
  27. end
  28. end
  29. 1 describe '#acceptable_attributes' do
  30. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  31. 1 expect(Bandwidth::TfvStatus.acceptable_attributes).to eq(Bandwidth::TfvStatus.attribute_map.values)
  32. end
  33. end
  34. 1 describe '#openapi_nullable' do
  35. 1 it 'expects nullable attributes to be the set of nullable fields' do
  36. 1 expect(Bandwidth::TfvStatus.openapi_nullable).to eq(Set.new([:'cv_token']))
  37. end
  38. end
  39. 1 describe '#build_from_hash' do
  40. 1 it 'validates instance of TfvStatus created by the build_from_hash method' do
  41. 1 tfv_status_from_hash = Bandwidth::TfvStatus.build_from_hash({
  42. phoneNumber: '+18005554321',
  43. status: Bandwidth::TfvStatusEnum::VERIFIED,
  44. internalTicketNumber: '8c8f33f8-0d72-43c8-8b6c-1da8f0a9e6b3',
  45. declineReasonDescription: 'The reason for declining',
  46. resubmitAllowed: false,
  47. createdDateTime: '2024-01-01T00:00:00Z',
  48. modifiedDateTime: '2024-01-02T00:00:00Z',
  49. submission: { businessAddress: { name: 'Bandwidth', addr1: '900 Main Campus Dr', city: 'Raleigh', state: 'NC', zip: '27606', url: 'https://www.bandwidth.com' } },
  50. blocked: false,
  51. blockedReason: 'The reason for blocking',
  52. cvToken: 'cv_token_value'
  53. })
  54. 1 expect(tfv_status_from_hash).to be_instance_of(Bandwidth::TfvStatus)
  55. 1 expect(tfv_status_from_hash.phone_number).to eq('+18005554321')
  56. 1 expect(tfv_status_from_hash.status).to eq(Bandwidth::TfvStatusEnum::VERIFIED)
  57. 1 expect(tfv_status_from_hash.internal_ticket_number).to eq('8c8f33f8-0d72-43c8-8b6c-1da8f0a9e6b3')
  58. 1 expect(tfv_status_from_hash.decline_reason_description).to eq('The reason for declining')
  59. 1 expect(tfv_status_from_hash.resubmit_allowed).to eq(false)
  60. 1 expect(tfv_status_from_hash.created_date_time).to eq(Time.parse('2024-01-01T00:00:00Z'))
  61. 1 expect(tfv_status_from_hash.modified_date_time).to eq(Time.parse('2024-01-02T00:00:00Z'))
  62. 1 expect(tfv_status_from_hash.submission).to be_instance_of(Bandwidth::TfvSubmissionInfo)
  63. 1 expect(tfv_status_from_hash.blocked).to eq(false)
  64. 1 expect(tfv_status_from_hash.blocked_reason).to eq('The reason for blocking')
  65. 1 expect(tfv_status_from_hash.cv_token).to eq('cv_token_value')
  66. end
  67. end
  68. 1 describe '#to_s' do
  69. 1 it 'returns a string representation of the object' do
  70. 1 expect(tfv_status_values.to_s).to eq('{:phoneNumber=>"+18005554321", :status=>"VERIFIED", :internalTicketNumber=>"8c8f33f8-0d72-43c8-8b6c-1da8f0a9e6b3", :declineReasonDescription=>"The reason for declining", :resubmitAllowed=>false, :createdDateTime=>"2024-01-01T00:00:00Z", :modifiedDateTime=>"2024-01-02T00:00:00Z", :submission=>{:businessAddress=>{:name=>"Bandwidth"}}, :blocked=>false, :blockedReason=>"The reason for blocking", :cvToken=>"cv_token_value"}')
  71. end
  72. end
  73. 1 describe '#eq? #==' do
  74. 1 it 'returns true/false when comparing objects' do
  75. 1 expect(tfv_status_default.eql?(Bandwidth::TfvStatus.new)).to be true
  76. 1 expect(tfv_status_default.eql?(tfv_status_values)).to be false
  77. end
  78. end
  79. 1 describe '#to_body #to_hash' do
  80. 1 it 'returns a hash representation of the object' do
  81. 1 expect(tfv_status_values.to_body).to eq({
  82. phoneNumber: '+18005554321',
  83. status: Bandwidth::TfvStatusEnum::VERIFIED,
  84. internalTicketNumber: '8c8f33f8-0d72-43c8-8b6c-1da8f0a9e6b3',
  85. declineReasonDescription: 'The reason for declining',
  86. resubmitAllowed: false,
  87. createdDateTime: '2024-01-01T00:00:00Z',
  88. modifiedDateTime: '2024-01-02T00:00:00Z',
  89. submission: { businessAddress: { name: 'Bandwidth' } },
  90. blocked: false,
  91. blockedReason: 'The reason for blocking',
  92. cvToken: 'cv_token_value'
  93. })
  94. end
  95. end
  96. 1 describe 'custom attribute writers' do
  97. 1 it '#phone_number=' do
  98. 1 expect {
  99. 1 Bandwidth::TfvStatus.new({ phone_number: nil })
  100. }.to raise_error(ArgumentError, 'phone_number cannot be nil')
  101. 1 expect {
  102. 1 Bandwidth::TfvStatus.new({ phone_number: '+1800555432' })
  103. }.to raise_error(ArgumentError, 'invalid value for "phone_number", the character length must be greater than or equal to 12.')
  104. 1 expect {
  105. 1 Bandwidth::TfvStatus.new({ phone_number: '+180055543210' })
  106. }.to raise_error(ArgumentError, 'invalid value for "phone_number", the character length must be smaller than or equal to 12.')
  107. 1 expect {
  108. 1 Bandwidth::TfvStatus.new({ phone_number: '+12345678901' })
  109. }.to raise_error(ArgumentError, /invalid value for "phone_number", must conform to the pattern/)
  110. end
  111. 1 it '#cv_token=' do
  112. 1 expect {
  113. 1 Bandwidth::TfvStatus.new({ cv_token: 'a' * 501 })
  114. }.to raise_error(ArgumentError, 'invalid value for "cv_token", the character length must be smaller than or equal to 500.')
  115. end
  116. end
  117. end

spec/unit/models/tfv_submission_info_spec.rb

100.0% lines covered

93 relevant lines. 93 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::TfvSubmissionInfo
  2. 1 describe Bandwidth::TfvSubmissionInfo do
  3. 2 let(:tfv_submission_info_default) { Bandwidth::TfvSubmissionInfo.new }
  4. 4 let(:tfv_submission_info_values) { Bandwidth::TfvSubmissionInfo.new({
  5. business_address: { name: 'Bandwidth' },
  6. business_contact: { firstName: 'Jane' },
  7. message_volume: 1000,
  8. use_case: 'Customer notifications',
  9. use_case_summary: 'Send customers updates about their orders',
  10. production_message_content: 'Your order has shipped',
  11. opt_in_workflow: { description: 'opt-in via website', imageUrls: ['https://example.com/optin.png'] },
  12. additional_information: 'extra info',
  13. isv_reseller: 'My ISV',
  14. privacy_policy_url: 'https://example.com/privacy',
  15. terms_and_conditions_url: 'https://example.com/terms',
  16. business_dba: 'Bandwidth Inc',
  17. business_registration_number: '12-3456789',
  18. business_registration_type: Bandwidth::BusinessRegistrationTypeEnum::EIN,
  19. business_registration_issuing_country: 'USA',
  20. business_entity_type: Bandwidth::BusinessEntityTypeEnum::PRIVATE_PROFIT
  21. }) }
  22. 1 describe '#initialize' do
  23. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  24. 1 expect {
  25. 1 Bandwidth::TfvSubmissionInfo.new([])
  26. }.to raise_error(ArgumentError)
  27. end
  28. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  29. 1 expect {
  30. 1 Bandwidth::TfvSubmissionInfo.new({ invalid: true })
  31. }.to raise_error(ArgumentError)
  32. end
  33. end
  34. 1 describe '#acceptable_attributes' do
  35. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  36. 1 expect(Bandwidth::TfvSubmissionInfo.acceptable_attributes).to eq(Bandwidth::TfvSubmissionInfo.attribute_map.values)
  37. end
  38. end
  39. 1 describe '#openapi_nullable' do
  40. 1 it 'expects nullable attributes to be the set of nullable fields' do
  41. 1 expect(Bandwidth::TfvSubmissionInfo.openapi_nullable).to eq(Set.new([
  42. :'additional_information',
  43. :'isv_reseller',
  44. :'business_registration_number',
  45. :'business_registration_type',
  46. :'business_registration_issuing_country'
  47. ]))
  48. end
  49. end
  50. 1 describe '#build_from_hash' do
  51. 1 it 'validates instance of TfvSubmissionInfo created by the build_from_hash method' do
  52. 1 tfv_submission_info_from_hash = Bandwidth::TfvSubmissionInfo.build_from_hash({
  53. businessAddress: { name: 'Bandwidth', addr1: '900 Main Campus Dr', city: 'Raleigh', state: 'NC', zip: '27606', url: 'https://www.bandwidth.com' },
  54. businessContact: { firstName: 'Jane', lastName: 'Doe', email: 'jane@bandwidth.com', phoneNumber: '+19195551234' },
  55. messageVolume: 1000,
  56. useCase: 'Customer notifications',
  57. useCaseSummary: 'Send customers updates about their orders',
  58. productionMessageContent: 'Your order has shipped',
  59. optInWorkflow: { description: 'opt-in via website', imageUrls: ['https://example.com/optin.png'] },
  60. additionalInformation: 'extra info',
  61. isvReseller: 'My ISV',
  62. privacyPolicyUrl: 'https://example.com/privacy',
  63. termsAndConditionsUrl: 'https://example.com/terms',
  64. businessDba: 'Bandwidth Inc',
  65. businessRegistrationNumber: '12-3456789',
  66. businessRegistrationType: Bandwidth::BusinessRegistrationTypeEnum::EIN,
  67. businessRegistrationIssuingCountry: 'USA',
  68. businessEntityType: Bandwidth::BusinessEntityTypeEnum::PRIVATE_PROFIT
  69. })
  70. 1 expect(tfv_submission_info_from_hash).to be_instance_of(Bandwidth::TfvSubmissionInfo)
  71. 1 expect(tfv_submission_info_from_hash.business_address).to be_instance_of(Bandwidth::Address)
  72. 1 expect(tfv_submission_info_from_hash.business_contact).to be_instance_of(Bandwidth::Contact)
  73. 1 expect(tfv_submission_info_from_hash.message_volume).to eq(1000)
  74. 1 expect(tfv_submission_info_from_hash.use_case).to eq('Customer notifications')
  75. 1 expect(tfv_submission_info_from_hash.use_case_summary).to eq('Send customers updates about their orders')
  76. 1 expect(tfv_submission_info_from_hash.production_message_content).to eq('Your order has shipped')
  77. 1 expect(tfv_submission_info_from_hash.opt_in_workflow).to be_instance_of(Bandwidth::OptInWorkflow)
  78. 1 expect(tfv_submission_info_from_hash.additional_information).to eq('extra info')
  79. 1 expect(tfv_submission_info_from_hash.isv_reseller).to eq('My ISV')
  80. 1 expect(tfv_submission_info_from_hash.privacy_policy_url).to eq('https://example.com/privacy')
  81. 1 expect(tfv_submission_info_from_hash.terms_and_conditions_url).to eq('https://example.com/terms')
  82. 1 expect(tfv_submission_info_from_hash.business_dba).to eq('Bandwidth Inc')
  83. 1 expect(tfv_submission_info_from_hash.business_registration_number).to eq('12-3456789')
  84. 1 expect(tfv_submission_info_from_hash.business_registration_type).to eq(Bandwidth::BusinessRegistrationTypeEnum::EIN)
  85. 1 expect(tfv_submission_info_from_hash.business_registration_issuing_country).to eq('USA')
  86. 1 expect(tfv_submission_info_from_hash.business_entity_type).to eq(Bandwidth::BusinessEntityTypeEnum::PRIVATE_PROFIT)
  87. end
  88. end
  89. 1 describe '#to_s' do
  90. 1 it 'returns a string representation of the object' do
  91. 1 expect(tfv_submission_info_values.to_s).to eq('{:businessAddress=>{:name=>"Bandwidth"}, :businessContact=>{:firstName=>"Jane"}, :messageVolume=>1000, :useCase=>"Customer notifications", :useCaseSummary=>"Send customers updates about their orders", :productionMessageContent=>"Your order has shipped", :optInWorkflow=>{:description=>"opt-in via website", :imageUrls=>["https://example.com/optin.png"]}, :additionalInformation=>"extra info", :isvReseller=>"My ISV", :privacyPolicyUrl=>"https://example.com/privacy", :termsAndConditionsUrl=>"https://example.com/terms", :businessDba=>"Bandwidth Inc", :businessRegistrationNumber=>"12-3456789", :businessRegistrationType=>"EIN", :businessRegistrationIssuingCountry=>"USA", :businessEntityType=>"PRIVATE_PROFIT"}')
  92. end
  93. end
  94. 1 describe '#eq? #==' do
  95. 1 it 'returns true/false when comparing objects' do
  96. 1 expect(tfv_submission_info_default.eql?(Bandwidth::TfvSubmissionInfo.new)).to be true
  97. 1 expect(tfv_submission_info_default.eql?(tfv_submission_info_values)).to be false
  98. end
  99. end
  100. 1 describe '#to_body #to_hash' do
  101. 1 it 'returns a hash representation of the object' do
  102. 1 expect(tfv_submission_info_values.to_body).to eq({
  103. businessAddress: { name: 'Bandwidth' },
  104. businessContact: { firstName: 'Jane' },
  105. messageVolume: 1000,
  106. useCase: 'Customer notifications',
  107. useCaseSummary: 'Send customers updates about their orders',
  108. productionMessageContent: 'Your order has shipped',
  109. optInWorkflow: { description: 'opt-in via website', imageUrls: ['https://example.com/optin.png'] },
  110. additionalInformation: 'extra info',
  111. isvReseller: 'My ISV',
  112. privacyPolicyUrl: 'https://example.com/privacy',
  113. termsAndConditionsUrl: 'https://example.com/terms',
  114. businessDba: 'Bandwidth Inc',
  115. businessRegistrationNumber: '12-3456789',
  116. businessRegistrationType: Bandwidth::BusinessRegistrationTypeEnum::EIN,
  117. businessRegistrationIssuingCountry: 'USA',
  118. businessEntityType: Bandwidth::BusinessEntityTypeEnum::PRIVATE_PROFIT
  119. })
  120. end
  121. end
  122. 1 describe 'custom attribute writers' do
  123. 1 it '#message_volume=' do
  124. 1 expect {
  125. 1 Bandwidth::TfvSubmissionInfo.new({ message_volume: nil })
  126. }.to raise_error(ArgumentError, 'message_volume cannot be nil')
  127. 1 expect {
  128. 1 Bandwidth::TfvSubmissionInfo.new({ message_volume: 10000001 })
  129. }.to raise_error(ArgumentError, 'invalid value for "message_volume", must be smaller than or equal to 10000000.')
  130. 1 expect {
  131. 1 Bandwidth::TfvSubmissionInfo.new({ message_volume: 9 })
  132. }.to raise_error(ArgumentError, 'invalid value for "message_volume", must be greater than or equal to 10.')
  133. end
  134. 1 it '#use_case=' do
  135. 1 expect {
  136. 1 Bandwidth::TfvSubmissionInfo.new({ use_case: nil })
  137. }.to raise_error(ArgumentError, 'use_case cannot be nil')
  138. 1 expect {
  139. 1 Bandwidth::TfvSubmissionInfo.new({ use_case: 'a' * 501 })
  140. }.to raise_error(ArgumentError, 'invalid value for "use_case", the character length must be smaller than or equal to 500.')
  141. end
  142. 1 it '#use_case_summary=' do
  143. 1 expect {
  144. 1 Bandwidth::TfvSubmissionInfo.new({ use_case_summary: nil })
  145. }.to raise_error(ArgumentError, 'use_case_summary cannot be nil')
  146. 1 expect {
  147. 1 Bandwidth::TfvSubmissionInfo.new({ use_case_summary: 'a' * 501 })
  148. }.to raise_error(ArgumentError, 'invalid value for "use_case_summary", the character length must be smaller than or equal to 500.')
  149. end
  150. 1 it '#production_message_content=' do
  151. 1 expect {
  152. 1 Bandwidth::TfvSubmissionInfo.new({ production_message_content: nil })
  153. }.to raise_error(ArgumentError, 'production_message_content cannot be nil')
  154. 1 expect {
  155. 1 Bandwidth::TfvSubmissionInfo.new({ production_message_content: 'a' * 501 })
  156. }.to raise_error(ArgumentError, 'invalid value for "production_message_content", the character length must be smaller than or equal to 500.')
  157. end
  158. 1 it '#additional_information=' do
  159. 1 expect {
  160. 1 Bandwidth::TfvSubmissionInfo.new({ additional_information: 'a' * 501 })
  161. }.to raise_error(ArgumentError, 'invalid value for "additional_information", the character length must be smaller than or equal to 500.')
  162. end
  163. 1 it '#isv_reseller=' do
  164. 1 expect {
  165. 1 Bandwidth::TfvSubmissionInfo.new({ isv_reseller: 'a' * 501 })
  166. }.to raise_error(ArgumentError, 'invalid value for "isv_reseller", the character length must be smaller than or equal to 500.')
  167. end
  168. 1 it '#privacy_policy_url=' do
  169. 1 expect {
  170. 1 Bandwidth::TfvSubmissionInfo.new({ privacy_policy_url: nil })
  171. }.to raise_error(ArgumentError, 'privacy_policy_url cannot be nil')
  172. 1 expect {
  173. 1 Bandwidth::TfvSubmissionInfo.new({ privacy_policy_url: 'a' * 501 })
  174. }.to raise_error(ArgumentError, 'invalid value for "privacy_policy_url", the character length must be smaller than or equal to 500.')
  175. end
  176. 1 it '#terms_and_conditions_url=' do
  177. 1 expect {
  178. 1 Bandwidth::TfvSubmissionInfo.new({ terms_and_conditions_url: nil })
  179. }.to raise_error(ArgumentError, 'terms_and_conditions_url cannot be nil')
  180. 1 expect {
  181. 1 Bandwidth::TfvSubmissionInfo.new({ terms_and_conditions_url: 'a' * 501 })
  182. }.to raise_error(ArgumentError, 'invalid value for "terms_and_conditions_url", the character length must be smaller than or equal to 500.')
  183. end
  184. 1 it '#business_dba=' do
  185. 1 expect {
  186. 1 Bandwidth::TfvSubmissionInfo.new({ business_dba: nil })
  187. }.to raise_error(ArgumentError, 'business_dba cannot be nil')
  188. 1 expect {
  189. 1 Bandwidth::TfvSubmissionInfo.new({ business_dba: 'a' * 501 })
  190. }.to raise_error(ArgumentError, 'invalid value for "business_dba", the character length must be smaller than or equal to 500.')
  191. end
  192. 1 it '#business_registration_number=' do
  193. 1 expect {
  194. 1 Bandwidth::TfvSubmissionInfo.new({ business_registration_number: 'a' * 501 })
  195. }.to raise_error(ArgumentError, 'invalid value for "business_registration_number", the character length must be smaller than or equal to 500.')
  196. end
  197. end
  198. end

spec/unit/models/tfv_submission_wrapper_spec.rb

100.0% lines covered

32 relevant lines. 32 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::TfvSubmissionWrapper
  2. 1 describe Bandwidth::TfvSubmissionWrapper do
  3. 2 let(:tfv_submission_wrapper_default) { Bandwidth::TfvSubmissionWrapper.new }
  4. 4 let(:tfv_submission_wrapper_values) { Bandwidth::TfvSubmissionWrapper.new({
  5. submission: { businessDba: 'Bandwidth Inc' }
  6. }) }
  7. 1 describe '#initialize' do
  8. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  9. 1 expect {
  10. 1 Bandwidth::TfvSubmissionWrapper.new([])
  11. }.to raise_error(ArgumentError)
  12. end
  13. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  14. 1 expect {
  15. 1 Bandwidth::TfvSubmissionWrapper.new({ invalid: true })
  16. }.to raise_error(ArgumentError)
  17. end
  18. end
  19. 1 describe '#acceptable_attributes' do
  20. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  21. 1 expect(Bandwidth::TfvSubmissionWrapper.acceptable_attributes).to eq(Bandwidth::TfvSubmissionWrapper.attribute_map.values)
  22. end
  23. end
  24. 1 describe '#openapi_nullable' do
  25. 1 it 'expects nullable attributes to be an empty set' do
  26. 1 expect(Bandwidth::TfvSubmissionWrapper.openapi_nullable).to eq(Set.new([]))
  27. end
  28. end
  29. 1 describe '#build_from_hash' do
  30. 1 it 'validates instance of TfvSubmissionWrapper created by the build_from_hash method' do
  31. 1 tfv_submission_wrapper_from_hash = Bandwidth::TfvSubmissionWrapper.build_from_hash({
  32. submission: {
  33. businessAddress: { name: 'Bandwidth', addr1: '900 Main Campus Dr', city: 'Raleigh', state: 'NC', zip: '27606', url: 'https://www.bandwidth.com' },
  34. businessContact: { firstName: 'Jane', lastName: 'Doe', email: 'jane@bandwidth.com', phoneNumber: '+19195551234' },
  35. messageVolume: 1000,
  36. useCase: 'Customer notifications',
  37. useCaseSummary: 'Send customers updates about their orders',
  38. productionMessageContent: 'Your order has shipped',
  39. optInWorkflow: { description: 'opt-in via website', imageUrls: ['https://example.com/optin.png'] },
  40. privacyPolicyUrl: 'https://example.com/privacy',
  41. termsAndConditionsUrl: 'https://example.com/terms',
  42. businessDba: 'Bandwidth Inc'
  43. }
  44. })
  45. 1 expect(tfv_submission_wrapper_from_hash).to be_instance_of(Bandwidth::TfvSubmissionWrapper)
  46. 1 expect(tfv_submission_wrapper_from_hash.submission).to be_instance_of(Bandwidth::VerificationUpdateRequest)
  47. 1 expect(tfv_submission_wrapper_from_hash.submission.business_dba).to eq('Bandwidth Inc')
  48. end
  49. end
  50. 1 describe '#to_s' do
  51. 1 it 'returns a string representation of the object' do
  52. 1 expect(tfv_submission_wrapper_values.to_s).to eq('{:submission=>{:businessDba=>"Bandwidth Inc"}}')
  53. end
  54. end
  55. 1 describe '#eq? #==' do
  56. 1 it 'returns true/false when comparing objects' do
  57. 1 expect(tfv_submission_wrapper_default.eql?(Bandwidth::TfvSubmissionWrapper.new)).to be true
  58. 1 expect(tfv_submission_wrapper_default.eql?(tfv_submission_wrapper_values)).to be false
  59. end
  60. end
  61. 1 describe '#to_body #to_hash' do
  62. 1 it 'returns a hash representation of the object' do
  63. 1 expect(tfv_submission_wrapper_values.to_body).to eq({
  64. submission: { businessDba: 'Bandwidth Inc' }
  65. })
  66. end
  67. end
  68. end

spec/unit/models/thumbnail_alignment_enum_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::ThumbnailAlignmentEnum
  2. 1 describe Bandwidth::ThumbnailAlignmentEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines LEFT' do
  5. 1 expect(Bandwidth::ThumbnailAlignmentEnum::LEFT).to eq('LEFT')
  6. end
  7. 1 it 'defines RIGHT' do
  8. 1 expect(Bandwidth::ThumbnailAlignmentEnum::RIGHT).to eq('RIGHT')
  9. end
  10. end
  11. 1 describe '.all_vars' do
  12. 1 it 'returns every valid enum value' do
  13. 1 expect(Bandwidth::ThumbnailAlignmentEnum.all_vars).to eq([
  14. 'LEFT',
  15. 'RIGHT'
  16. ])
  17. end
  18. end
  19. 1 describe '.build_from_hash' do
  20. 1 it 'returns the value when it matches a valid enum value' do
  21. 1 expect(Bandwidth::ThumbnailAlignmentEnum.build_from_hash('LEFT')).to eq('LEFT')
  22. 1 expect(Bandwidth::ThumbnailAlignmentEnum.build_from_hash('RIGHT')).to eq('RIGHT')
  23. end
  24. 1 it 'raises an error for an invalid enum value' do
  25. 1 expect {
  26. 1 Bandwidth::ThumbnailAlignmentEnum.build_from_hash('invalid')
  27. }.to raise_error(RuntimeError)
  28. end
  29. end
  30. end

spec/unit/models/transcribe_recording_spec.rb

100.0% lines covered

49 relevant lines. 49 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::TranscribeRecording
  2. 1 describe Bandwidth::TranscribeRecording do
  3. 2 let(:transcribe_recording_default) { Bandwidth::TranscribeRecording.new }
  4. 4 let(:transcribe_recording_values) { Bandwidth::TranscribeRecording.new({
  5. callback_url: 'https://example.com/callback',
  6. callback_method: Bandwidth::CallbackMethodEnum::POST,
  7. username: 'mySecretUsername',
  8. password: 'mySecretPassword',
  9. tag: 'arbitrary tag',
  10. callback_timeout: 5.5,
  11. detect_language: true
  12. }) }
  13. 1 describe '#initialize' do
  14. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  15. 1 expect {
  16. 1 Bandwidth::TranscribeRecording.new([])
  17. }.to raise_error(ArgumentError)
  18. end
  19. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  20. 1 expect {
  21. 1 Bandwidth::TranscribeRecording.new({ invalid: true })
  22. }.to raise_error(ArgumentError)
  23. end
  24. end
  25. 1 describe '#acceptable_attributes' do
  26. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  27. 1 expect(Bandwidth::TranscribeRecording.acceptable_attributes).to eq(Bandwidth::TranscribeRecording.attribute_map.values)
  28. end
  29. end
  30. 1 describe '#openapi_nullable' do
  31. 1 it 'expects nullable attributes to be the set of nullable fields' do
  32. 1 expect(Bandwidth::TranscribeRecording.openapi_nullable).to eq(Set.new([
  33. :'callback_method',
  34. :'username',
  35. :'password',
  36. :'tag',
  37. :'callback_timeout',
  38. :'detect_language'
  39. ]))
  40. end
  41. end
  42. 1 describe '#build_from_hash' do
  43. 1 it 'validates instance of TranscribeRecording created by the build_from_hash method' do
  44. 1 transcribe_recording_from_hash = Bandwidth::TranscribeRecording.build_from_hash({
  45. callbackUrl: 'https://example.com/callback',
  46. callbackMethod: Bandwidth::CallbackMethodEnum::POST,
  47. username: 'mySecretUsername',
  48. password: 'mySecretPassword',
  49. tag: 'arbitrary tag',
  50. callbackTimeout: 5.5,
  51. detectLanguage: true
  52. })
  53. 1 expect(transcribe_recording_from_hash).to be_instance_of(Bandwidth::TranscribeRecording)
  54. 1 expect(transcribe_recording_from_hash.callback_url).to eq('https://example.com/callback')
  55. 1 expect(transcribe_recording_from_hash.callback_method).to eq(Bandwidth::CallbackMethodEnum::POST)
  56. 1 expect(transcribe_recording_from_hash.username).to eq('mySecretUsername')
  57. 1 expect(transcribe_recording_from_hash.password).to eq('mySecretPassword')
  58. 1 expect(transcribe_recording_from_hash.tag).to eq('arbitrary tag')
  59. 1 expect(transcribe_recording_from_hash.callback_timeout).to eq(5.5)
  60. 1 expect(transcribe_recording_from_hash.detect_language).to eq(true)
  61. end
  62. end
  63. 1 describe '#to_s' do
  64. 1 it 'returns a string representation of the object' do
  65. 1 expect(transcribe_recording_values.to_s).to eq('{:callbackUrl=>"https://example.com/callback", :callbackMethod=>"POST", :username=>"mySecretUsername", :password=>"mySecretPassword", :tag=>"arbitrary tag", :callbackTimeout=>5.5, :detectLanguage=>true}')
  66. end
  67. end
  68. 1 describe '#eq? #==' do
  69. 1 it 'returns true/false when comparing objects' do
  70. 1 expect(transcribe_recording_default.eql?(Bandwidth::TranscribeRecording.new)).to be true
  71. 1 expect(transcribe_recording_default.eql?(transcribe_recording_values)).to be false
  72. end
  73. end
  74. 1 describe '#to_body #to_hash' do
  75. 1 it 'returns a hash representation of the object' do
  76. 1 expect(transcribe_recording_values.to_body).to eq({
  77. callbackUrl: 'https://example.com/callback',
  78. callbackMethod: Bandwidth::CallbackMethodEnum::POST,
  79. username: 'mySecretUsername',
  80. password: 'mySecretPassword',
  81. tag: 'arbitrary tag',
  82. callbackTimeout: 5.5,
  83. detectLanguage: true
  84. })
  85. end
  86. end
  87. 1 describe 'custom attribute writers' do
  88. 1 it '#username=' do
  89. 1 expect {
  90. 1 Bandwidth::TranscribeRecording.new({ username: 'a' * 1025 })
  91. }.to raise_error(ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 1024.')
  92. end
  93. 1 it '#password=' do
  94. 1 expect {
  95. 1 Bandwidth::TranscribeRecording.new({ password: 'a' * 1025 })
  96. }.to raise_error(ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 1024.')
  97. end
  98. 1 it '#callback_timeout=' do
  99. 1 expect {
  100. 1 Bandwidth::TranscribeRecording.new({ callback_timeout: 26 })
  101. }.to raise_error(ArgumentError, 'invalid value for "callback_timeout", must be smaller than or equal to 25.')
  102. 1 expect {
  103. 1 Bandwidth::TranscribeRecording.new({ callback_timeout: 0.5 })
  104. }.to raise_error(ArgumentError, 'invalid value for "callback_timeout", must be greater than or equal to 1.')
  105. end
  106. end
  107. end

spec/unit/models/transcription_available_callback_spec.rb

100.0% lines covered

53 relevant lines. 53 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::TranscriptionAvailableCallback
  2. 1 describe Bandwidth::TranscriptionAvailableCallback do
  3. 2 let(:transcription_available_callback_default) { Bandwidth::TranscriptionAvailableCallback.new }
  4. 4 let(:transcription_available_callback_values) { Bandwidth::TranscriptionAvailableCallback.new({
  5. event_type: 'transcriptionAvailable',
  6. event_time: '2022-06-16T13:15:07.160Z',
  7. account_id: '9900000',
  8. application_id: '04e88489-df02-4e34-a0ee-27a91849555f',
  9. from: '+19195554321',
  10. to: '+19195551234',
  11. direction: Bandwidth::CallDirectionEnum::INBOUND,
  12. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  13. call_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  14. media_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/media',
  15. parent_call_id: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  16. recording_id: 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  17. enqueued_time: '2022-06-16T13:15:07.160Z',
  18. start_time: '2022-06-16T13:15:07.160Z',
  19. end_time: '2022-06-16T13:17:07.160Z',
  20. duration: 'PT2M',
  21. file_format: Bandwidth::FileFormatEnum::WAV,
  22. tag: 'custom tag',
  23. transcription: { text: 'Hello world.', confidence: 0.9 },
  24. transfer_caller_id: '+19195554321',
  25. transfer_to: '+19195551234'
  26. }) }
  27. 1 describe '#initialize' do
  28. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  29. 1 expect {
  30. 1 Bandwidth::TranscriptionAvailableCallback.new([])
  31. }.to raise_error(ArgumentError)
  32. end
  33. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  34. 1 expect {
  35. 1 Bandwidth::TranscriptionAvailableCallback.new({ invalid: true })
  36. }.to raise_error(ArgumentError)
  37. end
  38. end
  39. 1 describe '#acceptable_attributes' do
  40. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  41. 1 expect(Bandwidth::TranscriptionAvailableCallback.acceptable_attributes).to eq(Bandwidth::TranscriptionAvailableCallback.attribute_map.values)
  42. end
  43. end
  44. 1 describe '#openapi_nullable' do
  45. 1 it 'expects nullable attributes to be the set of nullable fields' do
  46. 1 expect(Bandwidth::TranscriptionAvailableCallback.openapi_nullable).to eq(Set.new([
  47. :'media_url',
  48. :'enqueued_time',
  49. :'tag'
  50. ]))
  51. end
  52. end
  53. 1 describe '#build_from_hash' do
  54. 1 it 'validates instance of TranscriptionAvailableCallback created by the build_from_hash method' do
  55. 1 transcription_available_callback_from_hash = Bandwidth::TranscriptionAvailableCallback.build_from_hash({
  56. eventType: 'transcriptionAvailable',
  57. eventTime: '2022-06-16T13:15:07.160Z',
  58. accountId: '9900000',
  59. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  60. from: '+19195554321',
  61. to: '+19195551234',
  62. direction: Bandwidth::CallDirectionEnum::INBOUND,
  63. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  64. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  65. mediaUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/media',
  66. parentCallId: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  67. recordingId: 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  68. enqueuedTime: '2022-06-16T13:15:07.160Z',
  69. startTime: '2022-06-16T13:15:07.160Z',
  70. endTime: '2022-06-16T13:17:07.160Z',
  71. duration: 'PT2M',
  72. fileFormat: Bandwidth::FileFormatEnum::WAV,
  73. tag: 'custom tag',
  74. transcription: { text: 'Hello world.', confidence: 0.9 },
  75. transferCallerId: '+19195554321',
  76. transferTo: '+19195551234'
  77. })
  78. 1 expect(transcription_available_callback_from_hash).to be_instance_of(Bandwidth::TranscriptionAvailableCallback)
  79. 1 expect(transcription_available_callback_from_hash.event_type).to eq('transcriptionAvailable')
  80. 1 expect(transcription_available_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  81. 1 expect(transcription_available_callback_from_hash.account_id).to eq('9900000')
  82. 1 expect(transcription_available_callback_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f')
  83. 1 expect(transcription_available_callback_from_hash.from).to eq('+19195554321')
  84. 1 expect(transcription_available_callback_from_hash.to).to eq('+19195551234')
  85. 1 expect(transcription_available_callback_from_hash.direction).to eq(Bandwidth::CallDirectionEnum::INBOUND)
  86. 1 expect(transcription_available_callback_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  87. 1 expect(transcription_available_callback_from_hash.call_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  88. 1 expect(transcription_available_callback_from_hash.media_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/media')
  89. 1 expect(transcription_available_callback_from_hash.parent_call_id).to eq('c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99')
  90. 1 expect(transcription_available_callback_from_hash.recording_id).to eq('r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  91. 1 expect(transcription_available_callback_from_hash.enqueued_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  92. 1 expect(transcription_available_callback_from_hash.start_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  93. 1 expect(transcription_available_callback_from_hash.end_time).to eq(Time.parse('2022-06-16T13:17:07.160Z'))
  94. 1 expect(transcription_available_callback_from_hash.duration).to eq('PT2M')
  95. 1 expect(transcription_available_callback_from_hash.file_format).to eq(Bandwidth::FileFormatEnum::WAV)
  96. 1 expect(transcription_available_callback_from_hash.tag).to eq('custom tag')
  97. 1 expect(transcription_available_callback_from_hash.transcription).to be_instance_of(Bandwidth::Transcription)
  98. 1 expect(transcription_available_callback_from_hash.transcription.text).to eq('Hello world.')
  99. 1 expect(transcription_available_callback_from_hash.transcription.confidence).to eq(0.9)
  100. 1 expect(transcription_available_callback_from_hash.transfer_caller_id).to eq('+19195554321')
  101. 1 expect(transcription_available_callback_from_hash.transfer_to).to eq('+19195551234')
  102. end
  103. end
  104. 1 describe '#to_s' do
  105. 1 it 'returns a string representation of the object' do
  106. 1 expect(transcription_available_callback_values.to_s).to eq('{:eventType=>"transcriptionAvailable", :eventTime=>"2022-06-16T13:15:07.160Z", :accountId=>"9900000", :applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :from=>"+19195554321", :to=>"+19195551234", :direction=>"inbound", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :callUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :mediaUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/media", :parentCallId=>"c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99", :recordingId=>"r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :enqueuedTime=>"2022-06-16T13:15:07.160Z", :startTime=>"2022-06-16T13:15:07.160Z", :endTime=>"2022-06-16T13:17:07.160Z", :duration=>"PT2M", :fileFormat=>"wav", :tag=>"custom tag", :transcription=>{:text=>"Hello world.", :confidence=>0.9}, :transferCallerId=>"+19195554321", :transferTo=>"+19195551234"}')
  107. end
  108. end
  109. 1 describe '#eq? #==' do
  110. 1 it 'returns true/false when comparing objects' do
  111. 1 expect(transcription_available_callback_default.eql?(Bandwidth::TranscriptionAvailableCallback.new)).to be true
  112. 1 expect(transcription_available_callback_default.eql?(transcription_available_callback_values)).to be false
  113. end
  114. end
  115. 1 describe '#to_body #to_hash' do
  116. 1 it 'returns a hash representation of the object' do
  117. 1 expect(transcription_available_callback_values.to_body).to eq({
  118. eventType: 'transcriptionAvailable',
  119. eventTime: '2022-06-16T13:15:07.160Z',
  120. accountId: '9900000',
  121. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  122. from: '+19195554321',
  123. to: '+19195551234',
  124. direction: Bandwidth::CallDirectionEnum::INBOUND,
  125. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  126. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  127. mediaUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/media',
  128. parentCallId: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  129. recordingId: 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  130. enqueuedTime: '2022-06-16T13:15:07.160Z',
  131. startTime: '2022-06-16T13:15:07.160Z',
  132. endTime: '2022-06-16T13:17:07.160Z',
  133. duration: 'PT2M',
  134. fileFormat: Bandwidth::FileFormatEnum::WAV,
  135. tag: 'custom tag',
  136. transcription: { text: 'Hello world.', confidence: 0.9 },
  137. transferCallerId: '+19195554321',
  138. transferTo: '+19195551234'
  139. })
  140. end
  141. end
  142. end

spec/unit/models/transcription_spec.rb

100.0% lines covered

32 relevant lines. 32 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::Transcription
  2. 1 describe Bandwidth::Transcription do
  3. 2 let(:transcription_default) { Bandwidth::Transcription.new }
  4. 4 let(:transcription_values) { Bandwidth::Transcription.new({
  5. text: 'Hello World! Thank you for calling.',
  6. confidence: 0.9
  7. }) }
  8. 1 describe '#initialize' do
  9. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  10. 1 expect {
  11. 1 Bandwidth::Transcription.new([])
  12. }.to raise_error(ArgumentError)
  13. end
  14. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  15. 1 expect {
  16. 1 Bandwidth::Transcription.new({ invalid: true })
  17. }.to raise_error(ArgumentError)
  18. end
  19. end
  20. 1 describe '#acceptable_attributes' do
  21. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  22. 1 expect(Bandwidth::Transcription.acceptable_attributes).to eq(Bandwidth::Transcription.attribute_map.values)
  23. end
  24. end
  25. 1 describe '#openapi_nullable' do
  26. 1 it 'expects nullable attributes to be an empty set' do
  27. 1 expect(Bandwidth::Transcription.openapi_nullable).to eq(Set.new([]))
  28. end
  29. end
  30. 1 describe '#build_from_hash' do
  31. 1 it 'validates instance of Transcription created by the build_from_hash method' do
  32. 1 transcription_from_hash = Bandwidth::Transcription.build_from_hash({
  33. text: 'Hello World! Thank you for calling.',
  34. confidence: 0.9
  35. })
  36. 1 expect(transcription_from_hash).to be_instance_of(Bandwidth::Transcription)
  37. 1 expect(transcription_from_hash.text).to eq('Hello World! Thank you for calling.')
  38. 1 expect(transcription_from_hash.confidence).to eq(0.9)
  39. end
  40. end
  41. 1 describe '#to_s' do
  42. 1 it 'returns a string representation of the object' do
  43. 1 expect(transcription_values.to_s).to eq('{:text=>"Hello World! Thank you for calling.", :confidence=>0.9}')
  44. end
  45. end
  46. 1 describe '#eq? #==' do
  47. 1 it 'returns true/false when comparing objects' do
  48. 1 expect(transcription_default.eql?(Bandwidth::Transcription.new)).to be true
  49. 1 expect(transcription_default.eql?(transcription_values)).to be false
  50. end
  51. end
  52. 1 describe '#to_body #to_hash' do
  53. 1 it 'returns a hash representation of the object' do
  54. 1 expect(transcription_values.to_body).to eq({
  55. text: 'Hello World! Thank you for calling.',
  56. confidence: 0.9
  57. })
  58. end
  59. end
  60. end

spec/unit/models/transfer_answer_callback_spec.rb

100.0% lines covered

45 relevant lines. 45 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::TransferAnswerCallback
  2. 1 describe Bandwidth::TransferAnswerCallback do
  3. 2 let(:transfer_answer_callback_default) { Bandwidth::TransferAnswerCallback.new }
  4. 4 let(:transfer_answer_callback_values) { Bandwidth::TransferAnswerCallback.new({
  5. event_type: 'transferAnswer',
  6. event_time: '2022-06-16T13:15:07.160Z',
  7. account_id: '9900000',
  8. application_id: '04e88489-df02-4e34-a0ee-27a91849555f',
  9. from: '+19195554321',
  10. to: '+19195551234',
  11. direction: Bandwidth::CallDirectionEnum::OUTBOUND,
  12. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  13. call_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  14. enqueued_time: '2022-06-16T13:15:07.160Z',
  15. start_time: '2022-06-16T13:15:07.160Z',
  16. answer_time: '2022-06-16T13:15:18.126Z',
  17. tag: 'custom tag',
  18. transfer_caller_id: '+19195554321',
  19. transfer_to: '+19195551234'
  20. }) }
  21. 1 describe '#initialize' do
  22. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  23. 1 expect {
  24. 1 Bandwidth::TransferAnswerCallback.new([])
  25. }.to raise_error(ArgumentError)
  26. end
  27. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  28. 1 expect {
  29. 1 Bandwidth::TransferAnswerCallback.new({ invalid: true })
  30. }.to raise_error(ArgumentError)
  31. end
  32. end
  33. 1 describe '#acceptable_attributes' do
  34. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  35. 1 expect(Bandwidth::TransferAnswerCallback.acceptable_attributes).to eq(Bandwidth::TransferAnswerCallback.attribute_map.values)
  36. end
  37. end
  38. 1 describe '#openapi_nullable' do
  39. 1 it 'expects nullable attributes to be the set of nullable fields' do
  40. 1 expect(Bandwidth::TransferAnswerCallback.openapi_nullable).to eq(Set.new([
  41. :'enqueued_time',
  42. :'answer_time',
  43. :'tag'
  44. ]))
  45. end
  46. end
  47. 1 describe '#build_from_hash' do
  48. 1 it 'validates instance of TransferAnswerCallback created by the build_from_hash method' do
  49. 1 transfer_answer_callback_from_hash = Bandwidth::TransferAnswerCallback.build_from_hash({
  50. eventType: 'transferAnswer',
  51. eventTime: '2022-06-16T13:15:07.160Z',
  52. accountId: '9900000',
  53. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  54. from: '+19195554321',
  55. to: '+19195551234',
  56. direction: Bandwidth::CallDirectionEnum::OUTBOUND,
  57. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  58. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  59. enqueuedTime: '2022-06-16T13:15:07.160Z',
  60. startTime: '2022-06-16T13:15:07.160Z',
  61. answerTime: '2022-06-16T13:15:18.126Z',
  62. tag: 'custom tag',
  63. transferCallerId: '+19195554321',
  64. transferTo: '+19195551234'
  65. })
  66. 1 expect(transfer_answer_callback_from_hash).to be_instance_of(Bandwidth::TransferAnswerCallback)
  67. 1 expect(transfer_answer_callback_from_hash.event_type).to eq('transferAnswer')
  68. 1 expect(transfer_answer_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  69. 1 expect(transfer_answer_callback_from_hash.account_id).to eq('9900000')
  70. 1 expect(transfer_answer_callback_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f')
  71. 1 expect(transfer_answer_callback_from_hash.from).to eq('+19195554321')
  72. 1 expect(transfer_answer_callback_from_hash.to).to eq('+19195551234')
  73. 1 expect(transfer_answer_callback_from_hash.direction).to eq(Bandwidth::CallDirectionEnum::OUTBOUND)
  74. 1 expect(transfer_answer_callback_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  75. 1 expect(transfer_answer_callback_from_hash.call_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  76. 1 expect(transfer_answer_callback_from_hash.enqueued_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  77. 1 expect(transfer_answer_callback_from_hash.start_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  78. 1 expect(transfer_answer_callback_from_hash.answer_time).to eq(Time.parse('2022-06-16T13:15:18.126Z'))
  79. 1 expect(transfer_answer_callback_from_hash.tag).to eq('custom tag')
  80. 1 expect(transfer_answer_callback_from_hash.transfer_caller_id).to eq('+19195554321')
  81. 1 expect(transfer_answer_callback_from_hash.transfer_to).to eq('+19195551234')
  82. end
  83. end
  84. 1 describe '#to_s' do
  85. 1 it 'returns a string representation of the object' do
  86. 1 expect(transfer_answer_callback_values.to_s).to eq('{:eventType=>"transferAnswer", :eventTime=>"2022-06-16T13:15:07.160Z", :accountId=>"9900000", :applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :from=>"+19195554321", :to=>"+19195551234", :direction=>"outbound", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :callUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :enqueuedTime=>"2022-06-16T13:15:07.160Z", :startTime=>"2022-06-16T13:15:07.160Z", :answerTime=>"2022-06-16T13:15:18.126Z", :tag=>"custom tag", :transferCallerId=>"+19195554321", :transferTo=>"+19195551234"}')
  87. end
  88. end
  89. 1 describe '#eq? #==' do
  90. 1 it 'returns true/false when comparing objects' do
  91. 1 expect(transfer_answer_callback_default.eql?(Bandwidth::TransferAnswerCallback.new)).to be true
  92. 1 expect(transfer_answer_callback_default.eql?(transfer_answer_callback_values)).to be false
  93. end
  94. end
  95. 1 describe '#to_body #to_hash' do
  96. 1 it 'returns a hash representation of the object' do
  97. 1 expect(transfer_answer_callback_values.to_body).to eq({
  98. eventType: 'transferAnswer',
  99. eventTime: '2022-06-16T13:15:07.160Z',
  100. accountId: '9900000',
  101. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  102. from: '+19195554321',
  103. to: '+19195551234',
  104. direction: Bandwidth::CallDirectionEnum::OUTBOUND,
  105. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  106. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  107. enqueuedTime: '2022-06-16T13:15:07.160Z',
  108. startTime: '2022-06-16T13:15:07.160Z',
  109. answerTime: '2022-06-16T13:15:18.126Z',
  110. tag: 'custom tag',
  111. transferCallerId: '+19195554321',
  112. transferTo: '+19195551234'
  113. })
  114. end
  115. end
  116. end

spec/unit/models/transfer_complete_callback_spec.rb

100.0% lines covered

48 relevant lines. 48 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::TransferCompleteCallback
  2. 1 describe Bandwidth::TransferCompleteCallback do
  3. 2 let(:transfer_complete_callback_default) { Bandwidth::TransferCompleteCallback.new }
  4. 4 let(:transfer_complete_callback_values) { Bandwidth::TransferCompleteCallback.new({
  5. event_type: 'transferComplete',
  6. event_time: '2022-06-16T13:15:07.160Z',
  7. account_id: '9900000',
  8. application_id: '04e88489-df02-4e34-a0ee-27a91849555f',
  9. from: '+19195554321',
  10. to: '+19195551234',
  11. direction: Bandwidth::CallDirectionEnum::OUTBOUND,
  12. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  13. call_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  14. enqueued_time: '2022-06-16T13:15:07.160Z',
  15. start_time: '2022-06-16T13:15:07.160Z',
  16. answer_time: '2022-06-16T13:15:18.126Z',
  17. tag: 'custom tag',
  18. transfer_caller_id: '+19195554321',
  19. transfer_to: '+19195551234',
  20. cause: 'hangup',
  21. error_message: 'call rejected',
  22. error_id: '4642074b-7b58-478b-96e4-3a60955c6765'
  23. }) }
  24. 1 describe '#initialize' do
  25. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  26. 1 expect {
  27. 1 Bandwidth::TransferCompleteCallback.new([])
  28. }.to raise_error(ArgumentError)
  29. end
  30. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  31. 1 expect {
  32. 1 Bandwidth::TransferCompleteCallback.new({ invalid: true })
  33. }.to raise_error(ArgumentError)
  34. end
  35. end
  36. 1 describe '#acceptable_attributes' do
  37. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  38. 1 expect(Bandwidth::TransferCompleteCallback.acceptable_attributes).to eq(Bandwidth::TransferCompleteCallback.attribute_map.values)
  39. end
  40. end
  41. 1 describe '#openapi_nullable' do
  42. 1 it 'expects nullable attributes to be the set of nullable fields' do
  43. 1 expect(Bandwidth::TransferCompleteCallback.openapi_nullable).to eq(Set.new([
  44. :'enqueued_time',
  45. :'answer_time',
  46. :'tag',
  47. :'error_message',
  48. :'error_id'
  49. ]))
  50. end
  51. end
  52. 1 describe '#build_from_hash' do
  53. 1 it 'validates instance of TransferCompleteCallback created by the build_from_hash method' do
  54. 1 transfer_complete_callback_from_hash = Bandwidth::TransferCompleteCallback.build_from_hash({
  55. eventType: 'transferComplete',
  56. eventTime: '2022-06-16T13:15:07.160Z',
  57. accountId: '9900000',
  58. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  59. from: '+19195554321',
  60. to: '+19195551234',
  61. direction: Bandwidth::CallDirectionEnum::OUTBOUND,
  62. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  63. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  64. enqueuedTime: '2022-06-16T13:15:07.160Z',
  65. startTime: '2022-06-16T13:15:07.160Z',
  66. answerTime: '2022-06-16T13:15:18.126Z',
  67. tag: 'custom tag',
  68. transferCallerId: '+19195554321',
  69. transferTo: '+19195551234',
  70. cause: 'hangup',
  71. errorMessage: 'call rejected',
  72. errorId: '4642074b-7b58-478b-96e4-3a60955c6765'
  73. })
  74. 1 expect(transfer_complete_callback_from_hash).to be_instance_of(Bandwidth::TransferCompleteCallback)
  75. 1 expect(transfer_complete_callback_from_hash.event_type).to eq('transferComplete')
  76. 1 expect(transfer_complete_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  77. 1 expect(transfer_complete_callback_from_hash.account_id).to eq('9900000')
  78. 1 expect(transfer_complete_callback_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f')
  79. 1 expect(transfer_complete_callback_from_hash.from).to eq('+19195554321')
  80. 1 expect(transfer_complete_callback_from_hash.to).to eq('+19195551234')
  81. 1 expect(transfer_complete_callback_from_hash.direction).to eq(Bandwidth::CallDirectionEnum::OUTBOUND)
  82. 1 expect(transfer_complete_callback_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  83. 1 expect(transfer_complete_callback_from_hash.call_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  84. 1 expect(transfer_complete_callback_from_hash.enqueued_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  85. 1 expect(transfer_complete_callback_from_hash.start_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  86. 1 expect(transfer_complete_callback_from_hash.answer_time).to eq(Time.parse('2022-06-16T13:15:18.126Z'))
  87. 1 expect(transfer_complete_callback_from_hash.tag).to eq('custom tag')
  88. 1 expect(transfer_complete_callback_from_hash.transfer_caller_id).to eq('+19195554321')
  89. 1 expect(transfer_complete_callback_from_hash.transfer_to).to eq('+19195551234')
  90. 1 expect(transfer_complete_callback_from_hash.cause).to eq('hangup')
  91. 1 expect(transfer_complete_callback_from_hash.error_message).to eq('call rejected')
  92. 1 expect(transfer_complete_callback_from_hash.error_id).to eq('4642074b-7b58-478b-96e4-3a60955c6765')
  93. end
  94. end
  95. 1 describe '#to_s' do
  96. 1 it 'returns a string representation of the object' do
  97. 1 expect(transfer_complete_callback_values.to_s).to eq('{:eventType=>"transferComplete", :eventTime=>"2022-06-16T13:15:07.160Z", :accountId=>"9900000", :applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :from=>"+19195554321", :to=>"+19195551234", :direction=>"outbound", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :callUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :enqueuedTime=>"2022-06-16T13:15:07.160Z", :startTime=>"2022-06-16T13:15:07.160Z", :answerTime=>"2022-06-16T13:15:18.126Z", :tag=>"custom tag", :transferCallerId=>"+19195554321", :transferTo=>"+19195551234", :cause=>"hangup", :errorMessage=>"call rejected", :errorId=>"4642074b-7b58-478b-96e4-3a60955c6765"}')
  98. end
  99. end
  100. 1 describe '#eq? #==' do
  101. 1 it 'returns true/false when comparing objects' do
  102. 1 expect(transfer_complete_callback_default.eql?(Bandwidth::TransferCompleteCallback.new)).to be true
  103. 1 expect(transfer_complete_callback_default.eql?(transfer_complete_callback_values)).to be false
  104. end
  105. end
  106. 1 describe '#to_body #to_hash' do
  107. 1 it 'returns a hash representation of the object' do
  108. 1 expect(transfer_complete_callback_values.to_body).to eq({
  109. eventType: 'transferComplete',
  110. eventTime: '2022-06-16T13:15:07.160Z',
  111. accountId: '9900000',
  112. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  113. from: '+19195554321',
  114. to: '+19195551234',
  115. direction: Bandwidth::CallDirectionEnum::OUTBOUND,
  116. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  117. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  118. enqueuedTime: '2022-06-16T13:15:07.160Z',
  119. startTime: '2022-06-16T13:15:07.160Z',
  120. answerTime: '2022-06-16T13:15:18.126Z',
  121. tag: 'custom tag',
  122. transferCallerId: '+19195554321',
  123. transferTo: '+19195551234',
  124. cause: 'hangup',
  125. errorMessage: 'call rejected',
  126. errorId: '4642074b-7b58-478b-96e4-3a60955c6765'
  127. })
  128. end
  129. end
  130. end

spec/unit/models/transfer_disconnect_callback_spec.rb

100.0% lines covered

50 relevant lines. 50 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::TransferDisconnectCallback
  2. 1 describe Bandwidth::TransferDisconnectCallback do
  3. 2 let(:transfer_disconnect_callback_default) { Bandwidth::TransferDisconnectCallback.new }
  4. 4 let(:transfer_disconnect_callback_values) { Bandwidth::TransferDisconnectCallback.new({
  5. event_type: 'transferDisconnect',
  6. event_time: '2022-06-16T13:15:07.160Z',
  7. account_id: '9900000',
  8. application_id: '04e88489-df02-4e34-a0ee-27a91849555f',
  9. from: '+19195554321',
  10. to: '+19195551234',
  11. direction: Bandwidth::CallDirectionEnum::OUTBOUND,
  12. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  13. call_url: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  14. parent_call_id: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  15. enqueued_time: '2022-06-16T13:15:07.160Z',
  16. start_time: '2022-06-16T13:15:07.160Z',
  17. answer_time: '2022-06-16T13:15:18.126Z',
  18. end_time: '2022-06-16T13:16:18.126Z',
  19. tag: 'custom tag',
  20. transfer_caller_id: '+19195554321',
  21. transfer_to: '+19195551234',
  22. cause: 'hangup',
  23. error_message: 'call rejected',
  24. error_id: '4642074b-7b58-478b-96e4-3a60955c6765'
  25. }) }
  26. 1 describe '#initialize' do
  27. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  28. 1 expect {
  29. 1 Bandwidth::TransferDisconnectCallback.new([])
  30. }.to raise_error(ArgumentError)
  31. end
  32. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  33. 1 expect {
  34. 1 Bandwidth::TransferDisconnectCallback.new({ invalid: true })
  35. }.to raise_error(ArgumentError)
  36. end
  37. end
  38. 1 describe '#acceptable_attributes' do
  39. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  40. 1 expect(Bandwidth::TransferDisconnectCallback.acceptable_attributes).to eq(Bandwidth::TransferDisconnectCallback.attribute_map.values)
  41. end
  42. end
  43. 1 describe '#openapi_nullable' do
  44. 1 it 'expects nullable attributes to be the set of nullable fields' do
  45. 1 expect(Bandwidth::TransferDisconnectCallback.openapi_nullable).to eq(Set.new([
  46. :'enqueued_time',
  47. :'answer_time',
  48. :'tag',
  49. :'error_message',
  50. :'error_id'
  51. ]))
  52. end
  53. end
  54. 1 describe '#build_from_hash' do
  55. 1 it 'validates instance of TransferDisconnectCallback created by the build_from_hash method' do
  56. 1 transfer_disconnect_callback_from_hash = Bandwidth::TransferDisconnectCallback.build_from_hash({
  57. eventType: 'transferDisconnect',
  58. eventTime: '2022-06-16T13:15:07.160Z',
  59. accountId: '9900000',
  60. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  61. from: '+19195554321',
  62. to: '+19195551234',
  63. direction: Bandwidth::CallDirectionEnum::OUTBOUND,
  64. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  65. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  66. parentCallId: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  67. enqueuedTime: '2022-06-16T13:15:07.160Z',
  68. startTime: '2022-06-16T13:15:07.160Z',
  69. answerTime: '2022-06-16T13:15:18.126Z',
  70. endTime: '2022-06-16T13:16:18.126Z',
  71. tag: 'custom tag',
  72. transferCallerId: '+19195554321',
  73. transferTo: '+19195551234',
  74. cause: 'hangup',
  75. errorMessage: 'call rejected',
  76. errorId: '4642074b-7b58-478b-96e4-3a60955c6765'
  77. })
  78. 1 expect(transfer_disconnect_callback_from_hash).to be_instance_of(Bandwidth::TransferDisconnectCallback)
  79. 1 expect(transfer_disconnect_callback_from_hash.event_type).to eq('transferDisconnect')
  80. 1 expect(transfer_disconnect_callback_from_hash.event_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  81. 1 expect(transfer_disconnect_callback_from_hash.account_id).to eq('9900000')
  82. 1 expect(transfer_disconnect_callback_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f')
  83. 1 expect(transfer_disconnect_callback_from_hash.from).to eq('+19195554321')
  84. 1 expect(transfer_disconnect_callback_from_hash.to).to eq('+19195551234')
  85. 1 expect(transfer_disconnect_callback_from_hash.direction).to eq(Bandwidth::CallDirectionEnum::OUTBOUND)
  86. 1 expect(transfer_disconnect_callback_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  87. 1 expect(transfer_disconnect_callback_from_hash.call_url).to eq('https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  88. 1 expect(transfer_disconnect_callback_from_hash.parent_call_id).to eq('c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99')
  89. 1 expect(transfer_disconnect_callback_from_hash.enqueued_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  90. 1 expect(transfer_disconnect_callback_from_hash.start_time).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
  91. 1 expect(transfer_disconnect_callback_from_hash.answer_time).to eq(Time.parse('2022-06-16T13:15:18.126Z'))
  92. 1 expect(transfer_disconnect_callback_from_hash.end_time).to eq(Time.parse('2022-06-16T13:16:18.126Z'))
  93. 1 expect(transfer_disconnect_callback_from_hash.tag).to eq('custom tag')
  94. 1 expect(transfer_disconnect_callback_from_hash.transfer_caller_id).to eq('+19195554321')
  95. 1 expect(transfer_disconnect_callback_from_hash.transfer_to).to eq('+19195551234')
  96. 1 expect(transfer_disconnect_callback_from_hash.cause).to eq('hangup')
  97. 1 expect(transfer_disconnect_callback_from_hash.error_message).to eq('call rejected')
  98. 1 expect(transfer_disconnect_callback_from_hash.error_id).to eq('4642074b-7b58-478b-96e4-3a60955c6765')
  99. end
  100. end
  101. 1 describe '#to_s' do
  102. 1 it 'returns a string representation of the object' do
  103. 1 expect(transfer_disconnect_callback_values.to_s).to eq('{:eventType=>"transferDisconnect", :eventTime=>"2022-06-16T13:15:07.160Z", :accountId=>"9900000", :applicationId=>"04e88489-df02-4e34-a0ee-27a91849555f", :from=>"+19195554321", :to=>"+19195551234", :direction=>"outbound", :callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :callUrl=>"https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85", :parentCallId=>"c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99", :enqueuedTime=>"2022-06-16T13:15:07.160Z", :startTime=>"2022-06-16T13:15:07.160Z", :answerTime=>"2022-06-16T13:15:18.126Z", :endTime=>"2022-06-16T13:16:18.126Z", :tag=>"custom tag", :transferCallerId=>"+19195554321", :transferTo=>"+19195551234", :cause=>"hangup", :errorMessage=>"call rejected", :errorId=>"4642074b-7b58-478b-96e4-3a60955c6765"}')
  104. end
  105. end
  106. 1 describe '#eq? #==' do
  107. 1 it 'returns true/false when comparing objects' do
  108. 1 expect(transfer_disconnect_callback_default.eql?(Bandwidth::TransferDisconnectCallback.new)).to be true
  109. 1 expect(transfer_disconnect_callback_default.eql?(transfer_disconnect_callback_values)).to be false
  110. end
  111. end
  112. 1 describe '#to_body #to_hash' do
  113. 1 it 'returns a hash representation of the object' do
  114. 1 expect(transfer_disconnect_callback_values.to_body).to eq({
  115. eventType: 'transferDisconnect',
  116. eventTime: '2022-06-16T13:15:07.160Z',
  117. accountId: '9900000',
  118. applicationId: '04e88489-df02-4e34-a0ee-27a91849555f',
  119. from: '+19195554321',
  120. to: '+19195551234',
  121. direction: Bandwidth::CallDirectionEnum::OUTBOUND,
  122. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  123. callUrl: 'https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85',
  124. parentCallId: 'c-95ac29a2-1331029c-2cb0-4a07-b215-b22865662d99',
  125. enqueuedTime: '2022-06-16T13:15:07.160Z',
  126. startTime: '2022-06-16T13:15:07.160Z',
  127. answerTime: '2022-06-16T13:15:18.126Z',
  128. endTime: '2022-06-16T13:16:18.126Z',
  129. tag: 'custom tag',
  130. transferCallerId: '+19195554321',
  131. transferTo: '+19195551234',
  132. cause: 'hangup',
  133. errorMessage: 'call rejected',
  134. errorId: '4642074b-7b58-478b-96e4-3a60955c6765'
  135. })
  136. end
  137. end
  138. end

spec/unit/models/update_call_recording_spec.rb

100.0% lines covered

36 relevant lines. 36 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::UpdateCallRecording
  2. 1 describe Bandwidth::UpdateCallRecording do
  3. 2 let(:update_call_recording_default) { Bandwidth::UpdateCallRecording.new({
  4. state: Bandwidth::RecordingStateEnum::PAUSED
  5. }) }
  6. 4 let(:update_call_recording_values) { Bandwidth::UpdateCallRecording.new({
  7. state: Bandwidth::RecordingStateEnum::RECORDING
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::UpdateCallRecording.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::UpdateCallRecording.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::UpdateCallRecording.acceptable_attributes).to eq(Bandwidth::UpdateCallRecording.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be an empty set' do
  28. 1 expect(Bandwidth::UpdateCallRecording.openapi_nullable).to eq(Set.new([]))
  29. end
  30. end
  31. 1 describe '#build_from_hash' do
  32. 1 it 'validates instance of UpdateCallRecording created by the build_from_hash method' do
  33. 1 update_call_recording_from_hash = Bandwidth::UpdateCallRecording.build_from_hash({
  34. state: Bandwidth::RecordingStateEnum::RECORDING
  35. })
  36. 1 expect(update_call_recording_from_hash).to be_instance_of(Bandwidth::UpdateCallRecording)
  37. 1 expect(update_call_recording_from_hash.state).to eq(Bandwidth::RecordingStateEnum::RECORDING)
  38. end
  39. end
  40. 1 describe '#to_s' do
  41. 1 it 'returns a string representation of the object' do
  42. 1 expect(update_call_recording_values.to_s).to eq('{:state=>"recording"}')
  43. end
  44. end
  45. 1 describe '#eq? #==' do
  46. 1 it 'returns true/false when comparing objects' do
  47. 1 update_call_recording_equal = Bandwidth::UpdateCallRecording.new({
  48. state: Bandwidth::RecordingStateEnum::PAUSED
  49. })
  50. 1 expect(update_call_recording_default.eql?(update_call_recording_equal)).to be true
  51. 1 expect(update_call_recording_default.eql?(update_call_recording_values)).to be false
  52. end
  53. end
  54. 1 describe '#to_body #to_hash' do
  55. 1 it 'returns a hash representation of the object' do
  56. 1 expect(update_call_recording_values.to_body).to eq({
  57. state: Bandwidth::RecordingStateEnum::RECORDING
  58. })
  59. end
  60. end
  61. 1 describe 'custom attribute writers' do
  62. 1 it '#state=' do
  63. 1 expect {
  64. 1 Bandwidth::UpdateCallRecording.new({ state: nil })
  65. }.to raise_error(ArgumentError, 'state cannot be nil')
  66. end
  67. end
  68. end

spec/unit/models/update_call_spec.rb

100.0% lines covered

56 relevant lines. 56 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::UpdateCall
  2. 1 describe Bandwidth::UpdateCall do
  3. 2 let(:update_call_default) { Bandwidth::UpdateCall.new }
  4. 4 let(:update_call_values) { Bandwidth::UpdateCall.new({
  5. state: Bandwidth::CallStateEnum::ACTIVE,
  6. redirect_url: 'https://example.com/redirect',
  7. redirect_method: Bandwidth::RedirectMethodEnum::POST,
  8. username: 'mySecretUsername',
  9. password: 'mySecretPassword',
  10. redirect_fallback_url: 'https://example.com/fallback',
  11. redirect_fallback_method: Bandwidth::RedirectMethodEnum::GET,
  12. fallback_username: 'fallbackUser',
  13. fallback_password: 'fallbackPass',
  14. tag: 'custom tag'
  15. }) }
  16. 1 describe '#initialize' do
  17. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  18. 1 expect {
  19. 1 Bandwidth::UpdateCall.new([])
  20. }.to raise_error(ArgumentError)
  21. end
  22. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  23. 1 expect {
  24. 1 Bandwidth::UpdateCall.new({ invalid: true })
  25. }.to raise_error(ArgumentError)
  26. end
  27. end
  28. 1 describe '#acceptable_attributes' do
  29. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  30. 1 expect(Bandwidth::UpdateCall.acceptable_attributes).to eq(Bandwidth::UpdateCall.attribute_map.values)
  31. end
  32. end
  33. 1 describe '#openapi_nullable' do
  34. 1 it 'expects nullable attributes to be the set of nullable fields' do
  35. 1 expect(Bandwidth::UpdateCall.openapi_nullable).to eq(Set.new([
  36. :'state',
  37. :'redirect_url',
  38. :'redirect_method',
  39. :'username',
  40. :'password',
  41. :'redirect_fallback_url',
  42. :'redirect_fallback_method',
  43. :'fallback_username',
  44. :'fallback_password',
  45. :'tag'
  46. ]))
  47. end
  48. end
  49. 1 describe '#build_from_hash' do
  50. 1 it 'validates instance of UpdateCall created by the build_from_hash method' do
  51. 1 update_call_from_hash = Bandwidth::UpdateCall.build_from_hash({
  52. state: Bandwidth::CallStateEnum::ACTIVE,
  53. redirectUrl: 'https://example.com/redirect',
  54. redirectMethod: Bandwidth::RedirectMethodEnum::POST,
  55. username: 'mySecretUsername',
  56. password: 'mySecretPassword',
  57. redirectFallbackUrl: 'https://example.com/fallback',
  58. redirectFallbackMethod: Bandwidth::RedirectMethodEnum::GET,
  59. fallbackUsername: 'fallbackUser',
  60. fallbackPassword: 'fallbackPass',
  61. tag: 'custom tag'
  62. })
  63. 1 expect(update_call_from_hash).to be_instance_of(Bandwidth::UpdateCall)
  64. 1 expect(update_call_from_hash.state).to eq(Bandwidth::CallStateEnum::ACTIVE)
  65. 1 expect(update_call_from_hash.redirect_url).to eq('https://example.com/redirect')
  66. 1 expect(update_call_from_hash.redirect_method).to eq(Bandwidth::RedirectMethodEnum::POST)
  67. 1 expect(update_call_from_hash.username).to eq('mySecretUsername')
  68. 1 expect(update_call_from_hash.password).to eq('mySecretPassword')
  69. 1 expect(update_call_from_hash.redirect_fallback_url).to eq('https://example.com/fallback')
  70. 1 expect(update_call_from_hash.redirect_fallback_method).to eq(Bandwidth::RedirectMethodEnum::GET)
  71. 1 expect(update_call_from_hash.fallback_username).to eq('fallbackUser')
  72. 1 expect(update_call_from_hash.fallback_password).to eq('fallbackPass')
  73. 1 expect(update_call_from_hash.tag).to eq('custom tag')
  74. end
  75. end
  76. 1 describe '#to_s' do
  77. 1 it 'returns a string representation of the object' do
  78. 1 expect(update_call_values.to_s).to eq('{:state=>"active", :redirectUrl=>"https://example.com/redirect", :redirectMethod=>"POST", :username=>"mySecretUsername", :password=>"mySecretPassword", :redirectFallbackUrl=>"https://example.com/fallback", :redirectFallbackMethod=>"GET", :fallbackUsername=>"fallbackUser", :fallbackPassword=>"fallbackPass", :tag=>"custom tag"}')
  79. end
  80. end
  81. 1 describe '#eq? #==' do
  82. 1 it 'returns true/false when comparing objects' do
  83. 1 expect(update_call_default.eql?(Bandwidth::UpdateCall.new)).to be true
  84. 1 expect(update_call_default.eql?(update_call_values)).to be false
  85. end
  86. end
  87. 1 describe '#to_body #to_hash' do
  88. 1 it 'returns a hash representation of the object' do
  89. 1 expect(update_call_values.to_body).to eq({
  90. state: Bandwidth::CallStateEnum::ACTIVE,
  91. redirectUrl: 'https://example.com/redirect',
  92. redirectMethod: Bandwidth::RedirectMethodEnum::POST,
  93. username: 'mySecretUsername',
  94. password: 'mySecretPassword',
  95. redirectFallbackUrl: 'https://example.com/fallback',
  96. redirectFallbackMethod: Bandwidth::RedirectMethodEnum::GET,
  97. fallbackUsername: 'fallbackUser',
  98. fallbackPassword: 'fallbackPass',
  99. tag: 'custom tag'
  100. })
  101. end
  102. end
  103. 1 describe 'custom attribute writers' do
  104. 1 it '#username=' do
  105. 1 expect {
  106. 1 Bandwidth::UpdateCall.new({ username: 'a' * 1025 })
  107. }.to raise_error(ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 1024.')
  108. end
  109. 1 it '#password=' do
  110. 1 expect {
  111. 1 Bandwidth::UpdateCall.new({ password: 'a' * 1025 })
  112. }.to raise_error(ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 1024.')
  113. end
  114. 1 it '#fallback_username=' do
  115. 1 expect {
  116. 1 Bandwidth::UpdateCall.new({ fallback_username: 'a' * 1025 })
  117. }.to raise_error(ArgumentError, 'invalid value for "fallback_username", the character length must be smaller than or equal to 1024.')
  118. end
  119. 1 it '#fallback_password=' do
  120. 1 expect {
  121. 1 Bandwidth::UpdateCall.new({ fallback_password: 'a' * 1025 })
  122. }.to raise_error(ArgumentError, 'invalid value for "fallback_password", the character length must be smaller than or equal to 1024.')
  123. end
  124. 1 it '#tag=' do
  125. 1 expect {
  126. 1 Bandwidth::UpdateCall.new({ tag: 'a' * 4097 })
  127. }.to raise_error(ArgumentError, 'invalid value for "tag", the character length must be smaller than or equal to 4096.')
  128. end
  129. end
  130. end

spec/unit/models/update_conference_member_spec.rb

100.0% lines covered

33 relevant lines. 33 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::UpdateConferenceMember
  2. 1 describe Bandwidth::UpdateConferenceMember do
  3. 2 let(:update_conference_member_default) { Bandwidth::UpdateConferenceMember.new }
  4. 4 let(:update_conference_member_values) { Bandwidth::UpdateConferenceMember.new({
  5. mute: true,
  6. hold: false,
  7. call_ids_to_coach: ['c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85']
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::UpdateConferenceMember.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::UpdateConferenceMember.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::UpdateConferenceMember.acceptable_attributes).to eq(Bandwidth::UpdateConferenceMember.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be the set of nullable fields' do
  28. 1 expect(Bandwidth::UpdateConferenceMember.openapi_nullable).to eq(Set.new([:'call_ids_to_coach']))
  29. end
  30. end
  31. 1 describe '#build_from_hash' do
  32. 1 it 'validates instance of UpdateConferenceMember created by the build_from_hash method' do
  33. 1 update_conference_member_from_hash = Bandwidth::UpdateConferenceMember.build_from_hash({
  34. mute: true,
  35. hold: false,
  36. callIdsToCoach: ['c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85']
  37. })
  38. 1 expect(update_conference_member_from_hash).to be_instance_of(Bandwidth::UpdateConferenceMember)
  39. 1 expect(update_conference_member_from_hash.mute).to eq(true)
  40. 1 expect(update_conference_member_from_hash.hold).to eq(false)
  41. 1 expect(update_conference_member_from_hash.call_ids_to_coach).to eq(['c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85'])
  42. end
  43. end
  44. 1 describe '#to_s' do
  45. 1 it 'returns a string representation of the object' do
  46. 1 expect(update_conference_member_values.to_s).to eq('{:mute=>true, :hold=>false, :callIdsToCoach=>["c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"]}')
  47. end
  48. end
  49. 1 describe '#eq? #==' do
  50. 1 it 'returns true/false when comparing objects' do
  51. 1 expect(update_conference_member_default.eql?(Bandwidth::UpdateConferenceMember.new)).to be true
  52. 1 expect(update_conference_member_default.eql?(update_conference_member_values)).to be false
  53. end
  54. end
  55. 1 describe '#to_body #to_hash' do
  56. 1 it 'returns a hash representation of the object' do
  57. 1 expect(update_conference_member_values.to_body).to eq({
  58. mute: true,
  59. hold: false,
  60. callIdsToCoach: ['c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85']
  61. })
  62. end
  63. end
  64. end

spec/unit/models/update_conference_spec.rb

100.0% lines covered

52 relevant lines. 52 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::UpdateConference
  2. 1 describe Bandwidth::UpdateConference do
  3. 2 let(:update_conference_default) { Bandwidth::UpdateConference.new }
  4. 4 let(:update_conference_values) { Bandwidth::UpdateConference.new({
  5. status: Bandwidth::ConferenceStateEnum::ACTIVE,
  6. redirect_url: 'https://example.com/redirect',
  7. redirect_method: Bandwidth::RedirectMethodEnum::POST,
  8. username: 'mySecretUsername',
  9. password: 'mySecretPassword',
  10. redirect_fallback_url: 'https://example.com/fallback',
  11. redirect_fallback_method: Bandwidth::RedirectMethodEnum::GET,
  12. fallback_username: 'fallbackUser',
  13. fallback_password: 'fallbackPass'
  14. }) }
  15. 1 describe '#initialize' do
  16. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  17. 1 expect {
  18. 1 Bandwidth::UpdateConference.new([])
  19. }.to raise_error(ArgumentError)
  20. end
  21. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  22. 1 expect {
  23. 1 Bandwidth::UpdateConference.new({ invalid: true })
  24. }.to raise_error(ArgumentError)
  25. end
  26. end
  27. 1 describe '#acceptable_attributes' do
  28. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  29. 1 expect(Bandwidth::UpdateConference.acceptable_attributes).to eq(Bandwidth::UpdateConference.attribute_map.values)
  30. end
  31. end
  32. 1 describe '#openapi_nullable' do
  33. 1 it 'expects nullable attributes to be the set of nullable fields' do
  34. 1 expect(Bandwidth::UpdateConference.openapi_nullable).to eq(Set.new([
  35. :'status',
  36. :'redirect_url',
  37. :'redirect_method',
  38. :'username',
  39. :'password',
  40. :'redirect_fallback_url',
  41. :'redirect_fallback_method',
  42. :'fallback_username',
  43. :'fallback_password'
  44. ]))
  45. end
  46. end
  47. 1 describe '#build_from_hash' do
  48. 1 it 'validates instance of UpdateConference created by the build_from_hash method' do
  49. 1 update_conference_from_hash = Bandwidth::UpdateConference.build_from_hash({
  50. status: Bandwidth::ConferenceStateEnum::ACTIVE,
  51. redirectUrl: 'https://example.com/redirect',
  52. redirectMethod: Bandwidth::RedirectMethodEnum::POST,
  53. username: 'mySecretUsername',
  54. password: 'mySecretPassword',
  55. redirectFallbackUrl: 'https://example.com/fallback',
  56. redirectFallbackMethod: Bandwidth::RedirectMethodEnum::GET,
  57. fallbackUsername: 'fallbackUser',
  58. fallbackPassword: 'fallbackPass'
  59. })
  60. 1 expect(update_conference_from_hash).to be_instance_of(Bandwidth::UpdateConference)
  61. 1 expect(update_conference_from_hash.status).to eq(Bandwidth::ConferenceStateEnum::ACTIVE)
  62. 1 expect(update_conference_from_hash.redirect_url).to eq('https://example.com/redirect')
  63. 1 expect(update_conference_from_hash.redirect_method).to eq(Bandwidth::RedirectMethodEnum::POST)
  64. 1 expect(update_conference_from_hash.username).to eq('mySecretUsername')
  65. 1 expect(update_conference_from_hash.password).to eq('mySecretPassword')
  66. 1 expect(update_conference_from_hash.redirect_fallback_url).to eq('https://example.com/fallback')
  67. 1 expect(update_conference_from_hash.redirect_fallback_method).to eq(Bandwidth::RedirectMethodEnum::GET)
  68. 1 expect(update_conference_from_hash.fallback_username).to eq('fallbackUser')
  69. 1 expect(update_conference_from_hash.fallback_password).to eq('fallbackPass')
  70. end
  71. end
  72. 1 describe '#to_s' do
  73. 1 it 'returns a string representation of the object' do
  74. 1 expect(update_conference_values.to_s).to eq('{:status=>"active", :redirectUrl=>"https://example.com/redirect", :redirectMethod=>"POST", :username=>"mySecretUsername", :password=>"mySecretPassword", :redirectFallbackUrl=>"https://example.com/fallback", :redirectFallbackMethod=>"GET", :fallbackUsername=>"fallbackUser", :fallbackPassword=>"fallbackPass"}')
  75. end
  76. end
  77. 1 describe '#eq? #==' do
  78. 1 it 'returns true/false when comparing objects' do
  79. 1 expect(update_conference_default.eql?(Bandwidth::UpdateConference.new)).to be true
  80. 1 expect(update_conference_default.eql?(update_conference_values)).to be false
  81. end
  82. end
  83. 1 describe '#to_body #to_hash' do
  84. 1 it 'returns a hash representation of the object' do
  85. 1 expect(update_conference_values.to_body).to eq({
  86. status: Bandwidth::ConferenceStateEnum::ACTIVE,
  87. redirectUrl: 'https://example.com/redirect',
  88. redirectMethod: Bandwidth::RedirectMethodEnum::POST,
  89. username: 'mySecretUsername',
  90. password: 'mySecretPassword',
  91. redirectFallbackUrl: 'https://example.com/fallback',
  92. redirectFallbackMethod: Bandwidth::RedirectMethodEnum::GET,
  93. fallbackUsername: 'fallbackUser',
  94. fallbackPassword: 'fallbackPass'
  95. })
  96. end
  97. end
  98. 1 describe 'custom attribute writers' do
  99. 1 it '#username=' do
  100. 1 expect {
  101. 1 Bandwidth::UpdateConference.new({ username: 'a' * 1025 })
  102. }.to raise_error(ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 1024.')
  103. end
  104. 1 it '#password=' do
  105. 1 expect {
  106. 1 Bandwidth::UpdateConference.new({ password: 'a' * 1025 })
  107. }.to raise_error(ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 1024.')
  108. end
  109. 1 it '#fallback_username=' do
  110. 1 expect {
  111. 1 Bandwidth::UpdateConference.new({ fallback_username: 'a' * 1025 })
  112. }.to raise_error(ArgumentError, 'invalid value for "fallback_username", the character length must be smaller than or equal to 1024.')
  113. end
  114. 1 it '#fallback_password=' do
  115. 1 expect {
  116. 1 Bandwidth::UpdateConference.new({ fallback_password: 'a' * 1025 })
  117. }.to raise_error(ArgumentError, 'invalid value for "fallback_password", the character length must be smaller than or equal to 1024.')
  118. end
  119. end
  120. end

spec/unit/models/verification_denial_webhook_spec.rb

100.0% lines covered

51 relevant lines. 51 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::VerificationDenialWebhook
  2. 1 describe Bandwidth::VerificationDenialWebhook do
  3. 2 let(:verification_denial_webhook_default) { Bandwidth::VerificationDenialWebhook.new }
  4. 4 let(:verification_denial_webhook_values) { Bandwidth::VerificationDenialWebhook.new({
  5. account_id: '9900000',
  6. additional_denial_reasons: [
  7. Bandwidth::AdditionalDenialReason.new({ status_code: 100, reason: 'reason text', resubmit_allowed: true })
  8. ],
  9. decline_reason_description: 'The reason for declining',
  10. denial_status_code: 100,
  11. internal_ticket_number: '8c8f33f8-0d72-43c8-8b6c-1da8f0a9e6b3',
  12. phone_number: '+18005554321',
  13. resubmit_allowed: true,
  14. status: 'UNVERIFIED',
  15. blocked: false,
  16. blocked_reason: 'The reason for blocking'
  17. }) }
  18. 1 describe '#initialize' do
  19. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  20. 1 expect {
  21. 1 Bandwidth::VerificationDenialWebhook.new([])
  22. }.to raise_error(ArgumentError)
  23. end
  24. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  25. 1 expect {
  26. 1 Bandwidth::VerificationDenialWebhook.new({ invalid: true })
  27. }.to raise_error(ArgumentError)
  28. end
  29. end
  30. 1 describe '#acceptable_attributes' do
  31. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  32. 1 expect(Bandwidth::VerificationDenialWebhook.acceptable_attributes).to eq(Bandwidth::VerificationDenialWebhook.attribute_map.values)
  33. end
  34. end
  35. 1 describe '#openapi_nullable' do
  36. 1 it 'expects nullable attributes to be an empty set' do
  37. 1 expect(Bandwidth::VerificationDenialWebhook.openapi_nullable).to eq(Set.new([]))
  38. end
  39. end
  40. 1 describe '#build_from_hash' do
  41. 1 it 'validates instance of VerificationDenialWebhook created by the build_from_hash method' do
  42. 1 verification_denial_webhook_from_hash = Bandwidth::VerificationDenialWebhook.build_from_hash({
  43. accountId: '9900000',
  44. additionalDenialReasons: [{ statusCode: 100, reason: 'reason text', resubmitAllowed: true }],
  45. declineReasonDescription: 'The reason for declining',
  46. denialStatusCode: 100,
  47. internalTicketNumber: '8c8f33f8-0d72-43c8-8b6c-1da8f0a9e6b3',
  48. phoneNumber: '+18005554321',
  49. resubmitAllowed: true,
  50. status: 'UNVERIFIED',
  51. blocked: false,
  52. blockedReason: 'The reason for blocking'
  53. })
  54. 1 expect(verification_denial_webhook_from_hash).to be_instance_of(Bandwidth::VerificationDenialWebhook)
  55. 1 expect(verification_denial_webhook_from_hash.account_id).to eq('9900000')
  56. 1 expect(verification_denial_webhook_from_hash.additional_denial_reasons).to be_instance_of(Array)
  57. 1 expect(verification_denial_webhook_from_hash.additional_denial_reasons.first).to be_instance_of(Bandwidth::AdditionalDenialReason)
  58. 1 expect(verification_denial_webhook_from_hash.decline_reason_description).to eq('The reason for declining')
  59. 1 expect(verification_denial_webhook_from_hash.denial_status_code).to eq(100)
  60. 1 expect(verification_denial_webhook_from_hash.internal_ticket_number).to eq('8c8f33f8-0d72-43c8-8b6c-1da8f0a9e6b3')
  61. 1 expect(verification_denial_webhook_from_hash.phone_number).to eq('+18005554321')
  62. 1 expect(verification_denial_webhook_from_hash.resubmit_allowed).to eq(true)
  63. 1 expect(verification_denial_webhook_from_hash.status).to eq('UNVERIFIED')
  64. 1 expect(verification_denial_webhook_from_hash.blocked).to eq(false)
  65. 1 expect(verification_denial_webhook_from_hash.blocked_reason).to eq('The reason for blocking')
  66. end
  67. end
  68. 1 describe '#to_s' do
  69. 1 it 'returns a string representation of the object' do
  70. 1 expect(verification_denial_webhook_values.to_s).to eq('{:accountId=>"9900000", :additionalDenialReasons=>[{:statusCode=>100, :reason=>"reason text", :resubmitAllowed=>true}], :declineReasonDescription=>"The reason for declining", :denialStatusCode=>100, :internalTicketNumber=>"8c8f33f8-0d72-43c8-8b6c-1da8f0a9e6b3", :phoneNumber=>"+18005554321", :resubmitAllowed=>true, :status=>"UNVERIFIED", :blocked=>false, :blockedReason=>"The reason for blocking"}')
  71. end
  72. end
  73. 1 describe '#eq? #==' do
  74. 1 it 'returns true/false when comparing objects' do
  75. 1 expect(verification_denial_webhook_default.eql?(Bandwidth::VerificationDenialWebhook.new)).to be true
  76. 1 expect(verification_denial_webhook_default.eql?(verification_denial_webhook_values)).to be false
  77. end
  78. end
  79. 1 describe '#to_body #to_hash' do
  80. 1 it 'returns a hash representation of the object' do
  81. 1 expect(verification_denial_webhook_values.to_body).to eq({
  82. accountId: '9900000',
  83. additionalDenialReasons: [{ statusCode: 100, reason: 'reason text', resubmitAllowed: true }],
  84. declineReasonDescription: 'The reason for declining',
  85. denialStatusCode: 100,
  86. internalTicketNumber: '8c8f33f8-0d72-43c8-8b6c-1da8f0a9e6b3',
  87. phoneNumber: '+18005554321',
  88. resubmitAllowed: true,
  89. status: 'UNVERIFIED',
  90. blocked: false,
  91. blockedReason: 'The reason for blocking'
  92. })
  93. end
  94. end
  95. 1 describe 'custom attribute writers' do
  96. 1 it '#phone_number=' do
  97. 1 expect {
  98. 1 Bandwidth::VerificationDenialWebhook.new({ phone_number: nil })
  99. }.to raise_error(ArgumentError, 'phone_number cannot be nil')
  100. 1 expect {
  101. 1 Bandwidth::VerificationDenialWebhook.new({ phone_number: '+1800555432' })
  102. }.to raise_error(ArgumentError, 'invalid value for "phone_number", the character length must be greater than or equal to 12.')
  103. 1 expect {
  104. 1 Bandwidth::VerificationDenialWebhook.new({ phone_number: '+180055543210' })
  105. }.to raise_error(ArgumentError, 'invalid value for "phone_number", the character length must be smaller than or equal to 12.')
  106. 1 expect {
  107. 1 Bandwidth::VerificationDenialWebhook.new({ phone_number: '+12345678901' })
  108. }.to raise_error(ArgumentError, /invalid value for "phone_number", must conform to the pattern/)
  109. end
  110. end
  111. end

spec/unit/models/verification_request_spec.rb

100.0% lines covered

123 relevant lines. 123 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::VerificationRequest
  2. 1 describe Bandwidth::VerificationRequest do
  3. 2 let(:verification_request_default) { Bandwidth::VerificationRequest.new({
  4. business_address: { name: 'Bandwidth' },
  5. business_contact: { firstName: 'Jane' },
  6. message_volume: 100,
  7. phone_numbers: ['+18005550100'],
  8. use_case: 'baseline use case',
  9. use_case_summary: 'baseline summary',
  10. production_message_content: 'baseline message',
  11. opt_in_workflow: { description: 'baseline opt-in', imageUrls: [] },
  12. business_entity_type: Bandwidth::BusinessEntityTypeEnum::PRIVATE_PROFIT
  13. }) }
  14. 21 let(:verification_request_values) { Bandwidth::VerificationRequest.new({
  15. business_address: { name: 'Bandwidth' },
  16. business_contact: { firstName: 'Jane' },
  17. message_volume: 1000,
  18. phone_numbers: ['+18005554321'],
  19. use_case: 'Customer notifications',
  20. use_case_summary: 'Send customers updates about their orders',
  21. production_message_content: 'Your order has shipped',
  22. opt_in_workflow: { description: 'opt-in via website', imageUrls: ['https://example.com/optin.png'] },
  23. additional_information: 'extra info',
  24. isv_reseller: 'My ISV',
  25. privacy_policy_url: 'https://example.com/privacy',
  26. terms_and_conditions_url: 'https://example.com/terms',
  27. business_dba: 'Bandwidth Inc',
  28. business_registration_number: '12-3456789',
  29. business_registration_type: Bandwidth::BusinessRegistrationTypeEnum::EIN,
  30. business_registration_issuing_country: 'USA',
  31. business_entity_type: Bandwidth::BusinessEntityTypeEnum::PRIVATE_PROFIT,
  32. help_message_response: 'For help reply with HELP',
  33. age_gated_content: false,
  34. cv_token: 'cv_token_value'
  35. }) }
  36. 1 describe '#initialize' do
  37. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  38. 1 expect {
  39. 1 Bandwidth::VerificationRequest.new([])
  40. }.to raise_error(ArgumentError)
  41. end
  42. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  43. 1 expect {
  44. 1 Bandwidth::VerificationRequest.new({ invalid: true })
  45. }.to raise_error(ArgumentError)
  46. end
  47. end
  48. 1 describe '#acceptable_attributes' do
  49. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  50. 1 expect(Bandwidth::VerificationRequest.acceptable_attributes).to eq(Bandwidth::VerificationRequest.attribute_map.values)
  51. end
  52. end
  53. 1 describe '#openapi_nullable' do
  54. 1 it 'expects nullable attributes to be the set of nullable fields' do
  55. 1 expect(Bandwidth::VerificationRequest.openapi_nullable).to eq(Set.new([
  56. :'additional_information',
  57. :'isv_reseller',
  58. :'business_registration_number',
  59. :'business_registration_type',
  60. :'business_registration_issuing_country',
  61. :'help_message_response',
  62. :'cv_token'
  63. ]))
  64. end
  65. end
  66. 1 describe '#build_from_hash' do
  67. 1 it 'validates instance of VerificationRequest created by the build_from_hash method' do
  68. 1 verification_request_from_hash = Bandwidth::VerificationRequest.build_from_hash({
  69. businessAddress: { name: 'Bandwidth', addr1: '900 Main Campus Dr', city: 'Raleigh', state: 'NC', zip: '27606', url: 'https://www.bandwidth.com' },
  70. businessContact: { firstName: 'Jane', lastName: 'Doe', email: 'jane@bandwidth.com', phoneNumber: '+19195551234' },
  71. messageVolume: 1000,
  72. phoneNumbers: ['+18005554321'],
  73. useCase: 'Customer notifications',
  74. useCaseSummary: 'Send customers updates about their orders',
  75. productionMessageContent: 'Your order has shipped',
  76. optInWorkflow: { description: 'opt-in via website', imageUrls: ['https://example.com/optin.png'] },
  77. additionalInformation: 'extra info',
  78. isvReseller: 'My ISV',
  79. privacyPolicyUrl: 'https://example.com/privacy',
  80. termsAndConditionsUrl: 'https://example.com/terms',
  81. businessDba: 'Bandwidth Inc',
  82. businessRegistrationNumber: '12-3456789',
  83. businessRegistrationType: Bandwidth::BusinessRegistrationTypeEnum::EIN,
  84. businessRegistrationIssuingCountry: 'USA',
  85. businessEntityType: Bandwidth::BusinessEntityTypeEnum::PRIVATE_PROFIT,
  86. helpMessageResponse: 'For help reply with HELP',
  87. ageGatedContent: false,
  88. cvToken: 'cv_token_value'
  89. })
  90. 1 expect(verification_request_from_hash).to be_instance_of(Bandwidth::VerificationRequest)
  91. 1 expect(verification_request_from_hash.business_address).to be_instance_of(Bandwidth::Address)
  92. 1 expect(verification_request_from_hash.business_contact).to be_instance_of(Bandwidth::Contact)
  93. 1 expect(verification_request_from_hash.message_volume).to eq(1000)
  94. 1 expect(verification_request_from_hash.phone_numbers).to eq(['+18005554321'])
  95. 1 expect(verification_request_from_hash.use_case).to eq('Customer notifications')
  96. 1 expect(verification_request_from_hash.use_case_summary).to eq('Send customers updates about their orders')
  97. 1 expect(verification_request_from_hash.production_message_content).to eq('Your order has shipped')
  98. 1 expect(verification_request_from_hash.opt_in_workflow).to be_instance_of(Bandwidth::OptInWorkflow)
  99. 1 expect(verification_request_from_hash.additional_information).to eq('extra info')
  100. 1 expect(verification_request_from_hash.isv_reseller).to eq('My ISV')
  101. 1 expect(verification_request_from_hash.privacy_policy_url).to eq('https://example.com/privacy')
  102. 1 expect(verification_request_from_hash.terms_and_conditions_url).to eq('https://example.com/terms')
  103. 1 expect(verification_request_from_hash.business_dba).to eq('Bandwidth Inc')
  104. 1 expect(verification_request_from_hash.business_registration_number).to eq('12-3456789')
  105. 1 expect(verification_request_from_hash.business_registration_type).to eq(Bandwidth::BusinessRegistrationTypeEnum::EIN)
  106. 1 expect(verification_request_from_hash.business_registration_issuing_country).to eq('USA')
  107. 1 expect(verification_request_from_hash.business_entity_type).to eq(Bandwidth::BusinessEntityTypeEnum::PRIVATE_PROFIT)
  108. 1 expect(verification_request_from_hash.help_message_response).to eq('For help reply with HELP')
  109. 1 expect(verification_request_from_hash.age_gated_content).to eq(false)
  110. 1 expect(verification_request_from_hash.cv_token).to eq('cv_token_value')
  111. end
  112. end
  113. 1 describe '#to_s' do
  114. 1 it 'returns a string representation of the object' do
  115. 1 expect(verification_request_values.to_s).to eq('{:businessAddress=>{:name=>"Bandwidth"}, :businessContact=>{:firstName=>"Jane"}, :messageVolume=>1000, :phoneNumbers=>["+18005554321"], :useCase=>"Customer notifications", :useCaseSummary=>"Send customers updates about their orders", :productionMessageContent=>"Your order has shipped", :optInWorkflow=>{:description=>"opt-in via website", :imageUrls=>["https://example.com/optin.png"]}, :additionalInformation=>"extra info", :isvReseller=>"My ISV", :privacyPolicyUrl=>"https://example.com/privacy", :termsAndConditionsUrl=>"https://example.com/terms", :businessDba=>"Bandwidth Inc", :businessRegistrationNumber=>"12-3456789", :businessRegistrationType=>"EIN", :businessRegistrationIssuingCountry=>"USA", :businessEntityType=>"PRIVATE_PROFIT", :helpMessageResponse=>"For help reply with HELP", :ageGatedContent=>false, :cvToken=>"cv_token_value"}')
  116. end
  117. end
  118. 1 describe '#eq? #==' do
  119. 1 it 'returns true/false when comparing objects' do
  120. 1 verification_request_equal = Bandwidth::VerificationRequest.new({
  121. business_address: { name: 'Bandwidth' },
  122. business_contact: { firstName: 'Jane' },
  123. message_volume: 100,
  124. phone_numbers: ['+18005550100'],
  125. use_case: 'baseline use case',
  126. use_case_summary: 'baseline summary',
  127. production_message_content: 'baseline message',
  128. opt_in_workflow: { description: 'baseline opt-in', imageUrls: [] },
  129. business_entity_type: Bandwidth::BusinessEntityTypeEnum::PRIVATE_PROFIT
  130. })
  131. 1 expect(verification_request_default.eql?(verification_request_equal)).to be true
  132. 1 expect(verification_request_default.eql?(verification_request_values)).to be false
  133. end
  134. end
  135. 1 describe '#to_body #to_hash' do
  136. 1 it 'returns a hash representation of the object' do
  137. 1 expect(verification_request_values.to_body).to eq({
  138. businessAddress: { name: 'Bandwidth' },
  139. businessContact: { firstName: 'Jane' },
  140. messageVolume: 1000,
  141. phoneNumbers: ['+18005554321'],
  142. useCase: 'Customer notifications',
  143. useCaseSummary: 'Send customers updates about their orders',
  144. productionMessageContent: 'Your order has shipped',
  145. optInWorkflow: { description: 'opt-in via website', imageUrls: ['https://example.com/optin.png'] },
  146. additionalInformation: 'extra info',
  147. isvReseller: 'My ISV',
  148. privacyPolicyUrl: 'https://example.com/privacy',
  149. termsAndConditionsUrl: 'https://example.com/terms',
  150. businessDba: 'Bandwidth Inc',
  151. businessRegistrationNumber: '12-3456789',
  152. businessRegistrationType: Bandwidth::BusinessRegistrationTypeEnum::EIN,
  153. businessRegistrationIssuingCountry: 'USA',
  154. businessEntityType: Bandwidth::BusinessEntityTypeEnum::PRIVATE_PROFIT,
  155. helpMessageResponse: 'For help reply with HELP',
  156. ageGatedContent: false,
  157. cvToken: 'cv_token_value'
  158. })
  159. end
  160. end
  161. 1 describe 'custom attribute writers' do
  162. 1 it '#business_address=' do
  163. 1 expect {
  164. 1 verification_request_values.business_address = nil
  165. }.to raise_error(ArgumentError, 'business_address cannot be nil')
  166. end
  167. 1 it '#business_contact=' do
  168. 1 expect {
  169. 1 verification_request_values.business_contact = nil
  170. }.to raise_error(ArgumentError, 'business_contact cannot be nil')
  171. end
  172. 1 it '#message_volume=' do
  173. 1 expect {
  174. 1 verification_request_values.message_volume = nil
  175. }.to raise_error(ArgumentError, 'message_volume cannot be nil')
  176. 1 expect {
  177. 1 verification_request_values.message_volume = 10000001
  178. }.to raise_error(ArgumentError, 'invalid value for "message_volume", must be smaller than or equal to 10000000.')
  179. 1 expect {
  180. 1 verification_request_values.message_volume = 9
  181. }.to raise_error(ArgumentError, 'invalid value for "message_volume", must be greater than or equal to 10.')
  182. end
  183. 1 it '#phone_numbers=' do
  184. 1 expect {
  185. 1 verification_request_values.phone_numbers = nil
  186. }.to raise_error(ArgumentError, 'phone_numbers cannot be nil')
  187. 1 expect {
  188. 12 verification_request_values.phone_numbers = Array.new(11) { '+18005551234' }
  189. }.to raise_error(ArgumentError, 'invalid value for "phone_numbers", number of items must be less than or equal to 10.')
  190. 1 expect {
  191. 1 verification_request_values.phone_numbers = []
  192. }.to raise_error(ArgumentError, 'invalid value for "phone_numbers", number of items must be greater than or equal to 1.')
  193. end
  194. 1 it '#use_case=' do
  195. 1 expect {
  196. 1 verification_request_values.use_case = nil
  197. }.to raise_error(ArgumentError, 'use_case cannot be nil')
  198. 1 expect {
  199. 1 verification_request_values.use_case = 'a' * 501
  200. }.to raise_error(ArgumentError, 'invalid value for "use_case", the character length must be smaller than or equal to 500.')
  201. end
  202. 1 it '#use_case_summary=' do
  203. 1 expect {
  204. 1 verification_request_values.use_case_summary = nil
  205. }.to raise_error(ArgumentError, 'use_case_summary cannot be nil')
  206. 1 expect {
  207. 1 verification_request_values.use_case_summary = 'a' * 501
  208. }.to raise_error(ArgumentError, 'invalid value for "use_case_summary", the character length must be smaller than or equal to 500.')
  209. end
  210. 1 it '#production_message_content=' do
  211. 1 expect {
  212. 1 verification_request_values.production_message_content = nil
  213. }.to raise_error(ArgumentError, 'production_message_content cannot be nil')
  214. 1 expect {
  215. 1 verification_request_values.production_message_content = 'a' * 501
  216. }.to raise_error(ArgumentError, 'invalid value for "production_message_content", the character length must be smaller than or equal to 500.')
  217. end
  218. 1 it '#opt_in_workflow=' do
  219. 1 expect {
  220. 1 verification_request_values.opt_in_workflow = nil
  221. }.to raise_error(ArgumentError, 'opt_in_workflow cannot be nil')
  222. end
  223. 1 it '#additional_information=' do
  224. 1 expect {
  225. 1 verification_request_values.additional_information = 'a' * 501
  226. }.to raise_error(ArgumentError, 'invalid value for "additional_information", the character length must be smaller than or equal to 500.')
  227. end
  228. 1 it '#isv_reseller=' do
  229. 1 expect {
  230. 1 verification_request_values.isv_reseller = 'a' * 501
  231. }.to raise_error(ArgumentError, 'invalid value for "isv_reseller", the character length must be smaller than or equal to 500.')
  232. end
  233. 1 it '#privacy_policy_url=' do
  234. 1 expect {
  235. 1 verification_request_values.privacy_policy_url = nil
  236. }.to raise_error(ArgumentError, 'privacy_policy_url cannot be nil')
  237. 1 expect {
  238. 1 verification_request_values.privacy_policy_url = 'a' * 501
  239. }.to raise_error(ArgumentError, 'invalid value for "privacy_policy_url", the character length must be smaller than or equal to 500.')
  240. end
  241. 1 it '#terms_and_conditions_url=' do
  242. 1 expect {
  243. 1 verification_request_values.terms_and_conditions_url = nil
  244. }.to raise_error(ArgumentError, 'terms_and_conditions_url cannot be nil')
  245. 1 expect {
  246. 1 verification_request_values.terms_and_conditions_url = 'a' * 501
  247. }.to raise_error(ArgumentError, 'invalid value for "terms_and_conditions_url", the character length must be smaller than or equal to 500.')
  248. end
  249. 1 it '#business_dba=' do
  250. 1 expect {
  251. 1 verification_request_values.business_dba = nil
  252. }.to raise_error(ArgumentError, 'business_dba cannot be nil')
  253. 1 expect {
  254. 1 verification_request_values.business_dba = 'a' * 501
  255. }.to raise_error(ArgumentError, 'invalid value for "business_dba", the character length must be smaller than or equal to 500.')
  256. end
  257. 1 it '#business_registration_number=' do
  258. 1 expect {
  259. 1 verification_request_values.business_registration_number = 'a' * 501
  260. }.to raise_error(ArgumentError, 'invalid value for "business_registration_number", the character length must be smaller than or equal to 500.')
  261. end
  262. 1 it '#business_entity_type=' do
  263. 1 expect {
  264. 1 verification_request_values.business_entity_type = nil
  265. }.to raise_error(ArgumentError, 'business_entity_type cannot be nil')
  266. end
  267. 1 it '#help_message_response=' do
  268. 1 expect {
  269. 1 verification_request_values.help_message_response = 'a' * 501
  270. }.to raise_error(ArgumentError, 'invalid value for "help_message_response", the character length must be smaller than or equal to 500.')
  271. end
  272. 1 it '#cv_token=' do
  273. 1 expect {
  274. 1 verification_request_values.cv_token = 'a' * 501
  275. }.to raise_error(ArgumentError, 'invalid value for "cv_token", the character length must be smaller than or equal to 500.')
  276. end
  277. end
  278. end

spec/unit/models/verification_update_request_spec.rb

100.0% lines covered

112 relevant lines. 112 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::VerificationUpdateRequest
  2. 1 describe Bandwidth::VerificationUpdateRequest do
  3. 2 let(:verification_update_request_default) { Bandwidth::VerificationUpdateRequest.new({
  4. business_address: { name: 'Bandwidth' },
  5. business_contact: { firstName: 'Jane' },
  6. message_volume: 100,
  7. use_case: 'baseline use case',
  8. use_case_summary: 'baseline summary',
  9. production_message_content: 'baseline message',
  10. opt_in_workflow: { description: 'baseline opt-in', imageUrls: [] }
  11. }) }
  12. 19 let(:verification_update_request_values) { Bandwidth::VerificationUpdateRequest.new({
  13. business_address: { name: 'Bandwidth' },
  14. business_contact: { firstName: 'Jane' },
  15. message_volume: 1000,
  16. use_case: 'Customer notifications',
  17. use_case_summary: 'Send customers updates about their orders',
  18. production_message_content: 'Your order has shipped',
  19. opt_in_workflow: { description: 'opt-in via website', imageUrls: ['https://example.com/optin.png'] },
  20. additional_information: 'extra info',
  21. isv_reseller: 'My ISV',
  22. privacy_policy_url: 'https://example.com/privacy',
  23. terms_and_conditions_url: 'https://example.com/terms',
  24. business_dba: 'Bandwidth Inc',
  25. business_registration_number: '12-3456789',
  26. business_registration_type: Bandwidth::BusinessRegistrationTypeEnum::EIN,
  27. business_entity_type: Bandwidth::BusinessEntityTypeEnum::PRIVATE_PROFIT,
  28. business_registration_issuing_country: 'USA',
  29. help_message_response: 'For help reply with HELP',
  30. age_gated_content: false,
  31. cv_token: 'cv_token_value'
  32. }) }
  33. 1 describe '#initialize' do
  34. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  35. 1 expect {
  36. 1 Bandwidth::VerificationUpdateRequest.new([])
  37. }.to raise_error(ArgumentError)
  38. end
  39. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  40. 1 expect {
  41. 1 Bandwidth::VerificationUpdateRequest.new({ invalid: true })
  42. }.to raise_error(ArgumentError)
  43. end
  44. end
  45. 1 describe '#acceptable_attributes' do
  46. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  47. 1 expect(Bandwidth::VerificationUpdateRequest.acceptable_attributes).to eq(Bandwidth::VerificationUpdateRequest.attribute_map.values)
  48. end
  49. end
  50. 1 describe '#openapi_nullable' do
  51. 1 it 'expects nullable attributes to be the set of nullable fields' do
  52. 1 expect(Bandwidth::VerificationUpdateRequest.openapi_nullable).to eq(Set.new([
  53. :'additional_information',
  54. :'isv_reseller',
  55. :'business_registration_number',
  56. :'business_registration_type',
  57. :'business_registration_issuing_country',
  58. :'help_message_response',
  59. :'cv_token'
  60. ]))
  61. end
  62. end
  63. 1 describe '#build_from_hash' do
  64. 1 it 'validates instance of VerificationUpdateRequest created by the build_from_hash method' do
  65. 1 verification_update_request_from_hash = Bandwidth::VerificationUpdateRequest.build_from_hash({
  66. businessAddress: { name: 'Bandwidth', addr1: '900 Main Campus Dr', city: 'Raleigh', state: 'NC', zip: '27606', url: 'https://www.bandwidth.com' },
  67. businessContact: { firstName: 'Jane', lastName: 'Doe', email: 'jane@bandwidth.com', phoneNumber: '+19195551234' },
  68. messageVolume: 1000,
  69. useCase: 'Customer notifications',
  70. useCaseSummary: 'Send customers updates about their orders',
  71. productionMessageContent: 'Your order has shipped',
  72. optInWorkflow: { description: 'opt-in via website', imageUrls: ['https://example.com/optin.png'] },
  73. additionalInformation: 'extra info',
  74. isvReseller: 'My ISV',
  75. privacyPolicyUrl: 'https://example.com/privacy',
  76. termsAndConditionsUrl: 'https://example.com/terms',
  77. businessDba: 'Bandwidth Inc',
  78. businessRegistrationNumber: '12-3456789',
  79. businessRegistrationType: Bandwidth::BusinessRegistrationTypeEnum::EIN,
  80. businessEntityType: Bandwidth::BusinessEntityTypeEnum::PRIVATE_PROFIT,
  81. businessRegistrationIssuingCountry: 'USA',
  82. helpMessageResponse: 'For help reply with HELP',
  83. ageGatedContent: false,
  84. cvToken: 'cv_token_value'
  85. })
  86. 1 expect(verification_update_request_from_hash).to be_instance_of(Bandwidth::VerificationUpdateRequest)
  87. 1 expect(verification_update_request_from_hash.business_address).to be_instance_of(Bandwidth::Address)
  88. 1 expect(verification_update_request_from_hash.business_contact).to be_instance_of(Bandwidth::Contact)
  89. 1 expect(verification_update_request_from_hash.message_volume).to eq(1000)
  90. 1 expect(verification_update_request_from_hash.use_case).to eq('Customer notifications')
  91. 1 expect(verification_update_request_from_hash.use_case_summary).to eq('Send customers updates about their orders')
  92. 1 expect(verification_update_request_from_hash.production_message_content).to eq('Your order has shipped')
  93. 1 expect(verification_update_request_from_hash.opt_in_workflow).to be_instance_of(Bandwidth::OptInWorkflow)
  94. 1 expect(verification_update_request_from_hash.additional_information).to eq('extra info')
  95. 1 expect(verification_update_request_from_hash.isv_reseller).to eq('My ISV')
  96. 1 expect(verification_update_request_from_hash.privacy_policy_url).to eq('https://example.com/privacy')
  97. 1 expect(verification_update_request_from_hash.terms_and_conditions_url).to eq('https://example.com/terms')
  98. 1 expect(verification_update_request_from_hash.business_dba).to eq('Bandwidth Inc')
  99. 1 expect(verification_update_request_from_hash.business_registration_number).to eq('12-3456789')
  100. 1 expect(verification_update_request_from_hash.business_registration_type).to eq(Bandwidth::BusinessRegistrationTypeEnum::EIN)
  101. 1 expect(verification_update_request_from_hash.business_entity_type).to eq(Bandwidth::BusinessEntityTypeEnum::PRIVATE_PROFIT)
  102. 1 expect(verification_update_request_from_hash.business_registration_issuing_country).to eq('USA')
  103. 1 expect(verification_update_request_from_hash.help_message_response).to eq('For help reply with HELP')
  104. 1 expect(verification_update_request_from_hash.age_gated_content).to eq(false)
  105. 1 expect(verification_update_request_from_hash.cv_token).to eq('cv_token_value')
  106. end
  107. end
  108. 1 describe '#to_s' do
  109. 1 it 'returns a string representation of the object' do
  110. 1 expect(verification_update_request_values.to_s).to eq('{:businessAddress=>{:name=>"Bandwidth"}, :businessContact=>{:firstName=>"Jane"}, :messageVolume=>1000, :useCase=>"Customer notifications", :useCaseSummary=>"Send customers updates about their orders", :productionMessageContent=>"Your order has shipped", :optInWorkflow=>{:description=>"opt-in via website", :imageUrls=>["https://example.com/optin.png"]}, :additionalInformation=>"extra info", :isvReseller=>"My ISV", :privacyPolicyUrl=>"https://example.com/privacy", :termsAndConditionsUrl=>"https://example.com/terms", :businessDba=>"Bandwidth Inc", :businessRegistrationNumber=>"12-3456789", :businessRegistrationType=>"EIN", :businessEntityType=>"PRIVATE_PROFIT", :businessRegistrationIssuingCountry=>"USA", :helpMessageResponse=>"For help reply with HELP", :ageGatedContent=>false, :cvToken=>"cv_token_value"}')
  111. end
  112. end
  113. 1 describe '#eq? #==' do
  114. 1 it 'returns true/false when comparing objects' do
  115. 1 verification_update_request_equal = Bandwidth::VerificationUpdateRequest.new({
  116. business_address: { name: 'Bandwidth' },
  117. business_contact: { firstName: 'Jane' },
  118. message_volume: 100,
  119. use_case: 'baseline use case',
  120. use_case_summary: 'baseline summary',
  121. production_message_content: 'baseline message',
  122. opt_in_workflow: { description: 'baseline opt-in', imageUrls: [] }
  123. })
  124. 1 expect(verification_update_request_default.eql?(verification_update_request_equal)).to be true
  125. 1 expect(verification_update_request_default.eql?(verification_update_request_values)).to be false
  126. end
  127. end
  128. 1 describe '#to_body #to_hash' do
  129. 1 it 'returns a hash representation of the object' do
  130. 1 expect(verification_update_request_values.to_body).to eq({
  131. businessAddress: { name: 'Bandwidth' },
  132. businessContact: { firstName: 'Jane' },
  133. messageVolume: 1000,
  134. useCase: 'Customer notifications',
  135. useCaseSummary: 'Send customers updates about their orders',
  136. productionMessageContent: 'Your order has shipped',
  137. optInWorkflow: { description: 'opt-in via website', imageUrls: ['https://example.com/optin.png'] },
  138. additionalInformation: 'extra info',
  139. isvReseller: 'My ISV',
  140. privacyPolicyUrl: 'https://example.com/privacy',
  141. termsAndConditionsUrl: 'https://example.com/terms',
  142. businessDba: 'Bandwidth Inc',
  143. businessRegistrationNumber: '12-3456789',
  144. businessRegistrationType: Bandwidth::BusinessRegistrationTypeEnum::EIN,
  145. businessEntityType: Bandwidth::BusinessEntityTypeEnum::PRIVATE_PROFIT,
  146. businessRegistrationIssuingCountry: 'USA',
  147. helpMessageResponse: 'For help reply with HELP',
  148. ageGatedContent: false,
  149. cvToken: 'cv_token_value'
  150. })
  151. end
  152. end
  153. 1 describe 'custom attribute writers' do
  154. 1 it '#business_address=' do
  155. 1 expect {
  156. 1 verification_update_request_values.business_address = nil
  157. }.to raise_error(ArgumentError, 'business_address cannot be nil')
  158. end
  159. 1 it '#business_contact=' do
  160. 1 expect {
  161. 1 verification_update_request_values.business_contact = nil
  162. }.to raise_error(ArgumentError, 'business_contact cannot be nil')
  163. end
  164. 1 it '#message_volume=' do
  165. 1 expect {
  166. 1 verification_update_request_values.message_volume = nil
  167. }.to raise_error(ArgumentError, 'message_volume cannot be nil')
  168. 1 expect {
  169. 1 verification_update_request_values.message_volume = 10000001
  170. }.to raise_error(ArgumentError, 'invalid value for "message_volume", must be smaller than or equal to 10000000.')
  171. 1 expect {
  172. 1 verification_update_request_values.message_volume = 9
  173. }.to raise_error(ArgumentError, 'invalid value for "message_volume", must be greater than or equal to 10.')
  174. end
  175. 1 it '#use_case=' do
  176. 1 expect {
  177. 1 verification_update_request_values.use_case = nil
  178. }.to raise_error(ArgumentError, 'use_case cannot be nil')
  179. 1 expect {
  180. 1 verification_update_request_values.use_case = 'a' * 501
  181. }.to raise_error(ArgumentError, 'invalid value for "use_case", the character length must be smaller than or equal to 500.')
  182. end
  183. 1 it '#use_case_summary=' do
  184. 1 expect {
  185. 1 verification_update_request_values.use_case_summary = nil
  186. }.to raise_error(ArgumentError, 'use_case_summary cannot be nil')
  187. 1 expect {
  188. 1 verification_update_request_values.use_case_summary = 'a' * 501
  189. }.to raise_error(ArgumentError, 'invalid value for "use_case_summary", the character length must be smaller than or equal to 500.')
  190. end
  191. 1 it '#production_message_content=' do
  192. 1 expect {
  193. 1 verification_update_request_values.production_message_content = nil
  194. }.to raise_error(ArgumentError, 'production_message_content cannot be nil')
  195. 1 expect {
  196. 1 verification_update_request_values.production_message_content = 'a' * 501
  197. }.to raise_error(ArgumentError, 'invalid value for "production_message_content", the character length must be smaller than or equal to 500.')
  198. end
  199. 1 it '#opt_in_workflow=' do
  200. 1 expect {
  201. 1 verification_update_request_values.opt_in_workflow = nil
  202. }.to raise_error(ArgumentError, 'opt_in_workflow cannot be nil')
  203. end
  204. 1 it '#additional_information=' do
  205. 1 expect {
  206. 1 verification_update_request_values.additional_information = 'a' * 501
  207. }.to raise_error(ArgumentError, 'invalid value for "additional_information", the character length must be smaller than or equal to 500.')
  208. end
  209. 1 it '#isv_reseller=' do
  210. 1 expect {
  211. 1 verification_update_request_values.isv_reseller = 'a' * 501
  212. }.to raise_error(ArgumentError, 'invalid value for "isv_reseller", the character length must be smaller than or equal to 500.')
  213. end
  214. 1 it '#privacy_policy_url=' do
  215. 1 expect {
  216. 1 verification_update_request_values.privacy_policy_url = nil
  217. }.to raise_error(ArgumentError, 'privacy_policy_url cannot be nil')
  218. 1 expect {
  219. 1 verification_update_request_values.privacy_policy_url = 'a' * 501
  220. }.to raise_error(ArgumentError, 'invalid value for "privacy_policy_url", the character length must be smaller than or equal to 500.')
  221. end
  222. 1 it '#terms_and_conditions_url=' do
  223. 1 expect {
  224. 1 verification_update_request_values.terms_and_conditions_url = nil
  225. }.to raise_error(ArgumentError, 'terms_and_conditions_url cannot be nil')
  226. 1 expect {
  227. 1 verification_update_request_values.terms_and_conditions_url = 'a' * 501
  228. }.to raise_error(ArgumentError, 'invalid value for "terms_and_conditions_url", the character length must be smaller than or equal to 500.')
  229. end
  230. 1 it '#business_dba=' do
  231. 1 expect {
  232. 1 verification_update_request_values.business_dba = nil
  233. }.to raise_error(ArgumentError, 'business_dba cannot be nil')
  234. 1 expect {
  235. 1 verification_update_request_values.business_dba = 'a' * 501
  236. }.to raise_error(ArgumentError, 'invalid value for "business_dba", the character length must be smaller than or equal to 500.')
  237. end
  238. 1 it '#business_registration_number=' do
  239. 1 expect {
  240. 1 verification_update_request_values.business_registration_number = 'a' * 501
  241. }.to raise_error(ArgumentError, 'invalid value for "business_registration_number", the character length must be smaller than or equal to 500.')
  242. end
  243. 1 it '#help_message_response=' do
  244. 1 expect {
  245. 1 verification_update_request_values.help_message_response = 'a' * 501
  246. }.to raise_error(ArgumentError, 'invalid value for "help_message_response", the character length must be smaller than or equal to 500.')
  247. end
  248. 1 it '#cv_token=' do
  249. 1 expect {
  250. 1 verification_update_request_values.cv_token = 'a' * 501
  251. }.to raise_error(ArgumentError, 'invalid value for "cv_token", the character length must be smaller than or equal to 500.')
  252. end
  253. end
  254. end

spec/unit/models/verification_webhook_spec.rb

100.0% lines covered

44 relevant lines. 44 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::VerificationWebhook
  2. 1 describe Bandwidth::VerificationWebhook do
  3. 2 let(:verification_webhook_default) { Bandwidth::VerificationWebhook.new }
  4. 4 let(:verification_webhook_values) { Bandwidth::VerificationWebhook.new({
  5. account_id: '9900000',
  6. phone_number: '+18005554321',
  7. status: Bandwidth::TfvCallbackStatusEnum::VERIFIED,
  8. internal_ticket_number: '8c8f33f8-0d72-43c8-8b6c-1da8f0a9e6b3'
  9. }) }
  10. 1 describe '#initialize' do
  11. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  12. 1 expect {
  13. 1 Bandwidth::VerificationWebhook.new([])
  14. }.to raise_error(ArgumentError)
  15. end
  16. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  17. 1 expect {
  18. 1 Bandwidth::VerificationWebhook.new({ invalid: true })
  19. }.to raise_error(ArgumentError)
  20. end
  21. end
  22. 1 describe '#acceptable_attributes' do
  23. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  24. 1 expect(Bandwidth::VerificationWebhook.acceptable_attributes).to eq(Bandwidth::VerificationWebhook.attribute_map.values)
  25. end
  26. end
  27. 1 describe '#openapi_nullable' do
  28. 1 it 'expects nullable attributes to be an empty set' do
  29. 1 expect(Bandwidth::VerificationWebhook.openapi_nullable).to eq(Set.new([]))
  30. end
  31. end
  32. 1 describe '#build_from_hash' do
  33. 1 it 'validates instance of VerificationWebhook created by the build_from_hash method' do
  34. 1 verification_webhook_from_hash = Bandwidth::VerificationWebhook.build_from_hash({
  35. accountId: '9900000',
  36. phoneNumber: '+18005554321',
  37. status: Bandwidth::TfvCallbackStatusEnum::VERIFIED,
  38. internalTicketNumber: '8c8f33f8-0d72-43c8-8b6c-1da8f0a9e6b3'
  39. })
  40. 1 expect(verification_webhook_from_hash).to be_instance_of(Bandwidth::VerificationWebhook)
  41. 1 expect(verification_webhook_from_hash.account_id).to eq('9900000')
  42. 1 expect(verification_webhook_from_hash.phone_number).to eq('+18005554321')
  43. 1 expect(verification_webhook_from_hash.status).to eq(Bandwidth::TfvCallbackStatusEnum::VERIFIED)
  44. 1 expect(verification_webhook_from_hash.internal_ticket_number).to eq('8c8f33f8-0d72-43c8-8b6c-1da8f0a9e6b3')
  45. end
  46. end
  47. 1 describe '#to_s' do
  48. 1 it 'returns a string representation of the object' do
  49. 1 expect(verification_webhook_values.to_s).to eq('{:accountId=>"9900000", :phoneNumber=>"+18005554321", :status=>"VERIFIED", :internalTicketNumber=>"8c8f33f8-0d72-43c8-8b6c-1da8f0a9e6b3"}')
  50. end
  51. end
  52. 1 describe '#eq? #==' do
  53. 1 it 'returns true/false when comparing objects' do
  54. 1 expect(verification_webhook_default.eql?(Bandwidth::VerificationWebhook.new)).to be true
  55. 1 expect(verification_webhook_default.eql?(verification_webhook_values)).to be false
  56. end
  57. end
  58. 1 describe '#to_body #to_hash' do
  59. 1 it 'returns a hash representation of the object' do
  60. 1 expect(verification_webhook_values.to_body).to eq({
  61. accountId: '9900000',
  62. phoneNumber: '+18005554321',
  63. status: Bandwidth::TfvCallbackStatusEnum::VERIFIED,
  64. internalTicketNumber: '8c8f33f8-0d72-43c8-8b6c-1da8f0a9e6b3'
  65. })
  66. end
  67. end
  68. 1 describe 'custom attribute writers' do
  69. 1 it '#phone_number=' do
  70. 1 expect {
  71. 1 Bandwidth::VerificationWebhook.new({ phone_number: nil })
  72. }.to raise_error(ArgumentError, 'phone_number cannot be nil')
  73. 1 expect {
  74. 1 Bandwidth::VerificationWebhook.new({ phone_number: '+1800555432' })
  75. }.to raise_error(ArgumentError, 'invalid value for "phone_number", the character length must be greater than or equal to 12.')
  76. 1 expect {
  77. 1 Bandwidth::VerificationWebhook.new({ phone_number: '+180055543210' })
  78. }.to raise_error(ArgumentError, 'invalid value for "phone_number", the character length must be smaller than or equal to 12.')
  79. 1 expect {
  80. 1 Bandwidth::VerificationWebhook.new({ phone_number: '+12345678901' })
  81. }.to raise_error(ArgumentError, /invalid value for "phone_number", must conform to the pattern/)
  82. end
  83. end
  84. end

spec/unit/models/verify_code_request_spec.rb

100.0% lines covered

55 relevant lines. 55 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::VerifyCodeRequest
  2. 1 describe Bandwidth::VerifyCodeRequest do
  3. 2 let(:verify_code_request_default) { Bandwidth::VerifyCodeRequest.new({
  4. to: '+19195551234',
  5. expiration_time_in_minutes: 1.0,
  6. code: '123456'
  7. }) }
  8. 4 let(:verify_code_request_values) { Bandwidth::VerifyCodeRequest.new({
  9. to: '+19195551234',
  10. scope: '2FA',
  11. expiration_time_in_minutes: 1.0,
  12. code: '123456'
  13. }) }
  14. 1 describe '#initialize' do
  15. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::VerifyCodeRequest.new([])
  18. }.to raise_error(ArgumentError)
  19. end
  20. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  21. 1 expect {
  22. 1 Bandwidth::VerifyCodeRequest.new({ invalid: true })
  23. }.to raise_error(ArgumentError)
  24. end
  25. end
  26. 1 describe '#acceptable_attributes' do
  27. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  28. 1 expect(Bandwidth::VerifyCodeRequest.acceptable_attributes).to eq(Bandwidth::VerifyCodeRequest.attribute_map.values)
  29. end
  30. end
  31. 1 describe '#openapi_nullable' do
  32. 1 it 'expects nullable attributes to be an empty set' do
  33. 1 expect(Bandwidth::VerifyCodeRequest.openapi_nullable).to eq(Set.new([]))
  34. end
  35. end
  36. 1 describe '#build_from_hash' do
  37. 1 it 'validates instance of VerifyCodeRequest created by the build_from_hash method' do
  38. 1 verify_code_request_from_hash = Bandwidth::VerifyCodeRequest.build_from_hash({
  39. to: '+19195551234',
  40. scope: '2FA',
  41. expirationTimeInMinutes: 1.0,
  42. code: '123456'
  43. })
  44. 1 expect(verify_code_request_from_hash).to be_instance_of(Bandwidth::VerifyCodeRequest)
  45. 1 expect(verify_code_request_from_hash.to).to eq('+19195551234')
  46. 1 expect(verify_code_request_from_hash.scope).to eq('2FA')
  47. 1 expect(verify_code_request_from_hash.expiration_time_in_minutes).to eq(1.0)
  48. 1 expect(verify_code_request_from_hash.code).to eq('123456')
  49. end
  50. end
  51. 1 describe '#to_s' do
  52. 1 it 'returns a string representation of the object' do
  53. 1 expect(verify_code_request_values.to_s).to eq('{:to=>"+19195551234", :scope=>"2FA", :expirationTimeInMinutes=>1.0, :code=>"123456"}')
  54. end
  55. end
  56. 1 describe '#eq? #==' do
  57. 1 it 'returns true/false when comparing objects' do
  58. 1 verify_code_request_equal = Bandwidth::VerifyCodeRequest.new({
  59. to: '+19195551234',
  60. expiration_time_in_minutes: 1.0,
  61. code: '123456'
  62. })
  63. 1 expect(verify_code_request_default.eql?(verify_code_request_equal)).to be true
  64. 1 expect(verify_code_request_default.eql?(verify_code_request_values)).to be false
  65. end
  66. end
  67. 1 describe '#to_body #to_hash' do
  68. 1 it 'returns a hash representation of the object' do
  69. 1 expect(verify_code_request_values.to_body).to eq({
  70. to: '+19195551234',
  71. scope: '2FA',
  72. expirationTimeInMinutes: 1.0,
  73. code: '123456'
  74. })
  75. end
  76. end
  77. 1 describe 'custom attribute writers' do
  78. 1 it '#to=' do
  79. 1 expect {
  80. 1 Bandwidth::VerifyCodeRequest.new({ to: nil })
  81. }.to raise_error(ArgumentError, 'to cannot be nil')
  82. 1 expect {
  83. 1 Bandwidth::VerifyCodeRequest.new({ to: 'invalid' })
  84. }.to raise_error(ArgumentError, 'invalid value for "to", must conform to the pattern (?-mix:^\+[1-9]\d{1,14}$).')
  85. end
  86. 1 it '#expiration_time_in_minutes=' do
  87. 1 expect {
  88. 1 Bandwidth::VerifyCodeRequest.new({ to: '+19195551234', expiration_time_in_minutes: nil })
  89. }.to raise_error(ArgumentError, 'expiration_time_in_minutes cannot be nil')
  90. 1 expect {
  91. 1 Bandwidth::VerifyCodeRequest.new({ to: '+19195551234', expiration_time_in_minutes: 16 })
  92. }.to raise_error(ArgumentError, 'invalid value for "expiration_time_in_minutes", must be smaller than or equal to 15.')
  93. 1 expect {
  94. 1 Bandwidth::VerifyCodeRequest.new({ to: '+19195551234', expiration_time_in_minutes: 0 })
  95. }.to raise_error(ArgumentError, 'invalid value for "expiration_time_in_minutes", must be greater than or equal to 1.')
  96. end
  97. 1 it '#code=' do
  98. 1 expect {
  99. 1 Bandwidth::VerifyCodeRequest.new({ to: '+19195551234', expiration_time_in_minutes: 1, code: nil })
  100. }.to raise_error(ArgumentError, 'code cannot be nil')
  101. 1 expect {
  102. 1 Bandwidth::VerifyCodeRequest.new({ to: '+19195551234', expiration_time_in_minutes: 1, code: '123456789' })
  103. }.to raise_error(ArgumentError, 'invalid value for "code", the character length must be smaller than or equal to 8.')
  104. 1 expect {
  105. 1 Bandwidth::VerifyCodeRequest.new({ to: '+19195551234', expiration_time_in_minutes: 1, code: '123' })
  106. }.to raise_error(ArgumentError, 'invalid value for "code", the character length must be greater than or equal to 4.')
  107. end
  108. end
  109. end

spec/unit/models/verify_code_response_spec.rb

100.0% lines covered

31 relevant lines. 31 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::VerifyCodeResponse
  2. 1 describe Bandwidth::VerifyCodeResponse do
  3. 2 let(:verify_code_response_default) { Bandwidth::VerifyCodeResponse.new }
  4. 4 let(:verify_code_response_values) { Bandwidth::VerifyCodeResponse.new({
  5. valid: true
  6. }) }
  7. 1 describe '#initialize' do
  8. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  9. 1 expect {
  10. 1 Bandwidth::VerifyCodeResponse.new([])
  11. }.to raise_error(ArgumentError)
  12. end
  13. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  14. 1 expect {
  15. 1 Bandwidth::VerifyCodeResponse.new({ invalid: true })
  16. }.to raise_error(ArgumentError)
  17. end
  18. end
  19. 1 describe '#acceptable_attributes' do
  20. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  21. 1 expect(Bandwidth::VerifyCodeResponse.acceptable_attributes).to eq(Bandwidth::VerifyCodeResponse.attribute_map.values)
  22. end
  23. end
  24. 1 describe '#openapi_nullable' do
  25. 1 it 'expects nullable attributes to be an empty set' do
  26. 1 expect(Bandwidth::VerifyCodeResponse.openapi_nullable).to eq(Set.new([]))
  27. end
  28. end
  29. 1 describe '#build_from_hash' do
  30. 1 it 'validates instance of VerifyCodeResponse created by the build_from_hash method' do
  31. 1 verify_code_response_from_hash = Bandwidth::VerifyCodeResponse.build_from_hash({
  32. valid: true
  33. })
  34. 1 expect(verify_code_response_from_hash).to be_instance_of(Bandwidth::VerifyCodeResponse)
  35. 1 expect(verify_code_response_from_hash.valid).to be true
  36. end
  37. end
  38. 1 describe '#to_s' do
  39. 1 it 'returns a string representation of the object' do
  40. 1 expect(verify_code_response_values.to_s).to eq('{:valid=>true}')
  41. end
  42. end
  43. 1 describe '#eq? #==' do
  44. 1 it 'returns true/false when comparing objects' do
  45. 1 expect(verify_code_response_default.eql?(Bandwidth::VerifyCodeResponse.new)).to be true
  46. 1 expect(verify_code_response_default.eql?(verify_code_response_values)).to be false
  47. end
  48. end
  49. 1 describe '#to_body #to_hash' do
  50. 1 it 'returns a hash representation of the object' do
  51. 1 expect(verify_code_response_values.to_body).to eq({
  52. valid: true
  53. })
  54. end
  55. end
  56. end

spec/unit/models/voice_api_error_spec.rb

100.0% lines covered

33 relevant lines. 33 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::VoiceApiError
  2. 1 describe Bandwidth::VoiceApiError do
  3. 2 let(:voice_api_error_default) { Bandwidth::VoiceApiError.new }
  4. 4 let(:voice_api_error_values) { Bandwidth::VoiceApiError.new({
  5. type: 'validation',
  6. description: 'request body is invalid',
  7. id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85'
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::VoiceApiError.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::VoiceApiError.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::VoiceApiError.acceptable_attributes).to eq(Bandwidth::VoiceApiError.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be the set of nullable fields' do
  28. 1 expect(Bandwidth::VoiceApiError.openapi_nullable).to eq(Set.new([:'id']))
  29. end
  30. end
  31. 1 describe '#build_from_hash' do
  32. 1 it 'validates instance of VoiceApiError created by the build_from_hash method' do
  33. 1 voice_api_error_from_hash = Bandwidth::VoiceApiError.build_from_hash({
  34. type: 'validation',
  35. description: 'request body is invalid',
  36. id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85'
  37. })
  38. 1 expect(voice_api_error_from_hash).to be_instance_of(Bandwidth::VoiceApiError)
  39. 1 expect(voice_api_error_from_hash.type).to eq('validation')
  40. 1 expect(voice_api_error_from_hash.description).to eq('request body is invalid')
  41. 1 expect(voice_api_error_from_hash.id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  42. end
  43. end
  44. 1 describe '#to_s' do
  45. 1 it 'returns a string representation of the object' do
  46. 1 expect(voice_api_error_values.to_s).to eq('{:type=>"validation", :description=>"request body is invalid", :id=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"}')
  47. end
  48. end
  49. 1 describe '#eq? #==' do
  50. 1 it 'returns true/false when comparing objects' do
  51. 1 expect(voice_api_error_default.eql?(Bandwidth::VoiceApiError.new)).to be true
  52. 1 expect(voice_api_error_default.eql?(voice_api_error_values)).to be false
  53. end
  54. end
  55. 1 describe '#to_body #to_hash' do
  56. 1 it 'returns a hash representation of the object' do
  57. 1 expect(voice_api_error_values.to_body).to eq({
  58. type: 'validation',
  59. description: 'request body is invalid',
  60. id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85'
  61. })
  62. end
  63. end
  64. end

spec/unit/models/voice_code_response_spec.rb

100.0% lines covered

31 relevant lines. 31 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::VoiceCodeResponse
  2. 1 describe Bandwidth::VoiceCodeResponse do
  3. 2 let(:voice_code_response_default) { Bandwidth::VoiceCodeResponse.new }
  4. 4 let(:voice_code_response_values) { Bandwidth::VoiceCodeResponse.new({
  5. call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85'
  6. }) }
  7. 1 describe '#initialize' do
  8. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  9. 1 expect {
  10. 1 Bandwidth::VoiceCodeResponse.new([])
  11. }.to raise_error(ArgumentError)
  12. end
  13. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  14. 1 expect {
  15. 1 Bandwidth::VoiceCodeResponse.new({ invalid: true })
  16. }.to raise_error(ArgumentError)
  17. end
  18. end
  19. 1 describe '#acceptable_attributes' do
  20. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  21. 1 expect(Bandwidth::VoiceCodeResponse.acceptable_attributes).to eq(Bandwidth::VoiceCodeResponse.attribute_map.values)
  22. end
  23. end
  24. 1 describe '#openapi_nullable' do
  25. 1 it 'expects nullable attributes to be an empty set' do
  26. 1 expect(Bandwidth::VoiceCodeResponse.openapi_nullable).to eq(Set.new([]))
  27. end
  28. end
  29. 1 describe '#build_from_hash' do
  30. 1 it 'validates instance of VoiceCodeResponse created by the build_from_hash method' do
  31. 1 voice_code_response_from_hash = Bandwidth::VoiceCodeResponse.build_from_hash({
  32. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85'
  33. })
  34. 1 expect(voice_code_response_from_hash).to be_instance_of(Bandwidth::VoiceCodeResponse)
  35. 1 expect(voice_code_response_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85')
  36. end
  37. end
  38. 1 describe '#to_s' do
  39. 1 it 'returns a string representation of the object' do
  40. 1 expect(voice_code_response_values.to_s).to eq('{:callId=>"c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"}')
  41. end
  42. end
  43. 1 describe '#eq? #==' do
  44. 1 it 'returns true/false when comparing objects' do
  45. 1 expect(voice_code_response_default.eql?(Bandwidth::VoiceCodeResponse.new)).to be true
  46. 1 expect(voice_code_response_default.eql?(voice_code_response_values)).to be false
  47. end
  48. end
  49. 1 describe '#to_body #to_hash' do
  50. 1 it 'returns a hash representation of the object' do
  51. 1 expect(voice_code_response_values.to_body).to eq({
  52. callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85'
  53. })
  54. end
  55. end
  56. end

spec/unit/models/webhook_subscription_basic_authentication_spec.rb

100.0% lines covered

44 relevant lines. 44 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::WebhookSubscriptionBasicAuthentication
  2. 1 describe Bandwidth::WebhookSubscriptionBasicAuthentication do
  3. 2 let(:webhook_subscription_basic_authentication_default) { Bandwidth::WebhookSubscriptionBasicAuthentication.new({
  4. username: 'baseline',
  5. password: 'baselinePass'
  6. }) }
  7. 4 let(:webhook_subscription_basic_authentication_values) { Bandwidth::WebhookSubscriptionBasicAuthentication.new({
  8. username: 'mySecretUsername',
  9. password: 'mySecretPassword'
  10. }) }
  11. 1 describe '#initialize' do
  12. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  13. 1 expect {
  14. 1 Bandwidth::WebhookSubscriptionBasicAuthentication.new([])
  15. }.to raise_error(ArgumentError)
  16. end
  17. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  18. 1 expect {
  19. 1 Bandwidth::WebhookSubscriptionBasicAuthentication.new({ invalid: true })
  20. }.to raise_error(ArgumentError)
  21. end
  22. end
  23. 1 describe '#acceptable_attributes' do
  24. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  25. 1 expect(Bandwidth::WebhookSubscriptionBasicAuthentication.acceptable_attributes).to eq(Bandwidth::WebhookSubscriptionBasicAuthentication.attribute_map.values)
  26. end
  27. end
  28. 1 describe '#openapi_nullable' do
  29. 1 it 'expects nullable attributes to be an empty set' do
  30. 1 expect(Bandwidth::WebhookSubscriptionBasicAuthentication.openapi_nullable).to eq(Set.new([]))
  31. end
  32. end
  33. 1 describe '#build_from_hash' do
  34. 1 it 'validates instance of WebhookSubscriptionBasicAuthentication created by the build_from_hash method' do
  35. 1 webhook_subscription_basic_authentication_from_hash = Bandwidth::WebhookSubscriptionBasicAuthentication.build_from_hash({
  36. username: 'mySecretUsername',
  37. password: 'mySecretPassword'
  38. })
  39. 1 expect(webhook_subscription_basic_authentication_from_hash).to be_instance_of(Bandwidth::WebhookSubscriptionBasicAuthentication)
  40. 1 expect(webhook_subscription_basic_authentication_from_hash.username).to eq('mySecretUsername')
  41. 1 expect(webhook_subscription_basic_authentication_from_hash.password).to eq('mySecretPassword')
  42. end
  43. end
  44. 1 describe '#to_s' do
  45. 1 it 'returns a string representation of the object' do
  46. 1 expect(webhook_subscription_basic_authentication_values.to_s).to eq('{:username=>"mySecretUsername", :password=>"mySecretPassword"}')
  47. end
  48. end
  49. 1 describe '#eq? #==' do
  50. 1 it 'returns true/false when comparing objects' do
  51. 1 webhook_subscription_basic_authentication_equal = Bandwidth::WebhookSubscriptionBasicAuthentication.new({
  52. username: 'baseline',
  53. password: 'baselinePass'
  54. })
  55. 1 expect(webhook_subscription_basic_authentication_default.eql?(webhook_subscription_basic_authentication_equal)).to be true
  56. 1 expect(webhook_subscription_basic_authentication_default.eql?(webhook_subscription_basic_authentication_values)).to be false
  57. end
  58. end
  59. 1 describe '#to_body #to_hash' do
  60. 1 it 'returns a hash representation of the object' do
  61. 1 expect(webhook_subscription_basic_authentication_values.to_body).to eq({
  62. username: 'mySecretUsername',
  63. password: 'mySecretPassword'
  64. })
  65. end
  66. end
  67. 1 describe 'custom attribute writers' do
  68. 1 it '#username=' do
  69. 1 expect {
  70. 1 Bandwidth::WebhookSubscriptionBasicAuthentication.new({ username: nil, password: 'pass' })
  71. }.to raise_error(ArgumentError, 'username cannot be nil')
  72. 1 expect {
  73. 1 Bandwidth::WebhookSubscriptionBasicAuthentication.new({ username: 'a' * 101, password: 'pass' })
  74. }.to raise_error(ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 100.')
  75. end
  76. 1 it '#password=' do
  77. 1 expect {
  78. 1 Bandwidth::WebhookSubscriptionBasicAuthentication.new({ username: 'user', password: nil })
  79. }.to raise_error(ArgumentError, 'password cannot be nil')
  80. 1 expect {
  81. 1 Bandwidth::WebhookSubscriptionBasicAuthentication.new({ username: 'user', password: 'a' * 201 })
  82. }.to raise_error(ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 200.')
  83. end
  84. end
  85. end

spec/unit/models/webhook_subscription_error_spec.rb

100.0% lines covered

35 relevant lines. 35 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::WebhookSubscriptionError
  2. 1 describe Bandwidth::WebhookSubscriptionError do
  3. 2 let(:webhook_subscription_error_default) { Bandwidth::WebhookSubscriptionError.new }
  4. 4 let(:webhook_subscription_error_values) { Bandwidth::WebhookSubscriptionError.new({
  5. code: 400,
  6. description: 'Invalid request',
  7. telephone_numbers: [
  8. Bandwidth::TelephoneNumber.new({ telephone_number: '+18005554321' })
  9. ]
  10. }) }
  11. 1 describe '#initialize' do
  12. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  13. 1 expect {
  14. 1 Bandwidth::WebhookSubscriptionError.new([])
  15. }.to raise_error(ArgumentError)
  16. end
  17. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  18. 1 expect {
  19. 1 Bandwidth::WebhookSubscriptionError.new({ invalid: true })
  20. }.to raise_error(ArgumentError)
  21. end
  22. end
  23. 1 describe '#acceptable_attributes' do
  24. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  25. 1 expect(Bandwidth::WebhookSubscriptionError.acceptable_attributes).to eq(Bandwidth::WebhookSubscriptionError.attribute_map.values)
  26. end
  27. end
  28. 1 describe '#openapi_nullable' do
  29. 1 it 'expects nullable attributes to be an empty set' do
  30. 1 expect(Bandwidth::WebhookSubscriptionError.openapi_nullable).to eq(Set.new([]))
  31. end
  32. end
  33. 1 describe '#build_from_hash' do
  34. 1 it 'validates instance of WebhookSubscriptionError created by the build_from_hash method' do
  35. 1 webhook_subscription_error_from_hash = Bandwidth::WebhookSubscriptionError.build_from_hash({
  36. code: 400,
  37. description: 'Invalid request',
  38. telephoneNumbers: [{ telephoneNumber: '+18005554321' }]
  39. })
  40. 1 expect(webhook_subscription_error_from_hash).to be_instance_of(Bandwidth::WebhookSubscriptionError)
  41. 1 expect(webhook_subscription_error_from_hash.code).to eq(400)
  42. 1 expect(webhook_subscription_error_from_hash.description).to eq('Invalid request')
  43. 1 expect(webhook_subscription_error_from_hash.telephone_numbers).to be_instance_of(Array)
  44. 1 expect(webhook_subscription_error_from_hash.telephone_numbers.first).to be_instance_of(Bandwidth::TelephoneNumber)
  45. 1 expect(webhook_subscription_error_from_hash.telephone_numbers.first.telephone_number).to eq('+18005554321')
  46. end
  47. end
  48. 1 describe '#to_s' do
  49. 1 it 'returns a string representation of the object' do
  50. 1 expect(webhook_subscription_error_values.to_s).to eq('{:code=>400, :description=>"Invalid request", :telephoneNumbers=>[{:telephoneNumber=>"+18005554321"}]}')
  51. end
  52. end
  53. 1 describe '#eq? #==' do
  54. 1 it 'returns true/false when comparing objects' do
  55. 1 expect(webhook_subscription_error_default.eql?(Bandwidth::WebhookSubscriptionError.new)).to be true
  56. 1 expect(webhook_subscription_error_default.eql?(webhook_subscription_error_values)).to be false
  57. end
  58. end
  59. 1 describe '#to_body #to_hash' do
  60. 1 it 'returns a hash representation of the object' do
  61. 1 expect(webhook_subscription_error_values.to_body).to eq({
  62. code: 400,
  63. description: 'Invalid request',
  64. telephoneNumbers: [{ telephoneNumber: '+18005554321' }]
  65. })
  66. end
  67. end
  68. end

spec/unit/models/webhook_subscription_request_schema_spec.rb

100.0% lines covered

46 relevant lines. 46 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::WebhookSubscriptionRequestSchema
  2. 1 describe Bandwidth::WebhookSubscriptionRequestSchema do
  3. 2 let(:webhook_subscription_request_schema_default) { Bandwidth::WebhookSubscriptionRequestSchema.new }
  4. 6 let(:webhook_subscription_request_schema_values) { Bandwidth::WebhookSubscriptionRequestSchema.new({
  5. basic_authentication: Bandwidth::TfvBasicAuthentication.new({ username: 'user', password: 'pass' }),
  6. callback_url: 'https://example.com/callback',
  7. shared_secret_key: 'abc123abc123abc1'
  8. }) }
  9. 1 describe '#initialize' do
  10. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  11. 1 expect {
  12. 1 Bandwidth::WebhookSubscriptionRequestSchema.new([])
  13. }.to raise_error(ArgumentError)
  14. end
  15. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  16. 1 expect {
  17. 1 Bandwidth::WebhookSubscriptionRequestSchema.new({ invalid: true })
  18. }.to raise_error(ArgumentError)
  19. end
  20. end
  21. 1 describe '#acceptable_attributes' do
  22. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  23. 1 expect(Bandwidth::WebhookSubscriptionRequestSchema.acceptable_attributes).to eq(Bandwidth::WebhookSubscriptionRequestSchema.attribute_map.values)
  24. end
  25. end
  26. 1 describe '#openapi_nullable' do
  27. 1 it 'expects nullable attributes to be the set of nullable fields' do
  28. 1 expect(Bandwidth::WebhookSubscriptionRequestSchema.openapi_nullable).to eq(Set.new([
  29. :'callback_url',
  30. :'shared_secret_key'
  31. ]))
  32. end
  33. end
  34. 1 describe '#build_from_hash' do
  35. 1 it 'validates instance of WebhookSubscriptionRequestSchema created by the build_from_hash method' do
  36. 1 webhook_subscription_request_schema_from_hash = Bandwidth::WebhookSubscriptionRequestSchema.build_from_hash({
  37. basicAuthentication: { username: 'user', password: 'pass' },
  38. callbackUrl: 'https://example.com/callback',
  39. sharedSecretKey: 'abc123abc123abc1'
  40. })
  41. 1 expect(webhook_subscription_request_schema_from_hash).to be_instance_of(Bandwidth::WebhookSubscriptionRequestSchema)
  42. 1 expect(webhook_subscription_request_schema_from_hash.basic_authentication).to be_instance_of(Bandwidth::TfvBasicAuthentication)
  43. 1 expect(webhook_subscription_request_schema_from_hash.basic_authentication.username).to eq('user')
  44. 1 expect(webhook_subscription_request_schema_from_hash.basic_authentication.password).to eq('pass')
  45. 1 expect(webhook_subscription_request_schema_from_hash.callback_url).to eq('https://example.com/callback')
  46. 1 expect(webhook_subscription_request_schema_from_hash.shared_secret_key).to eq('abc123abc123abc1')
  47. end
  48. end
  49. 1 describe '#to_s' do
  50. 1 it 'returns a string representation of the object' do
  51. 1 expect(webhook_subscription_request_schema_values.to_s).to eq('{:basicAuthentication=>{:username=>"user", :password=>"pass"}, :callbackUrl=>"https://example.com/callback", :sharedSecretKey=>"abc123abc123abc1"}')
  52. end
  53. end
  54. 1 describe '#eq? #==' do
  55. 1 it 'returns true/false when comparing objects' do
  56. 1 expect(webhook_subscription_request_schema_default.eql?(Bandwidth::WebhookSubscriptionRequestSchema.new)).to be true
  57. 1 expect(webhook_subscription_request_schema_default.eql?(webhook_subscription_request_schema_values)).to be false
  58. end
  59. end
  60. 1 describe '#to_body #to_hash' do
  61. 1 it 'returns a hash representation of the object' do
  62. 1 expect(webhook_subscription_request_schema_values.to_body).to eq({
  63. basicAuthentication: { username: 'user', password: 'pass' },
  64. callbackUrl: 'https://example.com/callback',
  65. sharedSecretKey: 'abc123abc123abc1'
  66. })
  67. end
  68. end
  69. 1 describe 'custom attribute writers' do
  70. 1 it '#callback_url=' do
  71. 1 expect {
  72. 1 webhook_subscription_request_schema_values.callback_url = 'a' * 2001
  73. }.to raise_error(ArgumentError, 'invalid value for "callback_url", the character length must be smaller than or equal to 2000.')
  74. 1 expect {
  75. 1 webhook_subscription_request_schema_values.callback_url = 'not a url'
  76. }.to raise_error(ArgumentError, /invalid value for "callback_url", must conform to the pattern/)
  77. end
  78. 1 it '#shared_secret_key=' do
  79. 1 expect {
  80. 1 webhook_subscription_request_schema_values.shared_secret_key = 'a' * 65
  81. }.to raise_error(ArgumentError, 'invalid value for "shared_secret_key", the character length must be smaller than or equal to 64.')
  82. 1 expect {
  83. 1 webhook_subscription_request_schema_values.shared_secret_key = 'a' * 15
  84. }.to raise_error(ArgumentError, 'invalid value for "shared_secret_key", the character length must be greater than or equal to 16.')
  85. end
  86. end
  87. end

spec/unit/models/webhook_subscription_spec.rb

100.0% lines covered

43 relevant lines. 43 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::WebhookSubscription
  2. 1 describe Bandwidth::WebhookSubscription do
  3. 2 let(:webhook_subscription_default) { Bandwidth::WebhookSubscription.new }
  4. 5 let(:webhook_subscription_values) { Bandwidth::WebhookSubscription.new({
  5. id: '6cf73464-0c9f-431f-bd16-3711df296b9a',
  6. account_id: '9900000',
  7. callback_url: 'https://example.com/callback',
  8. type: Bandwidth::WebhookSubscriptionTypeEnum::TOLLFREE_VERIFICATION_STATUS,
  9. basic_authentication: Bandwidth::WebhookSubscriptionBasicAuthentication.new({ username: 'user', password: 'pass' }),
  10. created_date: '2024-01-01T00:00:00Z',
  11. modified_date: '2024-01-02T00:00:00Z'
  12. }) }
  13. 1 describe '#initialize' do
  14. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  15. 1 expect {
  16. 1 Bandwidth::WebhookSubscription.new([])
  17. }.to raise_error(ArgumentError)
  18. end
  19. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  20. 1 expect {
  21. 1 Bandwidth::WebhookSubscription.new({ invalid: true })
  22. }.to raise_error(ArgumentError)
  23. end
  24. end
  25. 1 describe '#acceptable_attributes' do
  26. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  27. 1 expect(Bandwidth::WebhookSubscription.acceptable_attributes).to eq(Bandwidth::WebhookSubscription.attribute_map.values)
  28. end
  29. end
  30. 1 describe '#openapi_nullable' do
  31. 1 it 'expects nullable attributes to be the set of nullable fields' do
  32. 1 expect(Bandwidth::WebhookSubscription.openapi_nullable).to eq(Set.new([:'callback_url']))
  33. end
  34. end
  35. 1 describe '#build_from_hash' do
  36. 1 it 'validates instance of WebhookSubscription created by the build_from_hash method' do
  37. 1 webhook_subscription_from_hash = Bandwidth::WebhookSubscription.build_from_hash({
  38. id: '6cf73464-0c9f-431f-bd16-3711df296b9a',
  39. accountId: '9900000',
  40. callbackUrl: 'https://example.com/callback',
  41. type: Bandwidth::WebhookSubscriptionTypeEnum::TOLLFREE_VERIFICATION_STATUS,
  42. basicAuthentication: { username: 'user', password: 'pass' },
  43. createdDate: '2024-01-01T00:00:00Z',
  44. modifiedDate: '2024-01-02T00:00:00Z'
  45. })
  46. 1 expect(webhook_subscription_from_hash).to be_instance_of(Bandwidth::WebhookSubscription)
  47. 1 expect(webhook_subscription_from_hash.id).to eq('6cf73464-0c9f-431f-bd16-3711df296b9a')
  48. 1 expect(webhook_subscription_from_hash.account_id).to eq('9900000')
  49. 1 expect(webhook_subscription_from_hash.callback_url).to eq('https://example.com/callback')
  50. 1 expect(webhook_subscription_from_hash.type).to eq(Bandwidth::WebhookSubscriptionTypeEnum::TOLLFREE_VERIFICATION_STATUS)
  51. 1 expect(webhook_subscription_from_hash.basic_authentication).to be_instance_of(Bandwidth::WebhookSubscriptionBasicAuthentication)
  52. 1 expect(webhook_subscription_from_hash.created_date).to eq(Time.parse('2024-01-01T00:00:00Z'))
  53. 1 expect(webhook_subscription_from_hash.modified_date).to eq(Time.parse('2024-01-02T00:00:00Z'))
  54. end
  55. end
  56. 1 describe '#to_s' do
  57. 1 it 'returns a string representation of the object' do
  58. 1 expect(webhook_subscription_values.to_s).to eq('{:id=>"6cf73464-0c9f-431f-bd16-3711df296b9a", :accountId=>"9900000", :callbackUrl=>"https://example.com/callback", :type=>"TOLLFREE_VERIFICATION_STATUS", :basicAuthentication=>{:username=>"user", :password=>"pass"}, :createdDate=>"2024-01-01T00:00:00Z", :modifiedDate=>"2024-01-02T00:00:00Z"}')
  59. end
  60. end
  61. 1 describe '#eq? #==' do
  62. 1 it 'returns true/false when comparing objects' do
  63. 1 expect(webhook_subscription_default.eql?(Bandwidth::WebhookSubscription.new)).to be true
  64. 1 expect(webhook_subscription_default.eql?(webhook_subscription_values)).to be false
  65. end
  66. end
  67. 1 describe '#to_body #to_hash' do
  68. 1 it 'returns a hash representation of the object' do
  69. 1 expect(webhook_subscription_values.to_body).to eq({
  70. id: '6cf73464-0c9f-431f-bd16-3711df296b9a',
  71. accountId: '9900000',
  72. callbackUrl: 'https://example.com/callback',
  73. type: Bandwidth::WebhookSubscriptionTypeEnum::TOLLFREE_VERIFICATION_STATUS,
  74. basicAuthentication: { username: 'user', password: 'pass' },
  75. createdDate: '2024-01-01T00:00:00Z',
  76. modifiedDate: '2024-01-02T00:00:00Z'
  77. })
  78. end
  79. end
  80. 1 describe 'custom attribute writers' do
  81. 1 it '#callback_url=' do
  82. 1 expect {
  83. 1 webhook_subscription_values.callback_url = 'a' * 2001
  84. }.to raise_error(ArgumentError, 'invalid value for "callback_url", the character length must be smaller than or equal to 2000.')
  85. 1 expect {
  86. 1 webhook_subscription_values.callback_url = 'not a url'
  87. }.to raise_error(ArgumentError, /invalid value for "callback_url", must conform to the pattern/)
  88. end
  89. end
  90. end

spec/unit/models/webhook_subscription_type_enum_spec.rb

100.0% lines covered

16 relevant lines. 16 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::WebhookSubscriptionTypeEnum
  2. 1 describe Bandwidth::WebhookSubscriptionTypeEnum do
  3. 1 describe 'constants' do
  4. 1 it 'defines TOLLFREE_VERIFICATION_STATUS' do
  5. 1 expect(Bandwidth::WebhookSubscriptionTypeEnum::TOLLFREE_VERIFICATION_STATUS).to eq('TOLLFREE_VERIFICATION_STATUS')
  6. end
  7. 1 it 'defines MESSAGING_PORTOUT_APPROVAL_STATUS' do
  8. 1 expect(Bandwidth::WebhookSubscriptionTypeEnum::MESSAGING_PORTOUT_APPROVAL_STATUS).to eq('MESSAGING_PORTOUT_APPROVAL_STATUS')
  9. end
  10. end
  11. 1 describe '.all_vars' do
  12. 1 it 'returns every valid enum value' do
  13. 1 expect(Bandwidth::WebhookSubscriptionTypeEnum.all_vars).to eq([
  14. 'TOLLFREE_VERIFICATION_STATUS',
  15. 'MESSAGING_PORTOUT_APPROVAL_STATUS'
  16. ])
  17. end
  18. end
  19. 1 describe '.build_from_hash' do
  20. 1 it 'returns the value when it matches a valid enum value' do
  21. 1 expect(Bandwidth::WebhookSubscriptionTypeEnum.build_from_hash('TOLLFREE_VERIFICATION_STATUS')).to eq('TOLLFREE_VERIFICATION_STATUS')
  22. 1 expect(Bandwidth::WebhookSubscriptionTypeEnum.build_from_hash('MESSAGING_PORTOUT_APPROVAL_STATUS')).to eq('MESSAGING_PORTOUT_APPROVAL_STATUS')
  23. end
  24. 1 it 'raises an error for an invalid enum value' do
  25. 1 expect {
  26. 1 Bandwidth::WebhookSubscriptionTypeEnum.build_from_hash('invalid')
  27. }.to raise_error(RuntimeError)
  28. end
  29. end
  30. end

spec/unit/models/webhook_subscriptions_list_body_spec.rb

100.0% lines covered

40 relevant lines. 40 lines covered and 0 lines missed.
    
  1. # Unit tests for Bandwidth::WebhookSubscriptionsListBody
  2. 1 describe Bandwidth::WebhookSubscriptionsListBody do
  3. 2 let(:webhook_subscriptions_list_body_default) { Bandwidth::WebhookSubscriptionsListBody.new({
  4. data: []
  5. }) }
  6. 5 let(:webhook_subscriptions_list_body_values) { Bandwidth::WebhookSubscriptionsListBody.new({
  7. links: { self: 'https://example.com/self' },
  8. errors: [
  9. Bandwidth::WebhookSubscriptionError.new({ code: 400, description: 'Invalid request' })
  10. ],
  11. data: [
  12. Bandwidth::WebhookSubscription.new({ id: '6cf73464-0c9f-431f-bd16-3711df296b9a', account_id: '9900000' })
  13. ]
  14. }) }
  15. 1 describe '#initialize' do
  16. 1 it 'causes an ArgumentError by passing an Array to the initialize method' do
  17. 1 expect {
  18. 1 Bandwidth::WebhookSubscriptionsListBody.new([])
  19. }.to raise_error(ArgumentError)
  20. end
  21. 1 it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do
  22. 1 expect {
  23. 1 Bandwidth::WebhookSubscriptionsListBody.new({ invalid: true })
  24. }.to raise_error(ArgumentError)
  25. end
  26. end
  27. 1 describe '#acceptable_attributes' do
  28. 1 it 'expects acceptable JSON attributes to be those in the attribute map' do
  29. 1 expect(Bandwidth::WebhookSubscriptionsListBody.acceptable_attributes).to eq(Bandwidth::WebhookSubscriptionsListBody.attribute_map.values)
  30. end
  31. end
  32. 1 describe '#openapi_nullable' do
  33. 1 it 'expects nullable attributes to be an empty set' do
  34. 1 expect(Bandwidth::WebhookSubscriptionsListBody.openapi_nullable).to eq(Set.new([]))
  35. end
  36. end
  37. 1 describe '#build_from_hash' do
  38. 1 it 'validates instance of WebhookSubscriptionsListBody created by the build_from_hash method' do
  39. 1 webhook_subscriptions_list_body_from_hash = Bandwidth::WebhookSubscriptionsListBody.build_from_hash({
  40. links: { self: 'https://example.com/self' },
  41. errors: [{ code: 400, description: 'Invalid request' }],
  42. data: [{ id: '6cf73464-0c9f-431f-bd16-3711df296b9a', accountId: '9900000' }]
  43. })
  44. 1 expect(webhook_subscriptions_list_body_from_hash).to be_instance_of(Bandwidth::WebhookSubscriptionsListBody)
  45. 1 expect(webhook_subscriptions_list_body_from_hash.links).to be_instance_of(Bandwidth::LinksObject)
  46. 1 expect(webhook_subscriptions_list_body_from_hash.errors).to be_instance_of(Array)
  47. 1 expect(webhook_subscriptions_list_body_from_hash.errors.first).to be_instance_of(Bandwidth::WebhookSubscriptionError)
  48. 1 expect(webhook_subscriptions_list_body_from_hash.data).to be_instance_of(Array)
  49. 1 expect(webhook_subscriptions_list_body_from_hash.data.first).to be_instance_of(Bandwidth::WebhookSubscription)
  50. end
  51. end
  52. 1 describe '#to_s' do
  53. 1 it 'returns a string representation of the object' do
  54. 1 expect(webhook_subscriptions_list_body_values.to_s).to eq('{:links=>{:self=>"https://example.com/self"}, :errors=>[{:code=>400, :description=>"Invalid request"}], :data=>[{:id=>"6cf73464-0c9f-431f-bd16-3711df296b9a", :accountId=>"9900000", :callbackUrl=>nil}]}')
  55. end
  56. end
  57. 1 describe '#eq? #==' do
  58. 1 it 'returns true/false when comparing objects' do
  59. 1 webhook_subscriptions_list_body_equal = Bandwidth::WebhookSubscriptionsListBody.new({
  60. data: []
  61. })
  62. 1 expect(webhook_subscriptions_list_body_default.eql?(webhook_subscriptions_list_body_equal)).to be true
  63. 1 expect(webhook_subscriptions_list_body_default.eql?(webhook_subscriptions_list_body_values)).to be false
  64. end
  65. end
  66. 1 describe '#to_body #to_hash' do
  67. 1 it 'returns a hash representation of the object' do
  68. 1 expect(webhook_subscriptions_list_body_values.to_body).to eq({
  69. links: { self: 'https://example.com/self' },
  70. errors: [{ code: 400, description: 'Invalid request' }],
  71. data: [{ id: '6cf73464-0c9f-431f-bd16-3711df296b9a', accountId: '9900000', callbackUrl: nil }]
  72. })
  73. end
  74. end
  75. 1 describe 'custom attribute writers' do
  76. 1 it '#data=' do
  77. 1 expect {
  78. 1 webhook_subscriptions_list_body_values.data = nil
  79. }.to raise_error(ArgumentError, 'data cannot be nil')
  80. end
  81. end
  82. end