Class: StitchData::Api
- Inherits:
-
Object
- Object
- StitchData::Api
- Defined in:
- lib/stitch_data/api.rb
Constant Summary collapse
- API_BASE_URL =
'https://api.stitchdata.com/v2/import'.freeze
- DEFAULT_API_ACTION =
"upsert".freeze
- DEFAULT_REQUEST_PARAMS =
{ content_type: 'application/json', accept: 'json' }.freeze
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#key_names ⇒ Object
Returns the value of attribute key_names.
-
#sequence ⇒ Object
Returns the value of attribute sequence.
-
#table_name ⇒ Object
Returns the value of attribute table_name.
Instance Method Summary collapse
-
#initialize(table_name, sequence, key_names, data) ⇒ Api
constructor
A new instance of Api.
- #upsert! ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(table_name, sequence, key_names, data) ⇒ Api
Returns a new instance of Api.
8 9 10 11 12 13 14 15 |
# File 'lib/stitch_data/api.rb', line 8 def initialize(table_name, sequence, key_names, data) validate_key_names_is_array(key_names) @request_params = { Authorization: "Bearer #{StitchData.configuration.token}" }.merge(DEFAULT_REQUEST_PARAMS) @table_name = table_name.to_s @sequence = sequence.to_sym @key_names = key_names.map(&:to_s) @data = build_records(data) end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
3 4 5 |
# File 'lib/stitch_data/api.rb', line 3 def data @data end |
#key_names ⇒ Object
Returns the value of attribute key_names.
3 4 5 |
# File 'lib/stitch_data/api.rb', line 3 def key_names @key_names end |
#sequence ⇒ Object
Returns the value of attribute sequence.
3 4 5 |
# File 'lib/stitch_data/api.rb', line 3 def sequence @sequence end |
#table_name ⇒ Object
Returns the value of attribute table_name.
3 4 5 |
# File 'lib/stitch_data/api.rb', line 3 def table_name @table_name end |
Instance Method Details
#upsert! ⇒ Object
17 18 19 |
# File 'lib/stitch_data/api.rb', line 17 def upsert! stitch_post_request("#{API_BASE_URL}/push") end |
#validate! ⇒ Object
21 22 23 |
# File 'lib/stitch_data/api.rb', line 21 def validate! stitch_post_request("#{API_BASE_URL}/validate") end |