<commit_before># Copyright 2016, 2017 <NAME>. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import logging
from threading import Lock
from flask import Flask, Response, jsonify, request, make_response, json, url_for

# Create Flask application
app = Flask(__name__)
app.config['LOGGING_LEVEL'] = logging.INFO

# Status Codes
HTTP_200_OK = 200
HTTP_201_CREATED = 201
HTTP_204_NO_CONTENT = 204
HTTP_400_BAD_REQUEST = 400
HTTP_404_NOT_FOUND = 404
HTTP_409_CONFLICT = 409

# Lock for thread-safe counter increment
lock = Lock()

# dummy data for testing
current_promotion_id = 2
inactive_promotions=[]
promotions = [
    {
        'id': 0,
        'name': "Buy one, get one free",
        'description': 'Buy an item having a cost of atleast 30$ to get one free.Cost of the higher price product will be taken into account',
        'kind':'sales-promotion1'
    },
    {
        'id': 1,
        'name': "Buy one, get two free",
        'description': 'Buy an item having a cost of atleast 50$ to get two free.Cost of the highest price product will be taken into account',
        'kind':'sales-promotion2'
    },
    {
        'id': 2,
        'name': "Buy one, get two free",
        'description': 'Buy an item having a cost of atleast 50$ to get two free.Cost of the highest price product will be taken into account',
        'kind':'sales-promotion1'
    }
]

######################################################################
# GET INDEX
######################################################################
@app.route('/')
def index():
    promotion_url = request.base_url + "promotions"
    return make_response(jsonify(name='Promotion REST API Service',version='1.0',url=promotion_url), HTTP_200_OK)

######################################################################
# LIST ALL PROMOTIONS
######################################################################
@app.route('/promotions', methods=['GET'])
def list_promotions():
    results = []
    #kind = request.args.get('kind')
    if bool(promotions):
        results = [promotion for promotion in enumerate(promotions)]
        
    return make_response(jsonify(results), HTTP_200_OK)<commit_msg>Fixed Issue #19 as status was missing in promotion<commit_after># Copyright 2016, 2017 <NAME>. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import logging
from threading import Lock
from flask import Flask, Response, jsonify, request, make_response, json, url_for

# Create Flask application
app = Flask(__name__)
app.config['LOGGING_LEVEL'] = logging.INFO

# Status Codes
HTTP_200_OK = 200
HTTP_201_CREATED = 201
HTTP_204_NO_CONTENT = 204
HTTP_400_BAD_REQUEST = 400
HTTP_404_NOT_FOUND = 404
HTTP_409_CONFLICT = 409

# Lock for thread-safe counter increment
lock = Lock()

# dummy data for testing
current_promotion_id = 2
inactive_promotions=[]
promotions = [
    {
        'id': 0,
        'name': "Buy one, get one free",
        'description': 'Buy an item having a cost of atleast 30$ to get one free.Cost of the higher price product will be taken into account',
        'kind':'sales-promotion1',
        'status':'Active'
    },
    {
        'id': 1,
        'name': "Buy one, get two free",
        'description': 'Buy an item having a cost of atleast 50$ to get two free.Cost of the highest price product will be taken into account',
        'kind':'sales-promotion2',
        'status':'Active'

    },
    {
        'id': 2,
        'name': "Buy one, get two free",
        'description': 'Buy an item having a cost of atleast 50$ to get two free.Cost of the highest price product will be taken into account',
        'kind':'sales-promotion1',
        'status':'Active'
    }
]

######################################################################
# GET INDEX
######################################################################
@app.route('/')
def index():
    promotion_url = request.base_url + "promotions"
    return make_response(jsonify(name='Promotion REST API Service',version='1.0',url=promotion_url), HTTP_200_OK)

######################################################################
# LIST ALL PROMOTIONS
######################################################################
@app.route('/promotions', methods=['GET'])
def list_promotions():
    results = []
    #kind = request.args.get('kind')
    if bool(promotions):
        results = [promotion for promotion in enumerate(promotions)]
        
    return make_response(jsonify(results), HTTP_200_OK)
{'fraction_non_alphanumeric': 0.19121118576357363, 'fraction_numerical': 0.025422189940076268, 'mean_word_length': 4.123720930232558, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '725248', 'n_tokens_mistral': 1654, 'n_tokens_neox': 1476, 'n_words': 558}