def post(self): return compose( helpers.make_create( accounts.Account, create_fields, id_field, ), request.get_json, )(), 201
def post(self): return compose( helpers.make_create( providers.Provider, create_fields, id_field, ), request.get_json, )(), 201
def create(fields, account, provider, body, **args): if not account.get(): raise ReferencedEntityNotFound("Account") if not provider.get(): raise ReferencedEntityNotFound("Provider") return helpers.make_create(Service, fields + ["parent"])(merge( body, { "provider": provider, "parent": account }), **args)
def create(service_key, body): req_has_failed = body.get("status") == "failure" fields = ["status", "cost", "parent"] message = helpers.make_create( Message, fields + ["response"] if req_has_failed else fields )(merge(body, {"parent": service_key})) if req_has_failed: raise ServiceCallFailure( "{} - {}: {}".format(service_key.urlsafe(), message.get("id"), body) ) return message
def create(service_key, body): req_has_failed = body.get('status') == 'failure' fields = ['status', 'cost', 'parent'] message = helpers.make_create( Message, fields + ['response'] if req_has_failed else fields, )(merge(body, {'parent': service_key})) if req_has_failed: raise ServiceCallFailure("{} - {}".format(service_key.id(), message.get('id'))) return message
def mutate_and_get_payload(cls, root, info, **input): fields = merge( pick(["email", "name"], input), { "password_hash": generate_password_hash( input.get("password"), method="sha256" ) }, ) user = helpers.make_create( UserModel, ["email", "name", "password_hash"], "email" )(fields, as_obj=True) return SignUp(user=user)
def create(fields, site, body): account = ndb.Key('Account', site) if not account.get(): raise ReferencedEntityNotFound('Account') provider = ndb.Key('Provider', body.get('provider')) if not provider.get(): raise ReferencedEntityNotFound('Provider') return helpers.make_create( Service, fields + ['parent'], )(merge(body, { 'provider': provider, 'parent': account }))
def sign_up(): data = request.get_json() fields = merge( pick(["email", "name"], data), { "password_hash": generate_password_hash( data.get("password"), method="sha256" ) }, ) user = helpers.make_create(UserModel, ["email", "name", "password_hash"], "email")( fields, as_obj=True ) access_token = create_access_token(identity=user.key.urlsafe()) return jsonify({"access_token": access_token})
def create(fields, user, body, **args): if not user.get(): raise ReferencedEntityNotFound("User") return helpers.make_create(Provider, fields + ["parent"], "name")(merge(body, {"parent": user}), **args)