Commit 8bcd994 1 parent addd182 commit 8bcd994 Copy full SHA for 8bcd994
File tree 3 files changed +65
-1
lines changed
3 files changed +65
-1
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,13 @@ def push_templates(attributes = {})
145
145
batch
146
146
end
147
147
148
- end
148
+ def get_data_removal_status ( id )
149
+ format_response ( http_client . get ( "data-removals/#{ id } " ) )
150
+ end
149
151
152
+ def request_data_removal ( attributes = { } )
153
+ data = serialize ( HashHelper . to_postmark ( attributes ) )
154
+ format_response ( http_client . post ( 'data-removals' , data ) )
155
+ end
156
+ end
150
157
end
Original file line number Diff line number Diff line change 105
105
# delete
106
106
expect { subject . delete_server ( new_server [ :id ] ) } . not_to raise_error
107
107
end
108
+
109
+ it 'manages data removals' do
110
+ # create
111
+ data_removal_status = subject . request_data_removal (
112
+ 'requested_by' => 'sender@postmarkapp.com' ,
113
+ 'requested_for' => 'test@example.com' ,
114
+ 'notify_when_completed' => false
115
+ )
116
+
117
+ expect ( data_removal_status [ :status ] ) . to eq ( 'Pending' )
118
+
119
+ # get
120
+ fetched_data_removal_status = subject . get_data_removal_status ( data_removal_status [ :id ] )
121
+
122
+ expect ( fetched_data_removal_status [ :id ] ) . to eq ( data_removal_status [ :id ] )
123
+ end
108
124
end
Original file line number Diff line number Diff line change 728
728
end
729
729
end
730
730
731
+ describe '#get_data_removal_status' do
732
+ let ( :response ) {
733
+ {
734
+ "ID" => 42 ,
735
+ "Status" => "Done"
736
+ }
737
+ }
738
+
739
+ it 'performs a GET request to /data-removals/:id endpoint' do
740
+ allow ( subject . http_client ) . to receive ( :get ) .
741
+ with ( 'data-removals/42' ) . and_return ( response )
742
+ subject . get_data_removal_status ( 42 )
743
+ end
744
+
745
+ it 'formats the keys of returned response' do
746
+ allow ( subject . http_client ) . to receive ( :get ) . and_return ( response )
747
+ keys = subject . get_data_removal_status ( 42 ) . keys
748
+ expect ( keys . all? { |k | k . is_a? ( Symbol ) } ) . to be true
749
+ end
750
+ end
751
+
752
+ describe '#request_data_removal' do
753
+ let ( :response ) {
754
+ {
755
+ "ID" => 42 ,
756
+ "Status" => "Done"
757
+ }
758
+ }
759
+
760
+ it 'performs a POST request to /data-removals endpoint' do
761
+ allow ( subject . http_client ) . to receive ( :post ) .
762
+ with ( 'data-removals' , an_instance_of ( String ) ) . and_return ( response )
763
+ subject . request_data_removal ( :foo => 'bar' )
764
+ end
765
+
766
+ it 'formats the keys of returned response' do
767
+ allow ( subject . http_client ) . to receive ( :post ) . and_return ( response )
768
+ keys = subject . request_data_removal ( :foo => 'bar' ) . keys
769
+ expect ( keys . all? { |k | k . is_a? ( Symbol ) } ) . to be true
770
+ end
771
+ end
731
772
end
732
773
end
You can’t perform that action at this time.
0 commit comments