netinternet / logicboxes
Laravel logicboxes 包
0.1.2
2019-02-21 13:03 UTC
Requires
- php: >=5.4.0
- illuminate/console: >=5.4
- illuminate/filesystem: >=5.4
- illuminate/support: >=5.4
- symfony/class-loader: ^2.3|^3.0
Requires (Dev)
- fzaninotto/faker: ~1.4
- guzzlehttp/guzzle: ~6.0
- illuminate/config: >=5.4
- illuminate/view: >=5.4
- orchestra/testbench: ~3.0
- phpunit/phpunit: ^6.4
README
Logicboxes 包
LogicBoxes 包提供了LogicBoxes API的大部分功能以及兼容的公司API,例如resellerclub、whois.com等。
此包主要针对laravel包开发,但也可作为独立包使用。
安装
composer require netinternet/logicboxes
默认情况下,包应该可以自动发现,但如果您使用的是较旧版本的laravel,您应该使用以下方式更改config/app.php;
在providers数组中添加以下内容;
Netinternet\Logicboxes\LogicboxesServiceProvider::class,
在aliases数组中添加以下内容;
'Logicboxes' => Netinternet\Logicboxes\Facades\Logicboxes::class,
配置
使用以下命令,并在需要时选择logicboxes选项。它将在config目录中创建logicboxes.php文件。
php artisan vendor:publish
您也可以手动创建此文件,并将以下内容粘贴到文件中;
<?php return [ 'mode' => env('LOGICBOXES_ENV', 'test'), 'auth-userid' => env('LOGICBOXES_AUTHID'), 'api-key' => env('LOGICBOXES_APIKEY') ];
如你所见,默认情况下,包使用环境变量。请确保在开发模式下使用测试模式。我们强烈建议创建LogicBox 示例账户
使用方法
您可以选择使用外观或辅助函数。在本文档中,我们将使用辅助函数作为示例。
use Logicboxes; // With Facade public function myMethod() { return Logicboxes::domain('domain-name.tld')->ns(); }
或使用辅助函数
public function myMethod() { return logicboxes()->domain('domain-name.tld')->ns(); }
可用方法
// get domain nameservers. logicboxes()->domain('domain-name.tld')->nameservers(); // get domain nameservers short. logicboxes()->domain('domain-name.tld')->ns(); // get domains all details. logicboxes()->domain('domain-name.tld')->details(); // get domains status logicboxes()->domain('domain-name.tld')->status(); // get domains order details logicboxes()->domain('domain-name.tld')->order(); // get domains dnssec details logicboxes()->domain('domain-name.tld')->dnssec(); // get domains contact id list. logicboxes()->domain('domain-name.tld')->contact()->ids(); // get domains registrant contact details logicboxes()->domain('domain-name.tld')->contact()->registrant(); // get domains admin contact details logicboxes()->domain('domain-name.tld')->contact()->admin(); // get domains tech contact details logicboxes()->domain('domain-name.tld')->contact()->tech(); // get domains billing contact details logicboxes()->domain('domain-name.tld')->contact()->billing(); // check for domain logicboxes()->domain('domain-name')->check(['com','net']) // first parameter is array of tlds and second parameter domain suggessions as a boolean. Default is false. // and you can also set domain index as third parameter for getting immediate domain status without result //object ```logicboxes()->domain('domain-name')->check(['com','net'],false,1)``` // get domain order id logicboxes()->domain('domain-name.tld')->orderId(); // set enable theft protection logicboxes()->domain('domain-name.tld')->enableTheftProtection(); // set disable theft protection logicboxes()->domain('domain-name.tld')->disableTheftProtection(); // modify domain nameservers logicboxes()->domain('domain-name.tld')->modifyNameServers((array) $ns); // delete this domain logicboxes()->domain('domain-name.tld')->delete(); // cancel domain transfer process logicboxes()->domain('domain-name.tld')->cancelTransfer(); // register domain logicboxes()->domain('domain-name.tld')->register([ 'years' => $years, 'ns' => (array) $ns, 'customer-id' => $customerId, 'reg-contact-id' => $regContactId, 'admin-contact-id' => $adminContactId, 'tech-contact-id' => $techContactId, 'billing-contact-id' => $billingContactId, 'invoice-option' => 'KeepInvoice', 'purchase-privacy' => $purchasePrivacy, 'protect-privacy' => $protectPrivacy, ]); // Domain transfer logicboxes()->domain('domain-name.tld')->transfer([ 'auth-code' => $authCode, 'years' => $years, 'ns' => (array)$ns, 'customer-id' => $customerId, 'reg-contact-id' => $regContactId, 'admin-contact-id' => $adminContactId, 'tech-contact-id' => $techContactId, 'billing-contact-id' => $billingContactId, 'invoice-option' => $invoiceOption, 'purchase-privacy' => $purchasePrivacy, 'protect-privacy' => $protectPrivacy, ]); // set Auth Code logicboxes()->domain('domain-name.tld')->authCode('authcode'); // modify Auth Code logicboxes()->domain('domain-name.tld')->modifyAuthCode('authcode'); // modify Auth Code logicboxes()->domain('domain-name.tld')->validateTransferRequest(); // renew domain ($date => epochtime) logicboxes()->domain('domain-name.tld')->renew($years, $date, $invoiceOption, true); // $purchasePrivacy is default false // deafult customer nameservers logicboxes()->domain()->customerDefaultNameServers($customerId); // Check premium logicboxes()->domain('domain-name.tld')->isDomainPremium(); // add new child nameserver logicboxes()->domain('domain-name.tld')->addChildNs('ns1.domain.com', ['0.0.0.0', '0.0.0.1']); // get lock applied list logicboxes()->domain('domain-name.tld')->getListLockApplied(); // set suspend logicboxes()->domain('domain-name.tld')->suspend('reason text'); // set unsuspend logicboxes()->domain('domain-name.tld')->unSuspend();
客户
// Creating a customer logicboxes()->customer()->create([ 'username' => $this->faker->email, 'passwd' => 'Qs3jiA5fd8mq4', 'name' => $this->faker->name, 'company' => $this->faker->company, 'address-line-1' => $this->faker->streetAddress, 'city' => $this->faker->city, 'state' => $this->faker->state, 'country' => $this->faker->countryCode, 'zipcode' => $this->faker->postcode, 'phone-cc' => 90, 'phone' => 5555555555, 'lang-pref' => 'en' ]); // getting a customer by email or id logicboxes()->customer()->get('app@yourdomain.com') //or by id logicboxes()->customer()->get(17939294) // Changing customers password logicboxes()->customer()->get('app@yourdomain.com','myNew8CharPassword') // Change customer logicboxes()->customer()->moveProduct("app@yourdomain.com", 'old-customer-id', 'new-customer-id, 'old-contact');
测试配置
- 您首先应该打开LogicBox测试账户LogicBox 示例账户链接
- 复制示例配置文件
cp tests/config.ini.example tests/config.ini
- 在tests/config.ini文件中更改凭据。
- 运行phpunit
$ vendor/phpunit/phpunit/phpunit
贡献
- 将其分支( https://github.com/netinternet/logicboxes-api/ )
- 创建您的功能分支(git checkout -b my-new-feature)
- 提交您的更改(git commit -am '添加一些功能')
- 将分支推送到远程仓库(git push origin my-new-feature)
- 创建新的Pull Request