This repository has been archived by the owner on Nov 19, 2024. It is now read-only.
forked from singer-io/tap-exacttarget
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontent_areas.py
143 lines (128 loc) · 4.98 KB
/
content_areas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import FuelSDK
import singer
from tap_exacttarget.client import request
from tap_exacttarget.dao import DataAccessObject
from tap_exacttarget.schemas import ID_FIELD, CUSTOM_PROPERTY_LIST, \
CREATED_DATE_FIELD, MODIFIED_DATE_FIELD, CUSTOMER_KEY_FIELD, \
OBJECT_ID_FIELD, with_properties
from tap_exacttarget.state import incorporate, save_state, \
get_last_record_value_for_table
LOGGER = singer.get_logger()
class ContentAreaDataAccessObject(DataAccessObject):
SCHEMA = with_properties({
'BackgroundColor': {
'type': ['null', 'string'],
'description': 'Indicates background color of content area',
},
'BorderColor': {
'type': ['null', 'string'],
'description': ('Indicates color of border surrounding '
'content area'),
},
'BorderWidth': {
'type': ['null', 'integer'],
'description': ('Indicates pixel width of border '
'surrounding content area'),
},
'CategoryID': {
'type': ['null', 'integer'],
'description': 'Specifies the identifier of the folder.',
},
'Cellpadding': {
'type': ['null', 'integer'],
'description': ('Indicates pixel value of padding '
'around content area'),
},
'Cellspacing': {
'type': ['null', 'integer'],
'description': ('Indicates pixel value of spacing '
'for content area'),
},
'Content': {
'type': ['null', 'string'],
'description': ('Identifies content contained in '
'a content area.'),
},
'CreatedDate': CREATED_DATE_FIELD,
'CustomerKey': CUSTOMER_KEY_FIELD,
'FontFamily': {
'type': ['null', 'string'],
'description': 'Indicates font family used in content area',
},
'HasFontSize': {
'type': ['null', 'boolean'],
'description': ('Indicates whether the content area includes '
'a specified font size or not'),
},
'ID': ID_FIELD,
'IsBlank': {
'type': ['null', 'boolean'],
'description': ('Indicates if specified content area '
'contains no content.'),
},
'IsDynamicContent': {
'type': ['null', 'boolean'],
'description': ('Indicates if specific content area '
'contains dynamic content.'),
},
'IsLocked': {
'type': ['null', 'boolean'],
'description': ('Indicates if specific email content area '
'within an Enterprise or Enterprise 2.0 '
'account is locked and cannot be changed by '
'subaccounts.'),
},
'IsSurvey': {
'type': ['null', 'boolean'],
'description': ('Indicates whether a specific content area '
'contains survey questions.'),
},
'Key': {
'type': ['null', 'string'],
'description': ('Specifies key associated with content area '
'in HTML body. Relates to the Email object '
'via a custom type.'),
},
'ModifiedDate': MODIFIED_DATE_FIELD,
'Name': {
'type': ['null', 'string'],
'description': 'Name of the object or property.',
},
'ObjectID': OBJECT_ID_FIELD,
'PartnerProperties': CUSTOM_PROPERTY_LIST,
'Width': {
'type': ['null', 'integer'],
'description': 'Indicates pixel width of content area',
},
})
TABLE = 'content_area'
KEY_PROPERTIES = ['ID']
def sync_data(self):
table = self.__class__.TABLE
selector = FuelSDK.ET_ContentArea
search_filter = None
retrieve_all_since = get_last_record_value_for_table(
self.state,
table,
self.config.get('start_date'),
self.config.get('offset_start_date', None),
self.is_full_table_mode()
)
if retrieve_all_since is not None:
search_filter = {
'Property': 'ModifiedDate',
'SimpleOperator': 'greaterThan',
'Value': retrieve_all_since
}
stream = request('ContentAreaDataAccessObject',
selector,
self.auth_stub,
search_filter)
for content_area in stream:
content_area = self.filter_keys_and_parse(content_area)
self.state = incorporate(self.state,
table,
'ModifiedDate',
content_area.get('ModifiedDate'))
singer.write_records(table, [content_area])
save_state(self.state)