|
| 1 | +## |
| 2 | +# This code was generated by |
| 3 | +# ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ |
| 4 | +# | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ |
| 5 | +# | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ |
| 6 | +# |
| 7 | +# Twilio - Accounts |
| 8 | +# This is the public Twilio REST API. |
| 9 | +# |
| 10 | +# NOTE: This class is auto generated by OpenAPI Generator. |
| 11 | +# https://openapi-generator.tech |
| 12 | +# Do not edit the class manually. |
| 13 | +# |
| 14 | + |
| 15 | + |
| 16 | +module Twilio |
| 17 | + module REST |
| 18 | + class Accounts < AccountsBase |
| 19 | + class V1 < Version |
| 20 | + class MessagingGeopermissionsList < ListResource |
| 21 | + |
| 22 | + ## |
| 23 | + # Initialize the MessagingGeopermissionsList |
| 24 | + # @param [Version] version Version that contains the resource |
| 25 | + # @return [MessagingGeopermissionsList] MessagingGeopermissionsList |
| 26 | + def initialize(version) |
| 27 | + super(version) |
| 28 | + # Path Solution |
| 29 | + @solution = { } |
| 30 | + @uri = "/Messaging/GeoPermissions" |
| 31 | + |
| 32 | + end |
| 33 | + ## |
| 34 | + # Fetch the MessagingGeopermissionsInstance |
| 35 | + # @param [String] country_code The country code to filter the geo permissions. If provided, only the geo permission for the specified country will be returned. |
| 36 | + # @return [MessagingGeopermissionsInstance] Fetched MessagingGeopermissionsInstance |
| 37 | + def fetch( |
| 38 | + country_code: :unset |
| 39 | + ) |
| 40 | + |
| 41 | + params = Twilio::Values.of({ |
| 42 | + 'CountryCode' => country_code, |
| 43 | + }) |
| 44 | + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + payload = @version.fetch('GET', @uri, params: params, headers: headers) |
| 51 | + MessagingGeopermissionsInstance.new( |
| 52 | + @version, |
| 53 | + payload, |
| 54 | + ) |
| 55 | + end |
| 56 | + |
| 57 | + ## |
| 58 | + # Update the MessagingGeopermissionsInstance |
| 59 | + # @param [Array[Hash]] permissions A list of objects where each object represents the Geo Permission to be updated. Each object contains the following fields: `country_code`, unique code for each country of Geo Permission; `type`, permission type of the Geo Permission i.e. country; `enabled`, configure true for enabling the Geo Permission, false for disabling the Geo Permission. |
| 60 | + # @return [MessagingGeopermissionsInstance] Updated MessagingGeopermissionsInstance |
| 61 | + def update( |
| 62 | + permissions: nil |
| 63 | + ) |
| 64 | + |
| 65 | + data = Twilio::Values.of({ |
| 66 | + 'Permissions' => Twilio.serialize_list(permissions) { |e| Twilio.serialize_object(e) }, |
| 67 | + }) |
| 68 | + |
| 69 | + headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | + payload = @version.update('PATCH', @uri, data: data, headers: headers) |
| 76 | + MessagingGeopermissionsInstance.new( |
| 77 | + @version, |
| 78 | + payload, |
| 79 | + ) |
| 80 | + end |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + # Provide a user friendly representation |
| 86 | + def to_s |
| 87 | + '#<Twilio.Accounts.V1.MessagingGeopermissionsList>' |
| 88 | + end |
| 89 | + end |
| 90 | + |
| 91 | + class MessagingGeopermissionsPage < Page |
| 92 | + ## |
| 93 | + # Initialize the MessagingGeopermissionsPage |
| 94 | + # @param [Version] version Version that contains the resource |
| 95 | + # @param [Response] response Response from the API |
| 96 | + # @param [Hash] solution Path solution for the resource |
| 97 | + # @return [MessagingGeopermissionsPage] MessagingGeopermissionsPage |
| 98 | + def initialize(version, response, solution) |
| 99 | + super(version, response) |
| 100 | + |
| 101 | + # Path Solution |
| 102 | + @solution = solution |
| 103 | + end |
| 104 | + |
| 105 | + ## |
| 106 | + # Build an instance of MessagingGeopermissionsInstance |
| 107 | + # @param [Hash] payload Payload response from the API |
| 108 | + # @return [MessagingGeopermissionsInstance] MessagingGeopermissionsInstance |
| 109 | + def get_instance(payload) |
| 110 | + MessagingGeopermissionsInstance.new(@version, payload) |
| 111 | + end |
| 112 | + |
| 113 | + ## |
| 114 | + # Provide a user friendly representation |
| 115 | + def to_s |
| 116 | + '<Twilio.Accounts.V1.MessagingGeopermissionsPage>' |
| 117 | + end |
| 118 | + end |
| 119 | + class MessagingGeopermissionsInstance < InstanceResource |
| 120 | + ## |
| 121 | + # Initialize the MessagingGeopermissionsInstance |
| 122 | + # @param [Version] version Version that contains the resource |
| 123 | + # @param [Hash] payload payload that contains response from Twilio |
| 124 | + # @param [String] account_sid The SID of the |
| 125 | + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this MessagingGeopermissions |
| 126 | + # resource. |
| 127 | + # @param [String] sid The SID of the Call resource to fetch. |
| 128 | + # @return [MessagingGeopermissionsInstance] MessagingGeopermissionsInstance |
| 129 | + def initialize(version, payload ) |
| 130 | + super(version) |
| 131 | + |
| 132 | + # Marshaled Properties |
| 133 | + @properties = { |
| 134 | + 'permissions' => payload['permissions'], |
| 135 | + } |
| 136 | + end |
| 137 | + |
| 138 | + |
| 139 | + ## |
| 140 | + # @return [Hash] A list of objects where each object represents the result of processing a messaging Geo Permission. Each object contains the following fields: `country_code`, the country code of the country for which the permission was updated; `type`, the type of the permission i.e. country; `enabled`, true if the permission is enabled else false; `error_code`, an integer where 0 indicates success and any non-zero value represents an error; and `error_messages`, an array of strings describing specific validation errors encountered. If the request is successful, the error_messages array will be empty. |
| 141 | + def permissions |
| 142 | + @properties['permissions'] |
| 143 | + end |
| 144 | + |
| 145 | + ## |
| 146 | + # Provide a user friendly representation |
| 147 | + def to_s |
| 148 | + "<Twilio.Accounts.V1.MessagingGeopermissionsInstance>" |
| 149 | + end |
| 150 | + |
| 151 | + ## |
| 152 | + # Provide a detailed, user friendly representation |
| 153 | + def inspect |
| 154 | + "<Twilio.Accounts.V1.MessagingGeopermissionsInstance>" |
| 155 | + end |
| 156 | + end |
| 157 | + |
| 158 | + end |
| 159 | + end |
| 160 | + end |
| 161 | +end |
0 commit comments