| 1 | package WWW::DaftarNama::Reseller; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | our $DATE = '2018-12-17'; # DATE | |||||||||
| 4 | 1 | our $VERSION = '0.002'; # VERSION | |||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use 5.010001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use Exporter::Rinci qw(import); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 1 | our %SPEC; | |||||||||
| 13 | |||||||||||
| 14 | 1 | my %args_common = ( | |||||||||
| 15 | username => { | ||||||||||
| 16 | schema => 'str*', | ||||||||||
| 17 | req => 1, | ||||||||||
| 18 | tags => ['common', 'category:credential'], | ||||||||||
| 19 | }, | ||||||||||
| 20 | password => { | ||||||||||
| 21 | schema => 'str*', | ||||||||||
| 22 | req => 1, | ||||||||||
| 23 | is_password => 1, | ||||||||||
| 24 | tags => ['common', 'category:credential'], | ||||||||||
| 25 | }, | ||||||||||
| 26 | idkey => { | ||||||||||
| 27 | schema => 'str*', | ||||||||||
| 28 | req => 1, | ||||||||||
| 29 | is_password => 1, | ||||||||||
| 30 | tags => ['common', 'category:credential'], | ||||||||||
| 31 | }, | ||||||||||
| 32 | ); | ||||||||||
| 33 | |||||||||||
| 34 | 1 | my %arg0_domain = ( | |||||||||
| 35 | domain => { | ||||||||||
| 36 | schema => 'domain::name*', | ||||||||||
| 37 | req => 1, | ||||||||||
| 38 | pos => 0, | ||||||||||
| 39 | }, | ||||||||||
| 40 | ); | ||||||||||
| 41 | |||||||||||
| 42 | 1 | my %args_ns = ( | |||||||||
| 43 | ns1 => {schema => 'net::hostname*', req=>1}, | ||||||||||
| 44 | ns2 => {schema => 'net::hostname*', req=>1}, | ||||||||||
| 45 | ns3 => {schema => 'net::hostname*', req=>1}, | ||||||||||
| 46 | ns4 => {schema => 'net::hostname*', req=>1}, | ||||||||||
| 47 | ); | ||||||||||
| 48 | |||||||||||
| 49 | 1 | my %args_contact = ( | |||||||||
| 50 | firstname => {schema => 'str*', req=>1}, | ||||||||||
| 51 | lastname => {schema => 'str*', req=>1}, | ||||||||||
| 52 | company => {schema => 'str*', req=>1}, | ||||||||||
| 53 | address => {schema => 'str*', req=>1}, | ||||||||||
| 54 | city => {schema => 'str*', req=>1}, | ||||||||||
| 55 | state => {schema => 'str*', req=>1}, | ||||||||||
| 56 | zip => {schema => 'str*', req=>1}, | ||||||||||
| 57 | country => {schema => 'str*', req=>1}, | ||||||||||
| 58 | email => {schema => 'str*', req=>1}, # XXX email | ||||||||||
| 59 | phone => {schema => 'str*', req=>1}, # XXX phone::number | ||||||||||
| 60 | ); | ||||||||||
| 61 | |||||||||||
| 62 | 1 | my %arg_ns = ( | |||||||||
| 63 | ns => {schema => 'net::hostname*', req=>1}, | ||||||||||
| 64 | ); | ||||||||||
| 65 | |||||||||||
| 66 | 0 | ▶ | sub _request { | ||||||||
|
Subroutine
_request: not called CC=3 SCAR=24.8
| |||||||||||
| 67 | 0 | require HTTP::Tiny; | |||||||||
| 68 | 0 | require JSON::MaybeXS; | |||||||||
| 69 | |||||||||||
| 70 | 0 | my (%args) = @_; | |||||||||
| 71 | |||||||||||
| 72 | 0 | my $url = "https://www.daftarnama.id/api/provider.php"; | |||||||||
| 73 | 0 | my $res = HTTP::Tiny->new->post_form($url, \%args); | |||||||||
| 74 | return [$res->{status}, "Can't post to $url: $res->{reason}"] | ||||||||||
| 75 | 0 | ▶ | unless $res->{success}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 76 | |||||||||||
| 77 | 0 | my $data; | |||||||||
| 78 | 0 | eval { $data = JSON::MaybeXS::decode_json($res->{content}) }; | |||||||||
| 79 | 0 | ▶ | return [500, "Invalid JSON response from server: $@"] if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 80 | |||||||||||
| 81 | 0 | [200, "OK", $data]; | |||||||||
| 82 | } | ||||||||||
| 83 | |||||||||||
| 84 | $SPEC{get_ns} = { | ||||||||||
| 85 | 1 | v => 1.1, | |||||||||
| 86 | summary => 'Get nameservers for a domain', | ||||||||||
| 87 | args => { | ||||||||||
| 88 | %args_common, | ||||||||||
| 89 | %arg0_domain, | ||||||||||
| 90 | }, | ||||||||||
| 91 | }; | ||||||||||
| 92 | 0 | ▶ | sub get_ns { | ||||||||
|
Subroutine
get_ns: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 93 | 0 | my %args = @_; | |||||||||
| 94 | 0 | _request( | |||||||||
| 95 | action => 'getDNS', | ||||||||||
| 96 | %args, | ||||||||||
| 97 | ); | ||||||||||
| 98 | } | ||||||||||
| 99 | |||||||||||
| 100 | $SPEC{update_ns} = { | ||||||||||
| 101 | 1 | v => 1.1, | |||||||||
| 102 | summary => 'Update nameservers for a domain', | ||||||||||
| 103 | args => { | ||||||||||
| 104 | %args_common, | ||||||||||
| 105 | %arg0_domain, | ||||||||||
| 106 | %args_ns, | ||||||||||
| 107 | }, | ||||||||||
| 108 | }; | ||||||||||
| 109 | 0 | ▶ | sub update_ns { | ||||||||
|
Subroutine
update_ns: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 110 | 0 | my %args = @_; | |||||||||
| 111 | 0 | _request( | |||||||||
| 112 | action => 'updateDNS', | ||||||||||
| 113 | %args, | ||||||||||
| 114 | ); | ||||||||||
| 115 | } | ||||||||||
| 116 | |||||||||||
| 117 | $SPEC{get_lock_status} = { | ||||||||||
| 118 | 1 | v => 1.1, | |||||||||
| 119 | summary => 'Get lock status for a domain', | ||||||||||
| 120 | args => { | ||||||||||
| 121 | %args_common, | ||||||||||
| 122 | %arg0_domain, | ||||||||||
| 123 | }, | ||||||||||
| 124 | }; | ||||||||||
| 125 | 0 | ▶ | sub get_lock_status { | ||||||||
|
Subroutine
get_lock_status: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 126 | 0 | my %args = @_; | |||||||||
| 127 | 0 | _request( | |||||||||
| 128 | action => 'getStatus', | ||||||||||
| 129 | %args, | ||||||||||
| 130 | ); | ||||||||||
| 131 | } | ||||||||||
| 132 | |||||||||||
| 133 | $SPEC{update_lock_status} = { | ||||||||||
| 134 | 1 | v => 1.1, | |||||||||
| 135 | summary => 'Update lock status for a domain', | ||||||||||
| 136 | args => { | ||||||||||
| 137 | %args_common, | ||||||||||
| 138 | %arg0_domain, | ||||||||||
| 139 | statusKey => {schema => 'str*', req=>1}, | ||||||||||
| 140 | }, | ||||||||||
| 141 | }; | ||||||||||
| 142 | 0 | ▶ | sub update_lock_status { | ||||||||
|
Subroutine
update_lock_status: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 143 | 0 | my %args = @_; | |||||||||
| 144 | 0 | _request( | |||||||||
| 145 | action => 'changeStatus', | ||||||||||
| 146 | %args, | ||||||||||
| 147 | ); | ||||||||||
| 148 | } | ||||||||||
| 149 | |||||||||||
| 150 | $SPEC{register} = { | ||||||||||
| 151 | 1 | v => 1.1, | |||||||||
| 152 | summary => 'Register a domain', | ||||||||||
| 153 | args => { | ||||||||||
| 154 | %args_common, | ||||||||||
| 155 | %arg0_domain, | ||||||||||
| 156 | |||||||||||
| 157 | periode => {schema => ['int*', between=>[1,10]]}, | ||||||||||
| 158 | %args_ns, | ||||||||||
| 159 | %args_contact, | ||||||||||
| 160 | }, | ||||||||||
| 161 | }; | ||||||||||
| 162 | 0 | ▶ | sub register { | ||||||||
|
Subroutine
register: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 163 | 0 | my %args = @_; | |||||||||
| 164 | 0 | _request( | |||||||||
| 165 | action => 'domainRegister', | ||||||||||
| 166 | %args, | ||||||||||
| 167 | ); | ||||||||||
| 168 | } | ||||||||||
| 169 | |||||||||||
| 170 | $SPEC{transfer} = { | ||||||||||
| 171 | 1 | v => 1.1, | |||||||||
| 172 | summary => 'Transfer a domain', | ||||||||||
| 173 | args => { | ||||||||||
| 174 | %args_common, | ||||||||||
| 175 | %arg0_domain, | ||||||||||
| 176 | eppCode => {schema => 'str*', req=>1}, | ||||||||||
| 177 | }, | ||||||||||
| 178 | }; | ||||||||||
| 179 | 0 | ▶ | sub transfer { | ||||||||
|
Subroutine
transfer: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 180 | 0 | my %args = @_; | |||||||||
| 181 | 0 | _request( | |||||||||
| 182 | action => 'domainRegister', | ||||||||||
| 183 | %args, | ||||||||||
| 184 | ); | ||||||||||
| 185 | } | ||||||||||
| 186 | |||||||||||
| 187 | $SPEC{renew} = { | ||||||||||
| 188 | 1 | v => 1.1, | |||||||||
| 189 | summary => 'Renew a domain', | ||||||||||
| 190 | args => { | ||||||||||
| 191 | %args_common, | ||||||||||
| 192 | %arg0_domain, | ||||||||||
| 193 | eppCode => {schema => 'str*', req=>1}, | ||||||||||
| 194 | }, | ||||||||||
| 195 | }; | ||||||||||
| 196 | 0 | ▶ | sub renew { | ||||||||
|
Subroutine
renew: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 197 | 0 | my %args = @_; | |||||||||
| 198 | 0 | _request( | |||||||||
| 199 | action => 'domainRenewal', | ||||||||||
| 200 | %args, | ||||||||||
| 201 | ); | ||||||||||
| 202 | } | ||||||||||
| 203 | |||||||||||
| 204 | $SPEC{get_contact} = { | ||||||||||
| 205 | 1 | v => 1.1, | |||||||||
| 206 | summary => 'Get contact information for a domain', | ||||||||||
| 207 | args => { | ||||||||||
| 208 | %args_common, | ||||||||||
| 209 | %arg0_domain, | ||||||||||
| 210 | }, | ||||||||||
| 211 | }; | ||||||||||
| 212 | 0 | ▶ | sub get_contact { | ||||||||
|
Subroutine
get_contact: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 213 | 0 | my %args = @_; | |||||||||
| 214 | 0 | _request( | |||||||||
| 215 | action => 'whoisDomain', | ||||||||||
| 216 | %args, | ||||||||||
| 217 | ); | ||||||||||
| 218 | } | ||||||||||
| 219 | |||||||||||
| 220 | $SPEC{update_contact} = { | ||||||||||
| 221 | 1 | v => 1.1, | |||||||||
| 222 | summary => 'Update contact information for a domain', | ||||||||||
| 223 | args => { | ||||||||||
| 224 | %args_common, | ||||||||||
| 225 | %arg0_domain, | ||||||||||
| 226 | %args_contact, | ||||||||||
| 227 | contacttype => { | ||||||||||
| 228 | schema => ['str*', in=>[qw/all reg admin tech billing/]], | ||||||||||
| 229 | req => 1, | ||||||||||
| 230 | }, | ||||||||||
| 231 | }, | ||||||||||
| 232 | }; | ||||||||||
| 233 | 0 | ▶ | sub update_contact { | ||||||||
|
Subroutine
update_contact: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 234 | 0 | my %args = @_; | |||||||||
| 235 | 0 | _request( | |||||||||
| 236 | action => 'updateWhois', | ||||||||||
| 237 | %args, | ||||||||||
| 238 | ); | ||||||||||
| 239 | } | ||||||||||
| 240 | |||||||||||
| 241 | $SPEC{get_epp} = { | ||||||||||
| 242 | 1 | v => 1.1, | |||||||||
| 243 | summary => 'Get EPP Code for a domain', | ||||||||||
| 244 | args => { | ||||||||||
| 245 | %args_common, | ||||||||||
| 246 | %arg0_domain, | ||||||||||
| 247 | }, | ||||||||||
| 248 | }; | ||||||||||
| 249 | 0 | ▶ | sub get_epp { | ||||||||
|
Subroutine
get_epp: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 250 | 0 | my %args = @_; | |||||||||
| 251 | 0 | _request( | |||||||||
| 252 | action => 'getEPP', | ||||||||||
| 253 | %args, | ||||||||||
| 254 | ); | ||||||||||
| 255 | } | ||||||||||
| 256 | |||||||||||
| 257 | $SPEC{register_ns} = { | ||||||||||
| 258 | 1 | v => 1.1, | |||||||||
| 259 | summary => 'Register a nameserver', | ||||||||||
| 260 | args => { | ||||||||||
| 261 | %args_common, | ||||||||||
| 262 | %arg0_domain, | ||||||||||
| 263 | %arg_ns, | ||||||||||
| 264 | ip => {schema => 'net::ipv4*', req=>1}, | ||||||||||
| 265 | }, | ||||||||||
| 266 | }; | ||||||||||
| 267 | 0 | ▶ | sub register_ns { | ||||||||
|
Subroutine
register_ns: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 268 | 0 | my %args = @_; | |||||||||
| 269 | 0 | _request( | |||||||||
| 270 | action => 'hostRegister', | ||||||||||
| 271 | %args, | ||||||||||
| 272 | ); | ||||||||||
| 273 | } | ||||||||||
| 274 | |||||||||||
| 275 | $SPEC{delete_ns} = { | ||||||||||
| 276 | 1 | v => 1.1, | |||||||||
| 277 | summary => 'Delete a nameserver', | ||||||||||
| 278 | args => { | ||||||||||
| 279 | %args_common, | ||||||||||
| 280 | %arg0_domain, | ||||||||||
| 281 | %arg_ns, | ||||||||||
| 282 | }, | ||||||||||
| 283 | }; | ||||||||||
| 284 | 0 | ▶ | sub delete_ns { | ||||||||
|
Subroutine
delete_ns: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 285 | 0 | my %args = @_; | |||||||||
| 286 | 0 | _request( | |||||||||
| 287 | action => 'deleteHost', | ||||||||||
| 288 | %args, | ||||||||||
| 289 | ); | ||||||||||
| 290 | } | ||||||||||
| 291 | |||||||||||
| 292 | $SPEC{get_registrar} = { | ||||||||||
| 293 | 1 | v => 1.1, | |||||||||
| 294 | summary => 'Get registrar of a domain', | ||||||||||
| 295 | args => { | ||||||||||
| 296 | %args_common, | ||||||||||
| 297 | %arg0_domain, | ||||||||||
| 298 | }, | ||||||||||
| 299 | }; | ||||||||||
| 300 | 0 | ▶ | sub get_registrar { | ||||||||
|
Subroutine
get_registrar: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 301 | 0 | my %args = @_; | |||||||||
| 302 | 0 | _request( | |||||||||
| 303 | action => 'getRegistrar', | ||||||||||
| 304 | %args, | ||||||||||
| 305 | ); | ||||||||||
| 306 | } | ||||||||||
| 307 | |||||||||||
| 308 | $SPEC{check_availability} = { | ||||||||||
| 309 | 1 | v => 1.1, | |||||||||
| 310 | summary => 'Check the availability of a domain', | ||||||||||
| 311 | args => { | ||||||||||
| 312 | %args_common, | ||||||||||
| 313 | %arg0_domain, | ||||||||||
| 314 | }, | ||||||||||
| 315 | }; | ||||||||||
| 316 | 0 | ▶ | sub check_availability { | ||||||||
|
Subroutine
check_availability: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 317 | 0 | my %args = @_; | |||||||||
| 318 | 0 | _request( | |||||||||
| 319 | action => 'checkAvailibility', | ||||||||||
| 320 | %args, | ||||||||||
| 321 | ); | ||||||||||
| 322 | } | ||||||||||
| 323 | |||||||||||
| 324 | # XXX: uploadDocument | ||||||||||
| 325 | # XXX: changeStatuses | ||||||||||
| 326 | # XXX: checkDocument | ||||||||||
| 327 | # XXX: docType | ||||||||||
| 328 | # XXX: deleteDomain | ||||||||||
| 329 | # XXX: deleteDNSSec | ||||||||||
| 330 | # XXX: getEXP | ||||||||||
| 331 | # XXX: getRegistrar | ||||||||||
| 332 | # XXX: updateDNSSec | ||||||||||
| 333 | # XXX: domainRestore | ||||||||||
| 334 | |||||||||||
| 335 | 1 | 1; | |||||||||
| 336 | # ABSTRACT: Reseller API client for DaftarNama.id | ||||||||||
| 337 | |||||||||||
| 338 | __END__ | ||||||||||