Class: Twilio::REST::Accounts::V1::MessagingGeopermissionsList

Inherits:
ListResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/accounts/v1/messaging_geopermissions.rb

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ MessagingGeopermissionsList

Initialize the MessagingGeopermissionsList

Parameters:

  • version (Version)

    Version that contains the resource



26
27
28
29
30
31
32
33
# File 'lib/twilio-ruby/rest/accounts/v1/messaging_geopermissions.rb', line 26

def initialize(version)
    super(version)
    
    # Path Solution
    @solution = {  }
    @uri = "/Messaging/GeoPermissions"
    
end

Instance Method Details

#fetch(country_code: :unset) ⇒ MessagingGeopermissionsInstance

Fetch the MessagingGeopermissionsInstance

Parameters:

  • country_code (String) (defaults to: :unset)

    The country code to filter the geo permissions. If provided, only the geo permission for the specified country will be returned.

Returns:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/twilio-ruby/rest/accounts/v1/messaging_geopermissions.rb', line 38

def fetch(
    country_code: :unset
)

    params = Twilio::Values.of({
        'CountryCode' => country_code,
    })
    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, params: params, headers: headers)
    MessagingGeopermissionsInstance.new(
        @version,
        payload,
    )
end

#fetch_with_metadata(country_code: :unset) ⇒ MessagingGeopermissionsInstance

Fetch the MessagingGeopermissionsInstanceMetadata

Parameters:

  • country_code (String) (defaults to: :unset)

    The country code to filter the geo permissions. If provided, only the geo permission for the specified country will be returned.

Returns:



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/twilio-ruby/rest/accounts/v1/messaging_geopermissions.rb', line 62

def (
  country_code: :unset
)

    params = Twilio::Values.of({
        'CountryCode' => country_code,
    })
    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, params: params, headers: headers)
    messaging_geopermissions_instance = MessagingGeopermissionsInstance.new(
        @version,
        response.body,
    )
    .new(
        @version,
        messaging_geopermissions_instance,
        response.headers,
        response.status_code
    )
end

#to_sObject

Provide a user friendly representation



148
149
150
# File 'lib/twilio-ruby/rest/accounts/v1/messaging_geopermissions.rb', line 148

def to_s
    '#<Twilio.Accounts.V1.MessagingGeopermissionsList>'
end

#update(permissions: nil) ⇒ MessagingGeopermissionsInstance

Update the MessagingGeopermissionsInstance

Parameters:

  • permissions (Array[Hash]) (defaults to: nil)

    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.

Returns:



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/twilio-ruby/rest/accounts/v1/messaging_geopermissions.rb', line 92

def update(
    permissions: nil
)

    data = Twilio::Values.of({
        'Permissions' => Twilio.serialize_list(permissions) { |e| Twilio.serialize_object(e) },
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('PATCH', @uri, data: data, headers: headers)
    MessagingGeopermissionsInstance.new(
        @version,
        payload,
    )
end

#update_with_metadata(permissions: nil) ⇒ MessagingGeopermissionsInstance

Update the MessagingGeopermissionsInstanceMetadata

Parameters:

  • permissions (Array[Hash]) (defaults to: nil)

    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.

Returns:



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/twilio-ruby/rest/accounts/v1/messaging_geopermissions.rb', line 117

def (
  permissions: nil
)

    data = Twilio::Values.of({
        'Permissions' => Twilio.serialize_list(permissions) { |e| Twilio.serialize_object(e) },
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('PATCH', @uri, data: data, headers: headers)
    messaging_geopermissions_instance = MessagingGeopermissionsInstance.new(
        @version,
        response.body,
    )
    .new(
        @version,
        messaging_geopermissions_instance,
        response.headers,
        response.status_code
    )
end