mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Add DFC API endpoint for sales data
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module DfcProvider
|
||||
# Aggregates anonymised sales data for a research project.
|
||||
class AffiliateSalesDataController < DfcProvider::ApplicationController
|
||||
def show
|
||||
person = PersonBuilder.person(current_user)
|
||||
render json: DfcIo.export(person)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -12,4 +12,6 @@ DfcProvider::Engine.routes.draw do
|
||||
resources :affiliated_by, only: [:create, :destroy], module: 'enterprise_groups'
|
||||
end
|
||||
resources :persons, only: [:show]
|
||||
|
||||
resource :affiliate_sales_data, only: [:show]
|
||||
end
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative "../swagger_helper"
|
||||
|
||||
RSpec.describe "AffiliateSalesData", swagger_doc: "dfc.yaml", rswag_autodoc: true do
|
||||
let(:user) { create(:oidc_user, id: 10_000) }
|
||||
|
||||
before { login_as user }
|
||||
|
||||
path "/api/dfc/affiliate_sales_data" do
|
||||
get "Show sales data of person's affiliate enterprises" do
|
||||
produces "application/json"
|
||||
|
||||
response "200", "successful" do
|
||||
run_test! do
|
||||
expect(json_response).to include(
|
||||
"@id" => "http://test.host/api/dfc/persons/10000",
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -69,6 +69,23 @@ paths:
|
||||
dfc-b:region: Victoria
|
||||
'404':
|
||||
description: not found
|
||||
"/api/dfc/affiliate_sales_data":
|
||||
get:
|
||||
summary: Show sales data of person's affiliate enterprises
|
||||
tags:
|
||||
- AffiliateSalesData
|
||||
responses:
|
||||
'200':
|
||||
description: successful
|
||||
content:
|
||||
application/json:
|
||||
examples:
|
||||
test_example:
|
||||
value:
|
||||
"@context": https://www.datafoodconsortium.org
|
||||
"@id": http://test.host/api/dfc/persons/10000
|
||||
"@type": dfc-b:Person
|
||||
dfc-b:logo: ''
|
||||
"/api/dfc/enterprises/{enterprise_id}/catalog_items":
|
||||
parameters:
|
||||
- name: enterprise_id
|
||||
|
||||
Reference in New Issue
Block a user