Skip to content

Networkninja

flowtask.components.NetworkNinja

NetworkNinja

NetworkNinja(loop=None, job=None, stat=None, **kwargs)

Bases: HTTPService, FlowComponent

NetworkNinja.

Overview: Router for processing NetworkNinja Payloads.
Properties

+---------------+----------+------------------------------------------+ | Name | Required | Description | +---------------+----------+------------------------------------------+ | action | Yes | Type of operation (get_batch, etc) | +---------------+----------+------------------------------------------+ | credentials | No | API credentials (taken from config) | +---------------+----------+------------------------------------------+ | payload | No | Additional payload parameters | +---------------+----------+------------------------------------------+

Supported Types
  • get_batch: Retrieves batch acceptance data

get_batch async

get_batch()

Handle get_batch operation type

Uses to download a Batch from NetworkNinja SQS Queue.

get_multi_batches async

get_multi_batches()

Get Multiples batches at once.

report_batch async

report_batch(batch_id, report_code=200)

Handle report_batch operation type

Uses to report a Batch to NetworkNinja SQS Queue.

run async

run()

Run NetworkNinja Router.

models

abstract

AbstractPayload

Bases: BaseModel

Abstract Payload Model.

Common fields implemented by any Object in NetworkNinja Payloads.

ensure_timezone
ensure_timezone(dt)

Ensure a datetime has timezone information.

insert_record async
insert_record(conn, **kwargs)

Insert Record to Database.

on_sync async
on_sync(conn, upsert=True)

Sync Current Object with the Database.

save async
save(conn, pk=None, **kwargs)

Save the Object to the Database.

sync async
sync(**kwargs)

Sync the Object with the Database

update_many async
update_many(objects, primary_keys=None, **kwargs)

Upsert Several Records in Database.

upsert_record async
upsert_record(**kwargs)

Upsert Record to Database.

account

Account

Bases: AbstractPayload

{ "metadata": { "type": "retailer", "transaction_type": "UPSERT", "source": "MainEvent", "client": "global", "client_id": 1, "orgid": null, "timestamp": 1742240432.348096 }, "payload": { "account_id": 26, "account_name": "Brandsmart", "active": true } },

events

Event

Bases: AbstractPayload

Event Model.

EventPosition

Bases: BaseModel

Event Position Model.

EventPunch

Bases: AbstractPayload

Event Punch Model.

Example

{

    "cico_id": 4089,
    "event_id": 12272,
    "visitor_id": 18180,
    "latitude": "32.8066746",
    "longitude": "-97.426601",
    "cico_type": "out",
    "related_checkout_id": null,
    "total_hours": null,
    "client_id": 57,
    "orgid": 106,
    "visitor_name": "Margaret Ojeogwu",
    "timestamp_utc": "2025-03-22T01:17:36+00:00"
}

forms

Condition

Bases: BaseModel

Defines a Condition, a condition for a Logic Group. Example: { "condition_id": 1835, "condition_logic": "EQUALS", "condition_comparison_value": "Regular", "condition_question_reference_id": 48, "condition_option_id": 4308 }

Form

Bases: AbstractPayload

Reference to a Form:

on_sync async
on_sync()

Sync the form with the database.

FormData

Bases: AbstractPayload

Defines a Form Data, a collection of responses to a Form.

Example

{ "form_data_id": 1, "formid": 1, "client_id": 59, "orgid": 77, "store_id": 1, "store_name": "Best Buy 4350", "user_id": 1, "user_name": "Arturo", "created_at": "2025-02-01T00:00:00-06:00", "updated_at": "2025-02-01T00:00:00-06:00", "form_responses": [ { "column_name": "8550", "data": "Arturo", "question_shown_to_user": true, "column_id": "150698" } ] }

save async
save(conn, pk=None, **kwargs)

Always do an UPSERT on Form Data:

FormDefinition

Bases: AbstractPayload

Defines a Form (recap) definition.

FormMetadata

Bases: AbstractPayload

Defines a Form Metadata, a single question from a Form.

Example

{ "column_name": "8452", "description": "Please provide a photo of the starting odometer reading", "is_active": true, "data_type": "FIELD_IMAGE_UPLOAD", "formid": 1, "form_name": "Territory Manager Visit Form TEST", "client_id": 59, "client_name": "TRENDMICRO", "orgid": 77 }

insert_record async
insert_record(conn, **kwargs)

Insert Record to Database.

FormResponse

Bases: BaseModel

Defines a Form Response, a response to a Form.

Example

{ "event_id": 10516, "column_name": 8550, "data": "Arturo", "question_shown_to_user": true, "column_id": "150698" }

LogicGroup

Bases: BaseModel

Defines a Logic Group, a group of questions in a Form. Example: { "logic_group_id": 1706, "conditions": [ { "condition_id": 1835, "condition_logic": "EQUALS", "condition_comparison_value": "Regular", "condition_question_reference_id": 48, "condition_option_id": 4308 } ] }

