|
| 1 | +module Phaxio |
| 2 | + module Resources |
| 3 | + # Provides functionality for viewing and managing port orders. |
| 4 | + class PortOrder < Resource |
| 5 | + PORT_ORDERS_PATH = 'port_orders'.freeze |
| 6 | + private_constant :PORT_ORDERS_PATH |
| 7 | + |
| 8 | + # @return [Integer] the ID associated with this order. |
| 9 | + # @!attribute id |
| 10 | + |
| 11 | + # @return [String] the status of this order. |
| 12 | + # @!attribute status |
| 13 | + |
| 14 | + # @return [String] the E.164 contact number. |
| 15 | + # @!attribute contact_number |
| 16 | + |
| 17 | + # @return [String] The email address for the order. |
| 18 | + # @!attribute contact_email |
| 19 | + |
| 20 | + # @return [String] The identifier for the account associated with the numbers. |
| 21 | + # @!attribute account_identifier |
| 22 | + |
| 23 | + # @return [String] Type of numbers to be ported. Either "business" or "residential". |
| 24 | + # @!attribute port_type |
| 25 | + |
| 26 | + # @return [String] The PIN or password needed to port out the numbers. |
| 27 | + # @!attribute port_out_pin |
| 28 | + |
| 29 | + # @return [String] the name associated with the account. |
| 30 | + # @!attribute name_on_account |
| 31 | + |
| 32 | + # @return [String] the name of the business. |
| 33 | + # @!attribute name_of_business |
| 34 | + |
| 35 | + # @return [String] the provider name. |
| 36 | + # @!attribute provider_name |
| 37 | + |
| 38 | + # @return [String] the E.164 billing number. |
| 39 | + # @!attribute billing_number |
| 40 | + |
| 41 | + # @return [String] the first billing address line. |
| 42 | + # @!attribute billing_address1 |
| 43 | + |
| 44 | + # @return [String] the second billing address line. |
| 45 | + # @!attribute billing_address2 |
| 46 | + |
| 47 | + # @return [String] the billing address city. |
| 48 | + # @!attribute billing_city |
| 49 | + |
| 50 | + # @return [String] the billing address state. |
| 51 | + # @!attribute billing_state |
| 52 | + |
| 53 | + # @return [String] the billing address zip. |
| 54 | + # @!attribute billing_zip |
| 55 | + |
| 56 | + # @return [String] the electronic signature used to sign the order. |
| 57 | + # @!attribute esig |
| 58 | + |
| 59 | + # @return [true | false] |
| 60 | + # whether or not a bill will be provided. (only present on new orders) |
| 61 | + # @!attribute has_bill |
| 62 | + |
| 63 | + # @return [true | false] |
| 64 | + # whether or not the legal agreement is accepted. (only present on new orders) |
| 65 | + # @!attribute legal_agreement |
| 66 | + |
| 67 | + has_normal_attributes %w[ |
| 68 | + id contact_number contact_email name_on_account name_of_business provider_name |
| 69 | + billing_number billing_address1 billing_address2 account_identifier |
| 70 | + billing_city billing_state billing_zip esig legal_agreement port_type port_out_pin |
| 71 | + status |
| 72 | + ] |
| 73 | + |
| 74 | + # @return [Time] the time the order was created. |
| 75 | + # @!attribute created_at |
| 76 | + |
| 77 | + # @return [Time] the time the order was updated. |
| 78 | + # @!attribute updated_at |
| 79 | + |
| 80 | + # @return [Time] the time the bill for the order was received. |
| 81 | + # @!attribute bill_received_at |
| 82 | + |
| 83 | + # @return [Time] the time the order was requested for. |
| 84 | + # @!attribute requested_for |
| 85 | + |
| 86 | + # @return [Time] the time the order was completed. |
| 87 | + # @!attribute completed_at |
| 88 | + |
| 89 | + has_time_attributes %w[ |
| 90 | + created_at updated_at bill_received_at requested_for completed_at |
| 91 | + ] |
| 92 | + |
| 93 | + # @return [Phaxio::Resource::Collection<Phaxio::Resources::PortNumber>] |
| 94 | + # a collection of port numbers associated with the order |
| 95 | + # @!attribute port_numbers |
| 96 | + |
| 97 | + has_collection_attributes({port_numbers: PortNumber}) |
| 98 | + |
| 99 | + class << self |
| 100 | + # @macro paging |
| 101 | + # List port orders in date range. |
| 102 | + # @param params [Hash] |
| 103 | + # Any parameters to send to Phaxio. |
| 104 | + # - *created_before* [String] - RFC 3339 timestamp representing the end of the range. |
| 105 | + # - *created_after* [String] - RFC 3339 timestamp representing the beginning of the range. |
| 106 | + # @return [Phaxio::Resource::Collection<Phaxio::Resources::PortOrder>] |
| 107 | + # The collection of port orders matching your request. |
| 108 | + # @raise [Phaxio::Error::PhaxioError |
| 109 | + # @see https://www.phaxio.com/docs/api/v2/port_orders/list_port_orders |
| 110 | + def list params = {} |
| 111 | + response = Client.request :get, port_orders_endpoint, params |
| 112 | + response_collection response |
| 113 | + end |
| 114 | + |
| 115 | + # Create a port order. |
| 116 | + # @param params [Hash] |
| 117 | + # Any parameters to send to Phaxio. |
| 118 | + # - *port_numbers* [Array<String>] - Numbers to port. |
| 119 | + # - *contact_number* [String] - Number to contact about the port. |
| 120 | + # - *contact_email* [String] - The email address for the order. |
| 121 | + # - *account_identifier* [String] - The identifier for the account associated with the numbers. |
| 122 | + # - *port_type* [String] - Type of numbers to be ported. Either "business" or "residential". |
| 123 | + # - *port_out_pin* [String] - The PIN or password needed to port out the numbers. |
| 124 | + # - *name_on_account* [String] - Name on the account for the port. |
| 125 | + # - *name_of_business* [String] - Name of business associated with the port. |
| 126 | + # - *provider_name* [String] - Name of provider for the port. |
| 127 | + # - *esig* [String] - Electronic signature used to sign the order. |
| 128 | + # - *legal_agreement* [true | false] - Indicates acceptance of the legal agreement. |
| 129 | + # - *has_bill* [true | false] - Indicates whether or not a bill will be provided. If true, billing number |
| 130 | + # and address fields are not needed. |
| 131 | + # - *billing_number* [String] - Billing number. |
| 132 | + # - *billing_address1* [String] - Billing address line 1 |
| 133 | + # - *billing_address2* [String] - Billing address line 2 |
| 134 | + # - *billing_city* [String] - Billing address city. |
| 135 | + # - *billing_state* [String] - Billing address state. |
| 136 | + # - *billing_zip* [String] - Billing address zip. |
| 137 | + # @return [Phaxio::Resources::PortOrder] |
| 138 | + # @raise [Phaxio::Error::PhaxioError] |
| 139 | + # @see https://www.phaxio.com/docs/api/v2/port_orders/create_port_order |
| 140 | + def create params = {} |
| 141 | + response = Client.request :post, port_orders_endpoint, params |
| 142 | + response_record response |
| 143 | + end |
| 144 | + |
| 145 | + # Get port order info. |
| 146 | + # @param id [Integer] |
| 147 | + # The ID of the order to retrieve. |
| 148 | + # @param params [Hash] |
| 149 | + # A hash of parameters to send to Phaxio. This action takes no unique parameters. |
| 150 | + # @return [Phaxio::Resource::PortOrder] |
| 151 | + # @raise [Phaxio::Error::PhaxioError] |
| 152 | + # @see https://www.phaxio.com/docs/api/v2/port_orders/get_port_order |
| 153 | + def get id, params = {} |
| 154 | + response = Client.request :get, port_order_endpoint(id.to_i), params |
| 155 | + response_record response |
| 156 | + end |
| 157 | + alias :retrieve :get |
| 158 | + alias :find :get |
| 159 | + |
| 160 | + private |
| 161 | + |
| 162 | + def port_orders_endpoint |
| 163 | + PORT_ORDERS_PATH |
| 164 | + end |
| 165 | + |
| 166 | + def port_order_endpoint id |
| 167 | + "#{PORT_ORDERS_PATH}/#{id}" |
| 168 | + end |
| 169 | + end |
| 170 | + end |
| 171 | + end |
| 172 | +end |
0 commit comments