Test Failed
Pull Request — master (#46)
by Yuji
04:29
created

GetOrderInfoRequest::setOrderId()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
nc 2
cc 2
eloc 5
nop 1
1
<?php
2
3
namespace Shippinno\YahooShoppingJp\Request;
4
5
use FluidXml\FluidXml;
6
use LogicException;
7
use Shippinno\YahooShoppingJp\Api\GetOrderInfoApi;
8
use Shippinno\YahooShoppingJp\Exception\InvalidRequestException;
9
use Shippinno\YahooShoppingJp\Response\GetOrderInfoResponse;
10
11
class GetOrderInfoRequest extends AbstractRequest
12
{
13
14
    public function __construct()
15
    {
16
        $this->params['Target']['Field'] = implode(',', [
17
            'OrderId', 'Version', 'ParentOrderId', 'ChildOrderId', 'DeviceType', 'MobileCarrierName', 'IsSeen',
18
            'IsSplit', 'CancelReason', 'IsRoyalty', 'IsRoyaltyFix', 'IsSeller', 'IsAffiliate', 'IsRatingB2s', 'NeedSnl',
19
            'OrderTime', 'LastUpdateTime', 'Suspect', 'SuspectMessage', 'OrderStatus', 'StoreStatus', 'RoyaltyFixTime',
20
            'SendConfirmTime', 'SendPayTime', 'PrintSlipTime', 'PrintDeliveryTime', 'PrintBillTime', 'BuyerComments',
21
            'SellerComments', 'Notes', 'OperationUser', 'Referer', 'EntryPoint', 'HistoryId', 'HistoryId',
22
            'UseCouponData', 'UseCouponData', 'ShippingCouponFlg', 'ShippingCouponDiscount', 'CampaignPoints',
23
            'PayStatus', 'SettleStatus', 'PayType', 'PayKind', 'PayMethod', 'PayMethodName', 'SellerHandlingCharge',
24
            'PayActionTime', 'PayDate', 'PayNotes', 'SettleId', 'CardBrand', 'CardNumber', 'CardNumberLast4',
25
            'CardExpireYear', 'CardExpireMonth', 'CardPayType', 'CardHolderName', 'CardPayCount', 'CardBirthDay',
26
            'UseYahooCard', 'UseWallet', 'NeedBillSlip', 'NeedDetailedSlip', 'NeedReceipt', 'AgeConfirmField',
27
            'AgeConfirmValue', 'AgeConfirmValue', 'BillAddressFrom', 'BillFirstName', 'BillFirstNameKana',
28
            'BillLastName', 'BillLastNameKana', 'BillZipCode', 'BillPrefecture', 'BillPrefectureKana', 'BillCity',
29
            'BillCityKana', 'BillAddress1', 'BillAddress1Kana', 'BillAddress2', 'BillAddress2Kana', 'BillPhoneNumber',
30
            'BillEmgPhoneNumber', 'BillMailAddress', 'BillSection1Field', 'BillSection1Value', 'BillSection2Field',
31
            'BillSection2Value', 'PayNo', 'PayNoIssueDate', 'ConfirmNumber', 'PaymentTerm', 'ShipStatus', 'ShipMethod',
32
            'ShipMethodName', 'ShipRequestDate', 'ShipRequestTime', 'ShipNotes', 'ShipInvoiceNumber1',
33
            'ShipInvoiceNumber2', 'ShipUrl', 'ArriveType', 'ShipDate', 'ArrivalDate', 'NeedGiftWrap', 'GiftWrapType',
34
            'GiftWrapMessage', 'NeedGiftWrapPaper', 'GiftWrapPaperType', 'GiftWrapName', 'Option1Field', 'Option1Type',
35
            'Option1Value', 'Option2Field', 'Option2Type', 'Option2Value', 'ShipFirstName', 'ShipFirstNameKana',
36
            'ShipLastName', 'ShipLastNameKana', 'ShipZipCode', 'ShipPrefecture', 'ShipPrefectureKana', 'ShipCity',
37
            'ShipCityKana', 'ShipAddress1', 'ShipAddress1Kana', 'ShipAddress2', 'ShipAddress2Kana', 'ShipPhoneNumber',
38
            'ShipEmgPhoneNumber', 'ShipSection1Field', 'ShipSection1Value', 'ShipSection2Field', 'ShipSection2Value',
39
            'PayCharge', 'ShipCharge', 'GiftWrapCharge', 'Discount', 'Adjustments', 'SettleAmount', 'UsePoint',
40
            'TotalPrice', 'SettlePayAmount', 'TaxRatio', 'IsGetPointFixAll', 'TotalMallCouponDiscount', 'LineId',
41
            'ItemId', 'Title', 'SubCode', 'SubCodeOption', 'ItemOption', 'Inscription', 'IsUsed', 'ImageId', 'IsTaxable',
42
            'Jan', 'ProductId', 'CategoryId', 'AffiliateRatio', 'UnitPrice', 'Quantity', 'PointAvailQuantity',
43
            'ReleaseDate', 'IsShippingFree', 'HaveReview', 'PointFspCode', 'PointRatioY', 'PointRatioSeller',
44
            'UnitGetPoint', 'IsGetPointFix', 'GetPointFixDate', 'CouponData', 'CouponDiscount', 'CouponUseNum',
45
            'OriginalPrice', 'OriginalNum', 'SellerId', 'IsLogin', 'FspLicenseCode', 'FspLicenseName', 'GuestAuthId',
46
        ]);
47
    }
48
49
    /**
50
     * @return GetOrderInfoApi
51
     */
52
    public function api()
53
    {
54
        return new GetOrderInfoApi;
55
    }
56
57
    /**
58
     * @return GetOrderInfoResponse
59
     */
60
    public function response()
61
    {
62
        return new GetOrderInfoResponse;
63
    }
64
65
    /**
66
     * @return void
67
     */
68
    protected function validateParams()
69
    {
70
        if (!isset($this->params['SellerId'])) {
71
            throw new InvalidRequestException('SellerId is required.');
72
        }
73
74
        if (!isset($this->params['Target']['OrderId'])) {
75
            throw new InvalidRequestException('OrderId is required.');
76
        }
77
    }
78
79
    /**
80
     * @return array
81
     */
82
    public function getParams()
83
    {
84
        $this->validateParams();
85
86
        $fluidXml = new FluidXml('Req');
87
        $fluidXml->add($this->params);
88
89
        return $fluidXml->xml();
90
    }
91
92
    /**
93
     * @param string $sellerId
94
     * @return self
95
     */
96 View Code Duplication
    public function setSellerId(string $sellerId): self
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
97
    {
98
        if (isset($this->params['SellerId'])) {
99
            throw new LogicException('SellerId is already set.');
100
        }
101
102
        $this->params['SellerId'] = $sellerId;
103
104
        return $this;
105
    }
106
107
    /**
108
     * @param string $orderId
109
     * @return self
110
     */
111
    public function setOrderId(string $orderId): self
112
    {
113
        if (isset($this->params['Target']['OrderId'])) {
114
            throw new LogicException('OrderId is already set.');
115
        }
116
117
        $this->params['Target']['OrderId'] = $orderId;
118
119
        return $this;
120
    }
121
122
}
123