Module: MtnOpenApi
- Defined in:
- lib/mtn_open_api.rb,
lib/mtn_open_api/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
"0.1.1"- NAME =
'mtn_open_api'
Class Method Summary collapse
Class Method Details
.load_schema(filename) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/mtn_open_api.rb', line 48 def self.load_schema(filename) gem_root = begin Gem::Specification.find_by_name(NAME).gem_dir rescue Gem::LoadError, Gem::MissingSpecError end yaml_path = File.("schemas/#{filename}.yaml", gem_root) YAML.load(File.read(yaml_path)) end |
.schemas ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mtn_open_api.rb', line 23 def self.schemas [ { api: 'sandbox-provisioning-api', namespace: "SandboxProvisioning", content: load_schema("sandbox-provisioning-api") }, { api: "collection", namespace: 'Collection', content: load_schema("collection") }, { api: "disbursement", namespace: "Disbursement", content: load_schema("disbursement") }, { api: 'remittance', namespace: "Remittance", content: load_schema("remittance") } ].freeze end |
.to_camel_case(operationId) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/mtn_open_api.rb', line 14 def self.to_camel_case(operationId) # AbCd to ab_cd operationId = operationId.gsub(/\W/, '_').gsub(/([a-z])([A-Z])/, '\1_\2').downcase # _ - words = operationId.split(/[_-]/) camel_case_words = words.map.with_index { |w, i| i.zero? ? w : w.capitalize } camel_case_words.join end |