Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions source/OpenAPI-Client/OARequestBuilder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Class {
#package : 'OpenAPI-Client'
}

{ #category : 'building' }
OARequestBuilder >> addFormBody: aDictionary [
client entity: (ZnApplicationFormUrlEncodedEntity withAll: (self flattenFormParameters: aDictionary))
]

{ #category : 'as yet unclassified' }
OARequestBuilder >> addJSONBody: aDictionary [
client
Expand Down Expand Up @@ -58,6 +63,38 @@ OARequestBuilder >> client: aClient [
client := aClient
]

{ #category : 'forms' }
OARequestBuilder >> flattenFormParameters: aDictionary [
| result |
result := Dictionary new.
self flattenFormParameters: aDictionary prefix: nil into: result.
^ result
]

{ #category : 'forms' }
OARequestBuilder >> flattenFormParameters: anObject prefix: aPrefixString into: aDictionary [
anObject isString ifTrue: [
aDictionary at: aPrefixString put: anObject.
^ self ].
(anObject isKindOf: Dictionary) ifTrue: [
anObject keysAndValuesDo: [ :k :v |
self
flattenFormParameters: v
prefix: (aPrefixString
ifNil: [ k asString ]
ifNotNil: [ aPrefixString , (String with: $[) , k asString , (String with: $]) ])
into: aDictionary ].
^ self ].
(anObject isKindOf: SequenceableCollection) ifTrue: [
anObject doWithIndex: [ :v :i |
self
flattenFormParameters: v
prefix: (aPrefixString , (String with: $[) , (i - 1) asString , (String with: $]))
into: aDictionary ].
^ self ].
aDictionary at: aPrefixString put: anObject asString
]

{ #category : 'initialization' }
OARequestBuilder >> initialize [
super initialize.
Expand Down
Loading