Skip to content

Commit 044491a

Browse files
Merge pull request #372 from mailgun/370-skiped-domain-update-method
feature: Add skipped domain update method
2 parents d03a240 + 24c6002 commit 044491a

File tree

13 files changed

+24195
-123
lines changed

13 files changed

+24195
-123
lines changed

README.md

Lines changed: 140 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ The following service methods are available to instantiated clients. The example
8989
- [list](#list)
9090
- [get](#get)
9191
- [create](#create-1)
92+
- [update](#update)
9293
- [destroy](#destroy)
9394
- [getTracking](#gettracking)
9495
- [updateTracking](#updatetracking)
@@ -122,13 +123,13 @@ The following service methods are available to instantiated clients. The example
122123
- [list](#list-2)
123124
- [get](#get-3)
124125
- [create](#create-3)
125-
- [update](#update)
126+
- [update](#update-1)
126127
- [destroy](#destroy-2)
127128
- [routes](#routes)
128129
- [list](#list-3)
129130
- [get](#get-4)
130131
- [create](#create-4)
131-
- [update](#update-1)
132+
- [update](#update-2)
132133
- [destroy](#destroy-3)
133134
- [validate](#validate)
134135
- [get](#get-5)
@@ -141,7 +142,7 @@ The following service methods are available to instantiated clients. The example
141142
- [list](#list-5)
142143
- [get](#get-6)
143144
- [create](#create-6)
144-
- [update](#update-2)
145+
- [update](#update-3)
145146
- [destroy](#destroy-5)
146147
- [mailing list members](#mailing-list-members)
147148
- [listMembers](#listmember)
@@ -485,13 +486,13 @@ Method naming conventions:
485486

486487
- #### get
487488

488-
`mg.domains.get()`
489+
`mg.domains.get(domain)`
489490

490491
Example:
491492

492493
```JS
493-
mg.domains.get()
494-
.then(domains => console.log(domains)) // logs array of domains
494+
mg.domains.get('testing.example.com')
495+
.then(domains => console.log(domains)) // logs domain object
495496
.catch(err => console.error(err)); // logs any error
496497
```
497498

@@ -538,7 +539,11 @@ Method naming conventions:
538539
spam_action: 'disabled',
539540
state: 'unverified',
540541
type: 'custom',
541-
wildcard: true
542+
wildcard: true,
543+
id: '64a4291ebbe4ec7e1d78bc80',
544+
is_disabled: false,
545+
web_prefix: 'email',
546+
web_scheme: 'http'
542547
}
543548
```
544549

@@ -556,59 +561,149 @@ Method naming conventions:
556561

557562
Create method accepts data object with next properties:
558563

564+
| Parameter | Description |
565+
|--- |--- |
566+
| name | Name of the domain (ex. domain.com) |
567+
| smtp_password | Password for SMTP authentication |
568+
| spam_action | `disabled`, `block`, or `tag`<br>If `disabled`, no spam filtering will occur for inbound messages.<br>If `block`, inbound spam messages will not be delivered.<br>If `tag`, inbound messages will be tagged with a spam header. [Spam Filter](https://documentation.mailgun.com/en/latest/user_manual.html#um-spam-filter)<br>The default is `disabled`. |
569+
| wildcard | Can be string `'true'` or `'false'` or `boolean`<br>Determines whether the domain will accept email for sub-domains when sending messages.<br>The default is `false`. |
570+
| force_dkim_authority | Can be string `'true'` or `'false'` or `boolean`<br>If set to `true`, the domain will be the DKIM authority for itself even if the root domain is registered on the same mailgun account<br>If set to `false`, the domain will have the same DKIM authority as the root domain registered on the same mailgun account<br>The default is `false`. |
571+
| dkim_key_size | **1024** or **2048**<br>Set the length of your domain’s generated DKIM key<br>The default is **1024** |
572+
| ips | An optional, comma-separated list of IP addresses to be assigned to this domain. If not specified, all dedicated IP addresses on the account will be assigned. If the request cannot be fulfilled (e.g. a requested IP is not assigned to the account, etc), a 400 will be returned. |
573+
| pool_id | The id of the IP Pool that you wish to assign to the domain. The pool must contain at least 1 IP. (Note: IP Pools are only available on certain plans; see http://mailgun.com/pricing) |
574+
| web_scheme | String with `http` or `https`<br>Set your **open**, **click** and **unsubscribe** URLs to use `http` or `https`<br>The default is `http` |
575+
576+
Promise returns:
577+
578+
```JS
579+
name: 'foobar.example.com',
580+
require_tls: false,
581+
skip_verification: false,
582+
state: 'unverified',
583+
wildcard: false,
584+
spam_action: 'disabled',
585+
created_at: 'Tue, 04 Jul 2023 14:09:18 GMT',
586+
smtp_password: undefined,
587+
smtp_login: '[email protected]',
588+
type: 'custom',
589+
receiving_dns_records: [{
590+
"name": "foobar.example.com",
591+
"record_type": "TXT",
592+
"valid": "unknown",
593+
"value": "v=spf1 include:mailgun.org ~all"
594+
},
595+
{
596+
"name": "k1._domainkey.foobar.example.com",
597+
"record_type": "TXT",
598+
"valid": "unknown",
599+
"value": "k=rsa; 123456"
600+
},
601+
{
602+
"name": "email.foobar.example.com",
603+
"record_type": "CNAME",
604+
"valid": "unknown",
605+
"value": "mailgun.org"
606+
}
607+
],
608+
sending_dns_records: [{
609+
"priority": "10",
610+
"record_type": "MX",
611+
"valid": "unknown",
612+
"value": "mxa.mailgun.org"
613+
},
614+
{
615+
"priority": "10",
616+
"record_type": "MX",
617+
"valid": "unknown",
618+
"value": "mxb.mailgun.org"
619+
}],
620+
id: '64a4291ebbe4ec7e1d78bc80',
621+
is_disabled: false,
622+
web_prefix: 'email',
623+
web_scheme: 'http'
624+
```
625+
626+
- #### update
627+
628+
`mg.domains.update(domain, options)`
629+
630+
Example:
631+
632+
```js
633+
mg.domains.update('foobar.example.com',{
634+
wildcard: 'true',
635+
web_scheme: 'http',
636+
spam_action: 'disabled',
637+
})
638+
.then(msg => console.log(msg)) // logs response data
639+
.catch(err => console.error(err)); // logs any error
640+
```
641+
642+
Update method accepts data object with next properties:
643+
559644
| Property | Description |
560645
|:--------------|:----------------------------------------------------------------------------------------------------------------------------------------------|
561-
| name | Name of the domain (ex. domain.com) |
562-
| smtp_password | Password for SMTP authentication |
563-
| spam_action | disabled or tag Disable, no spam filtering will occur for inbound messages. Tag, messages will be tagged wtih a spam header. See Spam Filter. |
564-
| wildcard | true or false Determines whether the domain will accept email for sub-domains. |
646+
| spam_action | Can be string with value `disabled`, `block`, or `tag`. If *disabled*, no spam filtering will occur for inbound messages. If `block`, inbound spam messages will not be delivered. If `tag`, inbound messages will be tagged with a spam header. See [Spam Filter](https://documentation.mailgun.com/en/latest/user_manual.html#um-spam-filter).|
647+
| web_scheme | Can be string with value `http` or `https`. Set your **open**, **click** and **unsubscribe** URLs to use `http` or `https`. The default is `http`|
648+
| wildcard | Can be string `'true'` or `'false'` or `boolean`. Determines whether the domain will accept email for sub-domains. The default is `false`.|
565649

566650
Promise returns:
567651

568652
```JS
569653
{
570-
created_at: 'Sun, 19 Oct 2014 18:49:36 GMT',
571654
name: 'foobar.example.com',
572-
receiving_dns_records: [{
573-
"name": "foobar.example.com",
574-
"record_type": "TXT",
575-
"valid": "unknown",
576-
"value": "v=spf1 include:mailgun.org ~all"
577-
},
655+
require_tls: false,
656+
skip_verification: false,
657+
state: 'unverified',
658+
wildcard: true,
659+
spam_action: 'disabled',
660+
created_at: 'Tue, 04 Jul 2023 14:09:18 GMT',
661+
smtp_password: undefined,
662+
smtp_login: '[email protected]',
663+
type: 'custom',
664+
receiving_dns_records: [
578665
{
579-
"name": "k1._domainkey.foobar.example.com",
580-
"record_type": "TXT",
581-
"valid": "unknown",
582-
"value": "k=rsa; 123456"
666+
is_active: true,
667+
cached: [],
668+
priority: '10',
669+
record_type: 'MX',
670+
valid: 'unknown',
671+
value: 'mxa.mailgun.org'
583672
},
584673
{
585-
"name": "email.foobar.example.com",
586-
"record_type": "CNAME",
587-
"valid": "unknown",
588-
"value": "mailgun.org"
589-
}],
590-
require_tls: true,
591-
sending_dns_records: [{
592-
"priority": "10",
593-
"record_type": "MX",
594-
"valid": "unknown",
595-
"value": "mxa.mailgun.org"
674+
is_active: true,
675+
cached: [],
676+
priority: '10',
677+
record_type: 'MX',
678+
valid: 'unknown',
679+
value: 'mxb.mailgun.org'
680+
}
681+
],
682+
sending_dns_records: [
683+
{
684+
is_active: true,
685+
cached: [],
686+
name: 'foobar.example.com',
687+
record_type: 'TXT',
688+
valid: 'unknown',
689+
value: 'v=spf1 include:mailgun.org ~all'
596690
},
597691
{
598-
"priority": "10",
599-
"record_type": "MX",
600-
"valid": "unknown",
601-
"value": "mxb.mailgun.org"
602-
}],
603-
skip_verification: true,
604-
smtp_login: '[email protected]',
605-
smtp_password: 'password',
606-
spam_action: 'disabled',
607-
state: 'unverified',
608-
type: 'custom',
609-
wildcard: false
692+
is_active: true,
693+
cached: [],
694+
name: 'email.foobar.example.com',
695+
record_type: 'CNAME',
696+
valid: 'unknown',
697+
value: 'mailgun.org'
698+
}
699+
],
700+
id: '64a5880eere4eg7e1d85bc69',
701+
is_disabled: false,
702+
web_prefix: 'email',
703+
web_scheme: 'http'
610704
}
611705
```
706+
612707
- #### destroy
613708

614709
`mg.domains.destroy(domainAddress)`

dist/Classes/Domains/domain.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DNSRecord, DomainShortData, TDomain } from '../../Types/Domains';
1+
import { DNSRecord, DomainData, DomainShortData, TDomain } from '../../Types/Domains';
22
export default class Domain implements TDomain {
33
name: string;
44
require_tls: boolean;
@@ -12,5 +12,9 @@ export default class Domain implements TDomain {
1212
type: string;
1313
receiving_dns_records: DNSRecord[] | null;
1414
sending_dns_records: DNSRecord[] | null;
15-
constructor(data: DomainShortData, receiving?: DNSRecord[] | null, sending?: DNSRecord[] | null);
15+
id?: string;
16+
is_disabled?: boolean;
17+
web_prefix?: string;
18+
web_scheme?: string;
19+
constructor(data: DomainShortData | DomainData, receiving?: DNSRecord[] | null, sending?: DNSRecord[] | null);
1620
}

dist/Classes/Domains/domainsClient.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import Request from '../common/Request';
44
import DomainCredentialsClient from './domainsCredentials';
55
import DomainTemplatesClient from './domainsTemplates';
66
import DomainTagsClient from './domainsTags';
7-
import { MessageResponse, DomainTrackingData, UpdatedOpenTracking, DomainsQuery, DomainInfo, ConnectionSettings, UpdatedConnectionSettings, OpenTrackingInfo, ClickTrackingInfo, UnsubscribeTrackingInfo, ReplacementForPool, DKIMAuthorityInfo, UpdatedDKIMAuthority, DKIMSelectorInfo, UpdatedDKIMSelectorResponse, WebPrefixInfo, UpdatedWebPrefixResponse, TDomain } from '../../Types/Domains';
7+
import { MessageResponse, DomainTrackingData, UpdatedOpenTracking, DomainsQuery, DomainInfo, ConnectionSettings, UpdatedConnectionSettings, OpenTrackingInfo, ClickTrackingInfo, UnsubscribeTrackingInfo, ReplacementForPool, DKIMAuthorityInfo, UpdatedDKIMAuthority, DKIMSelectorInfo, UpdatedDKIMSelectorResponse, WebPrefixInfo, UpdatedWebPrefixResponse, TDomain, DomainUpdateInfo } from '../../Types/Domains';
88
export default class DomainsClient implements IDomainsClient {
99
request: Request;
1010
domainCredentials: IDomainCredentials;
1111
domainTemplates: IDomainTemplatesClient;
1212
domainTags: IDomainTagsClient;
1313
constructor(request: Request, domainCredentialsClient: DomainCredentialsClient, domainTemplatesClient: DomainTemplatesClient, domainTagsClient: DomainTagsClient);
14+
private _handleBoolValues;
1415
private _parseMessage;
1516
private parseDomainList;
1617
private _parseDomain;
@@ -19,6 +20,7 @@ export default class DomainsClient implements IDomainsClient {
1920
list(query?: DomainsQuery): Promise<TDomain[]>;
2021
get(domain: string): Promise<TDomain>;
2122
create(data: DomainInfo): Promise<TDomain>;
23+
update(domain: string, data: DomainUpdateInfo): Promise<TDomain>;
2224
verify(domain: string): Promise<TDomain>;
2325
destroy(domain: string): Promise<MessageResponse>;
2426
getConnection(domain: string): Promise<ConnectionSettings>;

dist/Interfaces/Domains/DomainsClient.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { APIResponse } from '../../Types/Common';
2-
import { ClickTrackingInfo, ConnectionSettings, DKIMAuthorityInfo, DKIMSelectorInfo, DomainInfo, DomainsQuery, DomainTrackingData, MessageResponse, OpenTrackingInfo, ReplacementForPool, TDomain, UnsubscribeTrackingInfo, UpdatedConnectionSettings, UpdatedDKIMAuthority, UpdatedDKIMSelectorResponse, UpdatedOpenTracking, UpdatedWebPrefixResponse, WebPrefixInfo } from '../../Types/Domains';
2+
import { ClickTrackingInfo, ConnectionSettings, DKIMAuthorityInfo, DKIMSelectorInfo, DomainInfo, DomainsQuery, DomainTrackingData, DomainUpdateInfo, MessageResponse, OpenTrackingInfo, ReplacementForPool, TDomain, UnsubscribeTrackingInfo, UpdatedConnectionSettings, UpdatedDKIMAuthority, UpdatedDKIMSelectorResponse, UpdatedOpenTracking, UpdatedWebPrefixResponse, WebPrefixInfo } from '../../Types/Domains';
33
import { IDomainCredentials } from './DomainCredentials';
44
import { IDomainTagsClient } from './DomainTags';
55
import { IDomainTemplatesClient } from './DomainTemplates';
@@ -10,6 +10,7 @@ export interface IDomainsClient {
1010
list(query?: DomainsQuery): Promise<TDomain[]>;
1111
get(domain: string): Promise<TDomain>;
1212
create(data: DomainInfo): Promise<TDomain>;
13+
update(domain: string, data: DomainUpdateInfo): Promise<TDomain>;
1314
verify(domain: string): Promise<TDomain>;
1415
destroy(domain: string): Promise<MessageResponse>;
1516
getConnection(domain: string): Promise<ConnectionSettings>;

0 commit comments

Comments
 (0)