commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
SubscriptionDraftBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
16 use stdClass;
17 
21 final class SubscriptionDraftBuilder implements Builder
22 {
27  private $changes;
28 
33  private $destination;
34 
39  private $key;
40 
45  private $messages;
46 
51  private $format;
52 
59  public function getChanges()
60  {
61  return $this->changes;
62  }
63 
70  public function getDestination()
71  {
72  return $this->destination instanceof DestinationBuilder ? $this->destination->build() : $this->destination;
73  }
74 
81  public function getKey()
82  {
83  return $this->key;
84  }
85 
92  public function getMessages()
93  {
94  return $this->messages;
95  }
96 
103  public function getFormat()
104  {
105  return $this->format instanceof DeliveryFormatBuilder ? $this->format->build() : $this->format;
106  }
107 
112  public function withChanges(?ChangeSubscriptionCollection $changes)
113  {
114  $this->changes = $changes;
115 
116  return $this;
117  }
118 
123  public function withDestination(?Destination $destination)
124  {
125  $this->destination = $destination;
126 
127  return $this;
128  }
129 
134  public function withKey(?string $key)
135  {
136  $this->key = $key;
137 
138  return $this;
139  }
140 
145  public function withMessages(?MessageSubscriptionCollection $messages)
146  {
147  $this->messages = $messages;
148 
149  return $this;
150  }
151 
156  public function withFormat(?DeliveryFormat $format)
157  {
158  $this->format = $format;
159 
160  return $this;
161  }
162 
167  public function withDestinationBuilder(?DestinationBuilder $destination)
168  {
169  $this->destination = $destination;
170 
171  return $this;
172  }
173 
178  public function withFormatBuilder(?DeliveryFormatBuilder $format)
179  {
180  $this->format = $format;
181 
182  return $this;
183  }
184 
185  public function build(): SubscriptionDraft
186  {
187  return new SubscriptionDraftModel(
188  $this->changes,
189  $this->destination instanceof DestinationBuilder ? $this->destination->build() : $this->destination,
190  $this->key,
191  $this->messages,
192  $this->format instanceof DeliveryFormatBuilder ? $this->format->build() : $this->format
193  );
194  }
195 
196  public static function of(): SubscriptionDraftBuilder
197  {
198  return new self();
199  }
200 }