Skip to content

Commit

Permalink
Skip locali for now
Browse files Browse the repository at this point in the history
This will be handle manually by them.
  • Loading branch information
thibaudgg committed Sep 20, 2024
1 parent 3ee1cbe commit 2821b4c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class App < Sinatra::Base
verify_signature!
payload = parse_payload

logger.info payload
begin
member_params = Webhook.handle!(payload)
logger.info payload
logger.info member_params
rescue => e
logger.info "#{e.class} - #{e.message}"
Expand Down
28 changes: 14 additions & 14 deletions config/mapping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,6 @@ cocagne:
33578: 37 # 158 rte d'Aïre 1219 Aïre
33577: 48 # 12 ch. de la Verseuse 1219 Le Lignon

locali:
store_id: 33
api_endpoint: https://admin.panier-locali.ch/api/v1/members
basket_sizes:
34090: 1 # Panier famille ?
depots:
35412: 9 # Vernier (à confirmer)
35411: 7 # Meyrin Champs Fréchets (à confirmer)
34101: 4 # Servette
34099: 1 # Plainpalais
34100: 3 # Plan les Ouates Sciers (à confirmer)
34097: 2 # Meyrin Vergers
34096: 6 # Conches

touviere:
store_id: 34
api_endpoint: https://admin.touviere.ch/api/v1/members
Expand All @@ -80,3 +66,17 @@ touviere:
34132: 2 # Chêne-Bourg
34131: 3 # Jonction
34129: 1 # Domaine de la Touvière

# locali:
# store_id: 33
# api_endpoint: https://admin.panier-locali.ch/api/v1/members
# basket_sizes:
# 34090: 1 # Panier famille ?
# depots:
# 35412: 9 # Vernier (à confirmer)
# 35411: 7 # Meyrin Champs Fréchets (à confirmer)
# 34101: 4 # Servette
# 34099: 1 # Plainpalais
# 34100: 3 # Plan les Ouates Sciers (à confirmer)
# 34097: 2 # Meyrin Vergers
# 34096: 6 # Conches
62 changes: 31 additions & 31 deletions test/app_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,37 +62,37 @@ def test_valid_webhook_request_cocagne
}.to_json
end

def test_valid_webhook_request_locali
ENV["LOCALI_API_TOKEN"] = "api-token-locali"
payload = File.read('test/fixtures/order_completed_locali.json')
stub_request(:any, "https://admin.panier-locali.test/api/v1/members")
.to_return(status: 201)

request(payload)

assert_equal 204, last_response.status
assert_empty last_response.body

assert_requested :post, "https://admin.panier-locali.test/api/v1/members",
times: 1,
headers: {
"Content-Type" => "application/json",
"Authorization" => "Token token=api-token-locali"
},
body: {
name: "Doe John",
emails: "[email protected]",
phones: "0791234567",
address: "Chemin de la Mairie 1",
city: "Genève",
zip: "1205",
country_code: "CH",
note: "Commande locali-ge.ch #35717",
waiting_basket_size_id: 1,
waiting_depot_id: 3,
members_basket_complements_attributes: []
}.to_json
end
# def test_valid_webhook_request_locali
# ENV["LOCALI_API_TOKEN"] = "api-token-locali"
# payload = File.read('test/fixtures/order_completed_locali.json')
# stub_request(:any, "https://admin.panier-locali.test/api/v1/members")
# .to_return(status: 201)

# request(payload)

# assert_equal 204, last_response.status
# assert_empty last_response.body

# assert_requested :post, "https://admin.panier-locali.test/api/v1/members",
# times: 1,
# headers: {
# "Content-Type" => "application/json",
# "Authorization" => "Token token=api-token-locali"
# },
# body: {
# name: "Doe John",
# emails: "[email protected]",
# phones: "0791234567",
# address: "Chemin de la Mairie 1",
# city: "Genève",
# zip: "1205",
# country_code: "CH",
# note: "Commande locali-ge.ch #35717",
# waiting_basket_size_id: 1,
# waiting_depot_id: 3,
# members_basket_complements_attributes: []
# }.to_json
# end

def test_valid_webhook_request_touviere
ENV["TOUVIERE_API_TOKEN"] = "api-token-touviere"
Expand Down

0 comments on commit 2821b4c

Please sign in to comment.