Skip to content

Commit 2f00c67

Browse files
committed
for supporting hash key field in sdk
1 parent 108a8fc commit 2f00c67

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

generator/cybersource_ruby_SDK_gen.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ git checkout spec/models/unauthorized_client_error_spec.rb
173173
cd ./lib/cybersource_rest_client/models
174174
echo "starting of replacing the hash keyword in models"
175175
for file in ./*.rb; do \
176-
sed -i 's/attr_accessor :hash_value/attr_accessor :hash \n \t alias :hash_value :hash \n \t alias :hash_value :hash/g' "$file"
177-
sed -i "s/:'hash_value' => :'hashValue'/:'hash_value' => :'hash'/g" "$file"
178-
sed -i "s/:'hash_value' => :'hash_value'/:'hash_value' => :'hash'/g" "$file"
176+
sed -i 's/attr_accessor :sdk_hash_value/attr_accessor :hash \n \t alias :sdk_hash_value :hash/g' "$file"
177+
sed -i "s/:'sdk_hash_value' => :'sdkHashValue'/:'sdk_hash_value' => :'hash'/g" "$file"
178+
sed -i "s/:'sdk_hash_value' => :'sdk_hash_value'/:'sdk_hash_value' => :'hash'/g" "$file"
179179
done
180180
echo "completed the task of replacing the hash keyword in models"

generator/replaceFieldNameFromRequestBody.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,15 @@
77

88
apis = spec_json["paths"].keys()
99

10-
fieldName= "hash"
11-
replacedFieldName= "hashValue"
10+
# fieldNames in request and response body structure and change with the value of it.
11+
# eg: fieldNames ={
12+
# "fieldName" : "changed sdk field name to be used",
13+
# "fieldName1" :"changed field name to be used in sdk"
14+
# }
15+
16+
fieldNames = {
17+
"hash": "sdkHashValue"
18+
}
1219

1320
def replaceFieldNamefromJSONObject(jsonObject):
1421
fields= jsonObject.keys()
@@ -21,8 +28,8 @@ def replaceFieldNamefromJSONObject(jsonObject):
2128

2229
result_json={}
2330
for field in fields:
24-
if field == fieldName:
25-
result_json[replacedFieldName]= jsonObject[field]
31+
if field in fieldNames.keys():
32+
result_json[fieldNames[field]]= jsonObject[field]
2633
else:
2734
result_json[field]=jsonObject[field]
2835
return result_json
@@ -39,8 +46,8 @@ def replaceFieldNamefromJSONObjectForResponse(jsonObject):
3946

4047
result_json={}
4148
for field in fields:
42-
if field == fieldName:
43-
result_json[replacedFieldName]= jsonObject[field]
49+
if field in fieldNames.keys():
50+
result_json[fieldNames[field]]= jsonObject[field]
4451
else:
4552
result_json[field]=jsonObject[field]
4653
return result_json

0 commit comments

Comments
 (0)