Question

Bases: BaseModel

Defines a Question, a single question in a Form. Example: { "question_id": 48, "question_column_name": "8501", "question_description": "Purpose of Visit", "question_logic_groups": [], "validations": [ { "validation_id": 43, "validation_type": "responseRequired", "validation_logic": null, "validation_comparison_value": null, "validation_question_reference_id": null } ] }

QuestionBlock

Bases: BaseModel

Defines a Question Block, a collection of questions in a Form.

Example

{ "question_block_id": 9, "question_block_type": "simple", "question_block_logic_groups": [], "questions": [] }

Validation

Bases: BaseModel

Defines a Validation, a validation rule for a question. Example: { "validation_id": 43, "validation_type": "responseRequired", "validation_logic": null, "validation_comparison_value": null, "validation_question_reference_id": null }

organization

Organization

photos

Document

Bases: AbstractPayload

Document Model.

Represents a document in the system.

Example

{ "document_id": 1, "document_name": "Test Document", "document_path": "https://www.example.com/test.pdf", "description": "Test Document Description", "created_on": "2025-02-01T00:00:00-06:00", "store_number": "12345", "account_id": 1, "account_name": "Test Account", "question_name": "Test Question", "url_parts": "https://www.example.com/test.pdf" }

PhotoCategory

Bases: AbstractPayload

Photo Category Model.

Represents a photo category in the system.

Example

{ "category_id": 53, "name": "TEST Category", "client_id": 61, "enabled": false, "orgid": 71, "client_name": "TRO Walmart Assembly" }

project

Project

Bases: AbstractPayload

NN Projects related to a Client.

Example payload: "payload": { "project_id": 595, "project_name": "Test Program", "is_active": true, "start_timestamp": "2025-02-01T00:00:00-06:00", "end_timestamp": "2025-02-28T00:00:00-06:00", "inserted_at": "2025-01-30T19:19:40-06:00", "updated_at": "2025-01-30T19:19:40-06:00", "description": "", "orgid": 69, "client_id": 56, "client_name": "EPSON" }

store

CustomStoreField

Bases: BaseModel

Custom Field Model for Store.

Represents a custom field for a store.

Example

{ "custom_id": 33, "custom_name": "Store Name", "custom_value": "Best Buy 4350", "custom_orgid": null, "custom_client_id": 1

}

Store

Bases: AbstractPayload

Store Model.

Represents a store in the system.

Example

{ "store_name": "KILMARNOCK-4350", "store_address": "200 Old Fair Grounds Way", "city": "Kilmarnock", "zipcode": "22482", "phone_number": "804-435-6149", }

StoreGeography

Bases: AbstractPayload

Store Geography Model.

Represents a store's geographical information.

Example

{ "geoid": 479, "region": "Assembly - Region", "district": "Assembly - District", "market": "136", "company_id": 61, "orgid": 71, "client_id": 61, "client_name": "ASSEMBLY" }

StoreType

Bases: AbstractPayload

Store Type Model.

Represents a store type in the system.

Example

{ "store_type_id": 1, "store_type_name": "Retail", "store_type_description": "Retail Store" }

user

User

Bases: AbstractPayload

User Model.

Represents a user in the system.

Example

{ "user_id": 1, "username": "admin", "employee_number": 1234, "first_name": "John", "last_name": "Doe", "email": " "mobile_number": "123-456-7890", "role_id": 1, "role_name": "Admin", "address": "1234 Elm St", "city": "Springfield", "state_code": "IL", "zipcode": "62704", "latitude": 39.781721, "longitude": -89.650148, }

router

EmptyQueue

Bases: BaseException

Exception raised when the Queue is empty.

Attributes:

Name Type Description
Example
NetworkNinja

comment: Download Batch from NetworkNinja. action: get_batch avoid_acceptance: true

NetworkNinja

NetworkNinja(loop=None, job=None, stat=None, **kwargs)

Bases: HTTPService, FlowComponent

NetworkNinja.

Overview: Router for processing NetworkNinja Payloads.
Properties

+---------------+----------+------------------------------------------+ | Name | Required | Description | +---------------+----------+------------------------------------------+ | action | Yes | Type of operation (get_batch, etc) | +---------------+----------+------------------------------------------+ | credentials | No | API credentials (taken from config) | +---------------+----------+------------------------------------------+ | payload | No | Additional payload parameters | +---------------+----------+------------------------------------------+

Supported Types
  • get_batch: Retrieves batch acceptance data
get_batch async
get_batch()

Handle get_batch operation type

Uses to download a Batch from NetworkNinja SQS Queue.

get_multi_batches async
get_multi_batches()

Get Multiples batches at once.

report_batch async
report_batch(batch_id, report_code=200)

Handle report_batch operation type

Uses to report a Batch to NetworkNinja SQS Queue.

run async
run()

Run NetworkNinja Router.