|  | 
|  | 1 | +import app from "../../opensrs.app.mjs"; | 
|  | 2 | +import utils from "../../common/utils.mjs"; | 
|  | 3 | +import constants from "../../common/constants.mjs"; | 
|  | 4 | + | 
|  | 5 | +export default { | 
|  | 6 | +  key: "opensrs-initiate-domain-transfer", | 
|  | 7 | +  name: "Initiate Domain Transfer", | 
|  | 8 | +  description: "Initiate a domain transfer to OpenSRS. [See the documentation](https://domains.opensrs.guide/docs/trade_domain).", | 
|  | 9 | +  version: "0.0.1", | 
|  | 10 | +  type: "action", | 
|  | 11 | +  props: { | 
|  | 12 | +    app, | 
|  | 13 | +    domain: { | 
|  | 14 | +      propDefinition: [ | 
|  | 15 | +        app, | 
|  | 16 | +        "domain", | 
|  | 17 | +      ], | 
|  | 18 | +    }, | 
|  | 19 | +    email: { | 
|  | 20 | +      type: "string", | 
|  | 21 | +      label: "Email", | 
|  | 22 | +      description: "The email address of the new owner of the domain.", | 
|  | 23 | +    }, | 
|  | 24 | +    firstName: { | 
|  | 25 | +      type: "string", | 
|  | 26 | +      label: "First Name", | 
|  | 27 | +      description: "The first name of the new owner of the domain.", | 
|  | 28 | +    }, | 
|  | 29 | +    lastName: { | 
|  | 30 | +      type: "string", | 
|  | 31 | +      label: "Last Name", | 
|  | 32 | +      description: "The last name of the new owner of the domain.", | 
|  | 33 | +    }, | 
|  | 34 | +    orgName: { | 
|  | 35 | +      type: "string", | 
|  | 36 | +      label: "Organization Name", | 
|  | 37 | +      description: "The organization name of the new owner of the domain.", | 
|  | 38 | +    }, | 
|  | 39 | +    phone: { | 
|  | 40 | +      type: "string", | 
|  | 41 | +      label: "Phone", | 
|  | 42 | +      description: "The phone number of the new owner of the domain. Required for all except `.BE`.", | 
|  | 43 | +      optional: true, | 
|  | 44 | +    }, | 
|  | 45 | +    address1: { | 
|  | 46 | +      type: "string", | 
|  | 47 | +      label: "Address 1", | 
|  | 48 | +      description: "The first line of the address of the new owner of the domain. Required for all except `.BE`.", | 
|  | 49 | +      optional: true, | 
|  | 50 | +    }, | 
|  | 51 | +    city: { | 
|  | 52 | +      type: "string", | 
|  | 53 | +      label: "City", | 
|  | 54 | +      description: "The city of the new owner of the domain. Required for all except `.BE`.", | 
|  | 55 | +      optional: true, | 
|  | 56 | +    }, | 
|  | 57 | +    country: { | 
|  | 58 | +      type: "string", | 
|  | 59 | +      label: "Country", | 
|  | 60 | +      description: "The country of the new owner of the domain. Required for all except `.BE`.", | 
|  | 61 | +      optional: true, | 
|  | 62 | +    }, | 
|  | 63 | +    state: { | 
|  | 64 | +      type: "string", | 
|  | 65 | +      label: "State", | 
|  | 66 | +      description: "The state of the new owner of the domain. Required for all except `.BE`.", | 
|  | 67 | +      optional: true, | 
|  | 68 | +    }, | 
|  | 69 | +    postalCode: { | 
|  | 70 | +      type: "string", | 
|  | 71 | +      label: "Postal Code", | 
|  | 72 | +      description: "The postal code of the new owner of the domain. Required for all except `.BE`.", | 
|  | 73 | +      optional: true, | 
|  | 74 | +    }, | 
|  | 75 | +    domainAuthInfo: { | 
|  | 76 | +      type: "string", | 
|  | 77 | +      label: "Domain Authorization Info", | 
|  | 78 | +      description: "The authorization code required for domain transfer. Required for `.BE`.", | 
|  | 79 | +      optional: true, | 
|  | 80 | +    }, | 
|  | 81 | +    jsonOutput: { | 
|  | 82 | +      type: "boolean", | 
|  | 83 | +      label: "JSON Output", | 
|  | 84 | +      description: "Whether to output the response in JSON format.", | 
|  | 85 | +      optional: true, | 
|  | 86 | +      default: true, | 
|  | 87 | +    }, | 
|  | 88 | +  }, | 
|  | 89 | +  methods: { | 
|  | 90 | +    getJsonBody() { | 
|  | 91 | +      const { | 
|  | 92 | +        domain, | 
|  | 93 | +        email, | 
|  | 94 | +        firstName, | 
|  | 95 | +        lastName, | 
|  | 96 | +        orgName, | 
|  | 97 | +        phone, | 
|  | 98 | +        address1, | 
|  | 99 | +        city, | 
|  | 100 | +        country, | 
|  | 101 | +        state, | 
|  | 102 | +        postalCode, | 
|  | 103 | +        domainAuthInfo, | 
|  | 104 | +      } = this; | 
|  | 105 | + | 
|  | 106 | +      return { | 
|  | 107 | +        data_block: { | 
|  | 108 | +          dt_assoc: { | 
|  | 109 | +            item: [ | 
|  | 110 | +              ...utils.addItem("protocol", constants.PROTOCOL.XCP), | 
|  | 111 | +              ...utils.addItem("object", constants.OBJECT_TYPE.DOMAIN), | 
|  | 112 | +              ...utils.addItem("action", constants.ACTION_TYPE.TRADE_DOMAIN), | 
|  | 113 | +              { | 
|  | 114 | +                "@_key": "attributes", | 
|  | 115 | +                "dt_assoc": { | 
|  | 116 | +                  item: [ | 
|  | 117 | +                    ...utils.addItem("domain", domain), | 
|  | 118 | +                    ...utils.addItem("email", email), | 
|  | 119 | +                    ...utils.addItem("first_name", firstName), | 
|  | 120 | +                    ...utils.addItem("last_name", lastName), | 
|  | 121 | +                    ...utils.addItem("org_name", orgName), | 
|  | 122 | +                    ...utils.addItem("phone", phone), | 
|  | 123 | +                    ...utils.addItem("address1", address1), | 
|  | 124 | +                    ...utils.addItem("city", city), | 
|  | 125 | +                    ...utils.addItem("country", country), | 
|  | 126 | +                    ...utils.addItem("state", state), | 
|  | 127 | +                    ...utils.addItem("postal_code", postalCode), | 
|  | 128 | +                    ...utils.addItem("domain_auth_info", domainAuthInfo), | 
|  | 129 | +                  ], | 
|  | 130 | +                }, | 
|  | 131 | +              }, | 
|  | 132 | +            ], | 
|  | 133 | +          }, | 
|  | 134 | +        }, | 
|  | 135 | +      }; | 
|  | 136 | +    }, | 
|  | 137 | +    initiateDomainTransfer(args = {}) { | 
|  | 138 | +      return this.app.post(args); | 
|  | 139 | +    }, | 
|  | 140 | +  }, | 
|  | 141 | +  async run({ $ }) { | 
|  | 142 | +    const { | 
|  | 143 | +      initiateDomainTransfer, | 
|  | 144 | +      getJsonBody, | 
|  | 145 | +      jsonOutput, | 
|  | 146 | +    } = this; | 
|  | 147 | + | 
|  | 148 | +    const response = await initiateDomainTransfer({ | 
|  | 149 | +      $, | 
|  | 150 | +      jsonBody: getJsonBody(), | 
|  | 151 | +      jsonOutput, | 
|  | 152 | +    }); | 
|  | 153 | + | 
|  | 154 | +    $.export("$summary", "Successfully initiated domain transfer."); | 
|  | 155 | +    return response; | 
|  | 156 | +  }, | 
|  | 157 | +}; | 
0 commit comments