Class: Trailblazer::Pro::Trace::Store
- Inherits:
-
Activity::Railway
- Object
- Activity::Railway
- Trailblazer::Pro::Trace::Store
- Defined in:
- lib/trailblazer/pro/trace/store.rb
Instance Method Summary collapse
- #error(ctx, response:) ⇒ Object
- #extract_id(ctx, response:) ⇒ Object
- #upload(ctx, firebase_upload_url:, data_to_store:, id_token:, firestore_fields_template:) ⇒ Object
Instance Method Details
#error(ctx, response:) ⇒ Object
33 34 35 |
# File 'lib/trailblazer/pro/trace/store.rb', line 33 def error(ctx, response:, **) puts response.inspect end |
#extract_id(ctx, response:) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/trailblazer/pro/trace/store.rb', line 26 def extract_id(ctx, response:, **) parsed_response = JSON.parse(response.body) ctx[:firestore_name] = parsed_response["name"] ctx[:id] = ctx[:firestore_name].split("/").last end |
#upload(ctx, firebase_upload_url:, data_to_store:, id_token:, firestore_fields_template:) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/trailblazer/pro/trace/store.rb', line 8 def upload(ctx, firebase_upload_url:, data_to_store:, id_token:, firestore_fields_template:, **) fields = data_to_store[:fields].merge(firestore_fields_template) json_to_store = JSON.dump(data_to_store.merge(fields: fields))#.to_json # puts "@@@@@ DATA SIZE: #{json_to_store.size / 1024} kb" ctx[:response] = Faraday.post( firebase_upload_url, json_to_store, {'Content-Type'=>'application/json', "Accept": "application/json", "Authorization": "Bearer #{id_token}" } ) ctx[:response].status == 200 end |